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

refactor(core/sec): make the boot header portable and lift it out of stm32

Public commit record

What the developer wrote

Authored by tychovrahe

100/100 · Strong
refactor(core/sec): make the boot header portable and lift it out of stm32

`boot_header.c` is parsing, hashing and signature verification over a
caller-supplied buffer. No flash, no MPU, nothing per-MCU -- yet it sat under
`image/stm32/`, so it was compiled only for the device and any host build of
code that touches a boot header failed to link on the whole layer. That blocks
two things: a bootloader emulator (it IS the boot chain, so it cannot emulate
anything without this) and host-side test harnesses over the same structures.

Only three lines were actually non-portable, all casting a `uint32_t` flash
address to a pointer. So the API takes pointers:

boot_header_auth_get(uint32_t address) -> (const void* header)
boot_header_calc_merkle_root(hdr, uint32_t, root) -> (hdr, const void*, root)
bootloader_area_needs_update(hdr, uint32_t) -> (hdr, const void*)

The callers are unaffected in substance: each already had the address of
something it was about to read, and on the device a pointer into flash IS that
address. `boot_ucb_read` still hands out `uint32_t` fields, because the UCB is a
flash structure the boardloader parses -- an address there is data, not a
pointer, and it stays that way.

`boot_ucb.c` and `boot_image.c` stay under stm32/: they touch flash.

Also in `boot_header_auth_get`, one early return was `return secfalse` in a
function returning a pointer. `secfalse` is 0x00000000U so this was correct by
accident; it now returns NULL. No behaviour change.

Pure refactor -- no functional change on any device. Built T3W1
boardloader/bootloader/firmware/prodtest, T3T1 boardloader and bootloader
--production (spare unchanged), T2T1 to cover an MCU without the scheme, and the
T3W1 firmware / T3T1 bootloader emulators.

[no changelog]

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Uses a recognizable type or scope✓ Provides detailed explanatory context✓ Explains rationale or failure mode✓ Mentions testing or verification✓ Names security-relevant behavior explicitly
The short version

What changed, and why it matters

This commit is a code cleanup that moves a small piece of boot-header parsing code out of an STM32-specific folder so it can also be used in emulator and test builds. It changes function arguments from raw flash addresses (uint32_t numbers) to generic pointers, and fixes one accidental use of a security-boolean value where a null pointer was intended. The commit message and diff show no intended behavior change on real devices.

Recommended action

No security action required. Treat as ordinary refactoring review; verify the new size check and pointer API compile cleanly across supported targets and emulators.

Security signals we found

01

Refactor only: commit message explicitly states 'Pure refactor -- no functional change on any device'

02

Pointer API change removes uint32_t-to-pointer casts, which is a defensive portability improvement

03

Added code_size upper-bound validation against NONBOARDLOADER_MAXSIZE - hdr->header_size

04

Fixed semantically incorrect return secfalse in pointer-returning function to return NULL

05

No changelog entry, consistent with non-security cleanup

Risk score

Why this scored 13/100

Our methodology →
Potential impact 0/30
Exploitability 0/25
Stealth signal 0/15
Affected reach 0/15
Confidence 9/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.