Randomize SCM_REVISION address in firmware #4468
Merged
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.
Implements https://github.com/satoshilabs/trezor-firmware/issues/189.
Replaces https://github.com/satoshilabs/trezor-firmware/pull/190.
Problem
When a firmware update is loaded onto a fake Trezor device, a malicious bootloader may automatically extract the revision ID of the firmware update. The malicious firmware on the device may then use the extracted revision ID to convince Suite that the firmware was successfully updated when in fact the malicious firmware is running on the device all along. This PR makes it difficult to automatically find the firmware revision ID in the firmware binary file by randomizing the address of the
SCM_REVISION
string in the firmware binary. (The address randomization is deterministic so that deterministic builds are preserved.)Solution
SCM_REVISION
as a global symbol in a separate filecore/embed/util/scm_revision/scm_revision.c
, so that it will be placed into a distinct object file separate from all other symbols and constants which could otherwise be used to easily locate it.SConscript.firmware
I shuffle the list of object files deterministically based on the value ofSCM_REVISION
itself. Based on observation of the resulting binary files, this results in the linker shuffling the strings in the firmware binary.