-
-
Notifications
You must be signed in to change notification settings - Fork 274
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
Bootloader downgrade protection #238
Bootloader downgrade protection #238
Conversation
This is a great idea, thanks for tackling it! FYI, @hughsie supplied integration with I haven't looked at the code yet, but please make sure this is implemented in such a way that the same firmware updates work for "old" and "new" bootloader, we don't want to deal with more than one firmware for all of Solo/Tap/Somu. About the flash layout will need to sync also with https://github.com/solokeys/openpgp so it doesn't clash. |
You are welcome!
This is aimed rather to be additional layer for the case, where adversary tries to update device using a custom updater.
Will check - perhaps the bootloader data page will have to be moved before the user data space starts, which is not hard by itself, but perhaps it will block some user space extension options in the future. Have not seen the OpenPGP project yet. |
It builds, but I am not sure what to do with the reported Codacy warning. This behavior is intended. Are there any force/ignore flags for the checker? Edit: about the
|
Logic modifications are finished, some cleanup might be applied (surely Git commits; also remove excess debug messages or comments). Will test tomorrow. I encourage to review and/or test. To decide, should version flag be moved to some other place. Currently it starts 8 bytes before the |
We haven't configured Codacy so far, just running with defaults. Very open to suggestions for improvement. Do you have an account at Codacy? I tried to add you (so you could poke around) with your Nitrokey and private Gmail, it stated "email is invalid". |
It seems it passed the tests second time without changes (tests' results not reproducible within a compilation unit?), so no need anymore for now (but thank you!). I do not have account there yet, but I plan to familiarize with it later - looks interesting. |
This is great! Changing the start page of the application won't work with previous devices. Since old bootloaders will jump to the old start location, and will be off by 1 page. I think it'd be better to put the bootloader data page at the end of the flash region by the application data. |
OK! Indeed this would be easier, will do. Edit: clarification |
9a8332d
to
02517b1
Compare
…nstead of memory storage.
…dress. Move bootloader config 8B forward.
7545101
to
3ce7682
Compare
3ce7682
to
a053bbc
Compare
Improved solution by:
Bootloader now checks version of the application by reading last written 4 bytes. App version does not use static address now. New solution is transparent for the old bootloaders. Version check is done now only in the verifying bootloader. The Please review. Edit: additionally a memory layout struct is added, to use it instead of the macro definitions. |
Awesome! I like the use of version being the last data written / It all looks good to me and building & programming the application works fine on old bootloader. I currently don't have spare devices to convert to secure to fully test -- @nickray do you have some? |
To correctly calculate the hash of the application image. page -19 contains variable bootloader data now. Related: solokeys/solo1#238
Correct application image size for hash and signature calculation. Related: solokeys/solo1#238 Nitrokey/nitrokey-fido2-firmware#3
To correctly calculate the hash of the application image. page -19 contains variable bootloader data now. Related: solokeys/solo1#238
Here are the required changes in the solo-python to make a valid signature for the new bootloader: solokeys/solo1-cli#36 |
@all-contributors please add @Nitrokey for code, tests, ideas |
I've put up a pull request to add @Nitrokey! 🎉 |
This PR adds downgrade protection for the bootloader. Work in progress. Comments welcomed.
Basic idea is to add another page after bootloader for its own data, which would consist entirely at the moment of the last used application firmware version.
The application firmware will contain the version in a known place, which bootloader will compare against before validating of the uploaded application, and will allow or deny, depending on, whenever the firmware is newer or equal the version of the last used firmware.