
Trezor is a hardware wallet for crypto users who want to keep the private keys to their funds away from their everyday phone or laptop, where malware can more easily reach them. Before new firmware runs on it, the bootloader first checks the update.
Recently, I found a firmware update vulnerability in the unreleased Trezor Model T bootloader code.
The bootloader checked official firmware A, but after a failed block retry it could write different firmware B without checking B's headers again.
I reported it to Trezor on September 29, 2026. Their team reproduced it, fixed it before release, and awarded me $1,000.
How the story started
The story started when I was reviewing recent commits in the Trezor firmware repository.
I was checking changes around the bootloader because firmware update code has many security decisions in one flow: signature verification, version checks, user confirmation, storage wipe policy, block hashes, and the final flash write.
One commit caught my attention. It changed the first-block retry so the bootloader could request the complete block again from offset zero.
That looked like a normal bug fix.
But I wanted to know one thing:
When block zero is downloaded again, are its firmware headers also checked again?
After following the state between wf_image_upload.c and wf_firmware_update.c, I found something interesting.
The answer was no.
How the normal update works
A Trezor firmware image starts with a vendor header and an image header.
The bootloader first downloads a small part of block zero and checks these headers. From them it learns:
- who signed the firmware;
- which device model it is for;
- the firmware version;
- where the executable code starts;
- the expected hashes for the code blocks;
- whether changing the vendor requires storage to be wiped.
Then the user confirms the update and the bootloader downloads the remaining blocks.
The expected flow is simple:
Check firmware headers
↓
Confirm that firmware
↓
Verify its code blocks
↓
Write the same firmware
What I noticed
When the first 16 KiB arrived, the bootloader called on_headers() and set:
headers_parsed = true;
The firmware identity, hash boundary, and storage decision were now cached from firmware A.
If the completed first block later failed its hash, the upload buffer was cleared and the bootloader requested the complete block again from offset zero.
But headers_parsed stayed true.
So when the new block arrived, the header-checking function was skipped.
First request: validate headers from A
Hash failure: clear the block buffer
Retry: receive new bytes from offset zero
Security state: still trusted from A
Flash write: write the complete replacement block
The bytes were new, but the security decision belonged to the old bytes.
And this was the bug.
Firmware A and firmware B
Now I needed to check whether firmware B could still pass the block hashes cached from A.
The official firmware I used as A had this layout:
Vendor header 4,608 bytes
Image header 1,024 bytes
Code starts at 5,632 bytes
The repository also contained a valid unsafe/developer vendor header with a shorter length:
Vendor header 2,560 bytes
Image header 1,024 bytes
Code starts at 3,584 bytes
The difference was 2,048 bytes.
The cached block-zero hash from A started at byte 5,632. But executable code in B started at byte 3,584.
That created a 2,048-byte executable area in B before A's hash boundary.
So I built B like this:
shorter unsafe vendor header
+
B image header
+
2,048-byte executable prefix
+
A's original bytes from offset 5,632 onward
B was still a valid unsafe/developer firmware image. Its own vendor signature, firmware signature, and content hashes passed.
At the same time, it also passed the hashes cached from A because both images were identical from byte 5,632 onward.
Proof of concept
I tested the complete sequence against the unmodified Trezor Model T bootloader emulator using the normal firmware upload protocol.
The sequence was:
- Start an update for official firmware A.
- Send A's first 16 KiB so its headers are accepted.
- Send the rest of A's first block with one corrupted byte.
- The hash fails and the bootloader requests block zero again from offset zero.
- Send the complete first block from firmware B.
- B's headers are skipped because
headers_parsedis already true. - Send the remaining B blocks.
The important part of the protocol trace was:
FirmwareRequest offset=0 length=16384
send A headers
FirmwareRequest offset=16384 length=114688
send A corrupted tail
FirmwareRequest offset=0 length=131072
send B full block zero
... remaining B blocks accepted ...
final response: Success
emulator log: normal reboot
The bootloader validated A, accepted every block from B, returned Success, and rebooted.
For a simple execution marker, I made B's reset vector point inside the 2,048-byte prefix. This confirmed that the replacement image controlled the next-stage entry point while still passing the update flow.
Impact
A malicious update host could make the device accept the identity of official firmware A and then replace it with a different, bootloader-valid unsafe firmware B during the retry.
The storage decision was also calculated from A. A normal official-to-unsafe vendor change would take the wipe path, but the retry kept A's same-vendor decision and skipped that vendor-change wipe.
My proof demonstrated the firmware identity swap, the skipped wipe decision, control of the reset vector, and 2,048 executable bytes in the emulator. I did not demonstrate seed extraction or fund loss on a physical device, and the unsafe-firmware warning still appeared before B could run.
The affected bootloader code was only on main. It had not shipped to users.
How Trezor fixed it
Trezor fixed the issue by binding every block-zero retry to the headers accepted in the first request.
The bootloader now stores a digest of the accepted header prefix. When block zero arrives again, it calculates the digest again and compares both values before writing anything.
Accepted headers A
↓
Save digest(A headers)
↓
Block-zero retry arrives
↓
Compare digest(retry headers)
↓
Different headers = abort update
The public fix is available in commit a71f3c3.
Timeline
29 September 2026 Vulnerability reported
30 September 2026 Report acknowledged
05 October 2026 Fix authored
14 October 2026 Fix committed
28 October 2026 Vulnerability confirmed and reward offered
October 2026 Public advisory published
Trezor's public advisory is available here:
Trezor T Bootloader firmware update retry could skip header checks
The lesson from this finding is simple:
A security check is useful only when its result stays bound to the exact bytes that are later used.
Thanks for reading :)