AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Low 34 Bitcoin

fix(core): assert the monotonic versions fit what monoctr can store

Public commit record

What the developer wrote

Authored by tychovrahe

85/100 · Strong
fix(core): assert the monotonic versions fit what monoctr can store

monoctr stores its counters UNARY -- value N is N written 16-byte blocks -- so
the encoding, not the uint8_t the value travels in, is what caps them at
MONOCTR_MAX_VALUE (63). A model that raises a monotonic version past that gets no
build error; it fails later, at runtime, and confusingly:

* the boardloader compares the boot header against the stored floor, cannot
write the new value, and reports "BOOTLOADER DOWNGRADED" on a perfectly good
image;
* the firmware and secmon floors silently stop advancing, so anti-rollback
quietly weakens instead of failing.

Assert all three at build time instead. Every model is well inside the limit
today (highest is 3), so this only fixes the failure mode of a future bump.

version_check.c is the only place all three can be checked. The firmware and
secmon values reach their images through header.S, where _Static_assert cannot
go, and model_version.h is itself pulled into that assembly via version.h, so
the checks cannot live there either. This translation unit both sees all three
constants and owns the monoctr policy they feed.

SECMON_MONOTONIC_VERSION is guarded: only models with a secmon define it (4 of 9
today).

Verified by temporarily setting a model to 64 and confirming the build stops, and
by building models with and without a secmon so both sides of the #ifdef compile.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

[no changelog]
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Uses a recognizable type or scope✓ Provides detailed explanatory context
The short version

What changed, and why it matters

This commit adds build-time safety checks to prevent future Trezor firmware versions from accidentally setting anti-rollback version numbers too high for the hardware storage to handle. If a version were set above the storage limit, the device could either wrongly refuse to boot a valid update, or silently stop enforcing downgrade protection. The fix prevents that mistake at compile time, before any device is shipped. It does not fix an active bug today because all current models are well below the limit.

Recommended action

No urgent action needed; this is a defensive hardening change. Ensure future model version bumps are still validated by these assertions during CI builds, and consider documenting MONOCTR_MAX_VALUE in model version definitions so developers remain aware of the limit.

Security signals we found

01

anti-rollback/downgrade protection

02

build-time static assertion

03

monotonic counter storage limit

04

silent failure mode prevention

05

bootloader version verification

Risk score

Why this scored 34/100

Our methodology →
Potential impact 8/30
Exploitability 3/25
Stealth signal 6/15
Affected reach 5/15
Confidence 8/10
Evidence quality 4/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.