Skip to content

Add downgrade protection#285

Closed
mrnerdhair wants to merge 5 commits into
masterfrom
downgrade-protection
Closed

Add downgrade protection#285
mrnerdhair wants to merge 5 commits into
masterfrom
downgrade-protection

Conversation

@mrnerdhair
Copy link
Copy Markdown
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 requested a review from markrypto as a code owner July 13, 2021 22:04
@mrnerdhair mrnerdhair force-pushed the downgrade-protection branch from c006bcb to ac8edb9 Compare July 13, 2021 22:09
@mrnerdhair mrnerdhair marked this pull request as draft July 13, 2021 22:12
Copy link
Copy Markdown
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.

@mrnerdhair mrnerdhair force-pushed the downgrade-protection branch from ac8edb9 to ac04043 Compare July 19, 2021 00:44
@mrnerdhair mrnerdhair requested a review from markrypto August 2, 2021 17:17
Comment thread docs/Storage.md Outdated
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
Copy Markdown
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

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
Copy Markdown
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
Copy Markdown
Collaborator Author

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

Comment thread lib/firmware/storage.c Outdated
Comment thread lib/firmware/storage.c Outdated
Comment thread lib/firmware/storage.c Outdated
@mrnerdhair mrnerdhair force-pushed the downgrade-protection branch 2 times, most recently from 019d5c4 to ae82249 Compare August 11, 2021 19:42
@mrnerdhair mrnerdhair force-pushed the downgrade-protection branch from ae82249 to 354cf89 Compare August 11, 2021 19:44
@mrnerdhair mrnerdhair requested a review from markrypto August 11, 2021 19:45
@mrnerdhair mrnerdhair marked this pull request as ready for review August 11, 2021 19:45
@mrnerdhair
Copy link
Copy Markdown
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
Copy Markdown
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.

3 participants