Skip to content

Commit 8ad9f4e

Browse files
committed
Fix a dumb type condition in gdrive.py
hashlib.md5(dbpath) returns a hash object, not a hex string. Comparing a string (md5Checksum) to a hash object with != always returns True. This means the DB-replacement code path is always entered, allowing an attacker who sends a forged notification (with the known static token) to trigger an arbitrary metadata.db download from GDrive, replacing the live database.
1 parent 0887789 commit 8ad9f4e

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

cps/gdrive.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def on_received_watch_confirmation():
140140
if response:
141141
dbpath = os.path.join(config.config_calibre_dir, "metadata.db").encode()
142142
if not response['deleted'] and response['file']['title'] == 'metadata.db' \
143-
and response['file']['md5Checksum'] != hashlib.md5(dbpath): # nosec
143+
and response['file']['md5Checksum'] != hashlib.md5(dbpath).hexdigest(): # nosec
144144
tmp_dir = get_temp_dir()
145145

146146
log.info('Database file updated')

0 commit comments

Comments
 (0)