Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add downgrade protection #285

Closed
wants to merge 5 commits into from
Closed

Add downgrade protection #285

wants to merge 5 commits into from

Conversation

mrnerdhair
Copy link
Collaborator

This adds a form of downgrade protection which prevents as-yet-undiscovered vulnerabilities in older firmware versions from being used to compromise the keys of a user who has upgraded, but whose device is subsequently stolen by an attacker who downgrades it to a vulnerable version.

Storage format 17 is introduced, which is identical to format 16 except that the three bytes at offsets 1, 2, and 3 are used to store the major, minor, and patch version numbers of the firmware version which wrote the structure. Moving to a newer firmware version will cause these version numbers to be updated; moving to an older version will cause the storage to be reset and the user's private keys to be wiped -- the same thing that would happen if an unsigned firmware image were loaded.

A warning is displayed before resetting the storage, which provides a user the opportunity to unplug the device and update it to avoid the wipe. However, if the user chooses to downgrade to a version released before this warning message was added, their keys will be wiped without any warning beyond the bootloader's usual admonishment that your keys might be erased after an upgrade and that you should verify that your recovery sentence is available.

This approach increases security while maintaining a user's sovereignty over what firmware runs on their device.

@mrnerdhair mrnerdhair marked this pull request as draft July 13, 2021 22:12
Copy link
Contributor

@markrypto markrypto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the correct approach:

When adding params to the storage section, add them to the reserve and decrease the reserve accordingly. Use the storage_write/readv11 to read/write.

docs/Storage.md Outdated Show resolved Hide resolved
@@ -558,7 +561,7 @@ TEST(Storage, StorageRoundTrip) {
0x73, 0x74, 0x6f, 0x72, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab,
0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab,
0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab,
0xab, 0xab, 0xab, 0xab, 0xab, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
0xab, 0xab, 0xab, 0xab, 0xab, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00,
Copy link
Collaborator Author

@mrnerdhair mrnerdhair Aug 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

version

@@ -683,7 +686,7 @@ TEST(Storage, StorageRoundTrip) {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0xe4, 0x8d, 0xfe,
0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0xe4, 0x8d, 0xfe,
Copy link
Collaborator Author

@mrnerdhair mrnerdhair Aug 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

encrypted_secrets_version

@mrnerdhair
Copy link
Collaborator Author

(just for posterity, in case it's not clear from the history above, @markrypto's feedback about storage format has been addressed.)

lib/firmware/storage.c Outdated Show resolved Hide resolved
lib/firmware/storage.c Outdated Show resolved Hide resolved
lib/firmware/storage.c Outdated Show resolved Hide resolved
@mrnerdhair mrnerdhair force-pushed the downgrade-protection branch 2 times, most recently from 019d5c4 to ae82249 Compare August 11, 2021 19:42
@mrnerdhair
Copy link
Collaborator Author

Are we OK to move forward with this now that the language is approved?

@mrnerdhair mrnerdhair requested review from BitHighlander and removed request for markrypto January 17, 2022 19:48
@markrypt0
Copy link
Collaborator

Closed, not selected.

@markrypt0 markrypt0 closed this May 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants