Don't restore cached backup password (bkpw) from backup file#653
Open
dmonakhov wants to merge 1 commit into
Open
Don't restore cached backup password (bkpw) from backup file#653dmonakhov wants to merge 1 commit into
dmonakhov wants to merge 1 commit into
Conversation
c03d892 to
16903b9
Compare
Collaborator
|
this requires attacker to know backup password - which is game over anyways. I do not mind to merge it, but remove the test - it is hacky... |
Restore mirrored the write-side strip of bkpw: a crafted backup could inject setting.bkpw and fixate the password used for future backups. Drop it on restore
16903b9 to
ca06dfd
Compare
Contributor
Author
|
Ack. Drop regression test.
Agree that knowing backup password is already a critical, but situation can be worse. |
Contributor
|
add a line to Next-Changelog.md linking to your github handle, and I will merge. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
render_backup_contents()deliberately strips the cached backup passwordbkpwfrom generated backups, butrestore_from_dict_ll()has no matchingfilter and re-imports any
setting.bkpwline from a backup file. A crafted ortampered backup with
setting.bkpw = "<known words>"thus plants an attacker-known backup password on restore.
bkpwis aMASTER_FIELD, so it persists,and
make_complete_backupthen offers it as the default next-backup password(quiz skipped, only a first/last-word hint shown). Result: all FUTURE backups
are silently encrypted with a password the attacker knows. Password fixation;
bypasses an existing precaution.
Affected
AFAIU all versions are affected, at least
Impact
Tampering a backup only needs its decryption password, which already exposes
the master secret inside - so the master seed is not what this bug leaks. But now days cold card state is more than just master seed.
The fixated, attacker-known password is reused for all FUTURE backups, leaking
secrets added AFTER restore that the attacker did not know at craft time like
Fix
Mirror the write-side strip in
restore_from_dict_ll, beside sd2fa/ccc:Legitimate backups never contain
bkpw, so this only drops injected values.Tests already assert
bkpwabsent after restore (test_backup.py:377,456), sono breakage.
Reproduction (simulator)
setting.bkpw = [12 known words]before# EOFin a decrypted backup../simulator.py --q1 -l, Import Existing -> Restore Backupsettings.get('bkpw')returns the injected value; a new Backupdefaults to those words. With the fix:
bkpwabsent, fresh random password.