Skip to content

Trezor Safe 7 bootloader 2.1.16

The published firmware image, checked against its published source. reproducible

Verified with cverif 0.1.4; this repository now uses cverif 0.1.5, which may prove more and report fewer false alarms. This result is due to be re-run.

762 / 983
functions proved equal to the source
38.8%
of code bytes proved (81,046 of 208,636)
65.8%
of source statements and branches proved
59
mismatches reported: 51 cverif false alarm, 8 unspecified in C
762 proved126 bounded8 differs where C leaves it open52 mismatch, cverif false alarm7 inconclusive28 unsupported

Constant time

4 functions are marked constant time by the specs trezor-crypto, secp256k1-zkp, trezor-storage; cverif checks that the published machine code's timing doesn't depend on their secrets, nor that of the helpers they pass secrets to (how). 61 spec entries are not in this image.

1 proved2 bounded1 mismatch, cverif false alarm
FunctionClaimDetail
memzero
marked
violationargument 1 of the call to explicit_bzero points to secret memory, and explicit_bzero is not known to be constant time (vendor/trezor-crypto/memzero.c:55)
any input
ECRYPT_keysetup
marked
provedconstant time
sha256_Transform
marked
boundedconstant time on the explored paths only
sha512_Transform
marked
boundedconstant time on the explored paths only

Chain of evidence

  1. Published image
    bootloader-t3w1-2.1.16.bin, sha256 c37138c667ad29e45b8ea7f51f09456405e6d29facb57030db77ea4d13ce325f
  2. Source
    trezor/trezor-firmware, tag core/bl2.1.16, commit 764df17ae782…
  3. Reproducible build
    the vendor's own build reproduces the published image byte for byte, signatures aside
  4. Source bundle
    207 C/assembly units linked into the image; 15 linked inputs have no C source (Rust, toolchain libraries); toolchain: arm-none-eabi-gcc (Arm GNU Toolchain 13.3.Rel1 (Build arm-13.24)) 13.3.1 20240614
  5. Extraction
    code at 0xc022000, 245,760 bytes; every published byte is accounted for
  6. Verification
    cverif 0.1.4 on the published bytes: 762 of 983 functions proved, 1 flag group(s)

Findings

infoThe published bootloader reproduces
build-docker.sh --models T3W1 --targets bootloader core/bl2.1.16 (commit 764df17a) gives the published image bootloader-t3w1-2.1.16.bin once the signature fields (sigmask, the signatures and, for TRZQ, the Merkle proof) are zeroed; the instrumented rebuild (compiler calls logged) is byte-identical to it.
reproducibility · confidence high · reproducible
infoRust UI and memory functions out of scope
The bootloader UI is Rust, out of cverif's scope (see the README's composition table), and so are memcpy, memset, memmove, strlen and the __aeabi_mem* helpers: weak C-ABI wrappers that tail-jump to Rust's compiler_builtins.
scope · confidence high · rust-share
infoRead as secure code (-mcmse)
Every unit is built with -mcmse, for which GCC predefines __ARM_FEATURE_CMSE as 3; the STM32U5 headers select the secure peripheral aliases and the secure-only code on it. verify.py passes -D__ARM_FEATURE_CMSE=3.
coverage · confidence high · cmse
infoThe one initialised-data difference is the signing tool's sigmask
g_bootloader_header (sec/image/boot_header.c) differs at offset 25, sigmask: the source sets 0 ("properly initialized later by headertool_pq"), the published, signed image has 0x03 (keys 1 and 2).
integrity · confidence high · sigmask
infocverif false alarmmemzero calls explicit_bzero on secret memory
memzero is explicit_bzero(pnt, len). newlib's explicit_bzero falls through into bzero, which tail-calls memset (the compiler_builtins one): its branches depend on the pointer's alignment and the length, never on the bytes it overwrites. cverif has no constant-time knowledge of the library function.
ct-triage · confidence high · ct-memzero
infoNo constant-time violation in the bootloader
The bootloader holds no signing key or PIN. The one violation reported, memzero passing secret memory to explicit_bzero, is a library call whose timing depends on alignment and length only (above).
coverage · confidence high · constant-time
infocverif false alarmCounterexample points an argument at __stack_chk_guard
In each counterexample a pointer argument points into __stack_chk_guard; the source's store through it overwrites the canary, the binary's epilogue check fails and __stack_chk_fail runs (error_shutdown, then systask_exit_fatal). No caller can pass the address of the guard, an object the compiler introduces (issue 23); every such path's binary condition compares __stack_chk_guard (checked in cverif's explanation of each).
mismatch-triage · confidence high · covers 24 mismatches · cverif issue 23 · canary-alias
infocverif false alarmHAL callbacks and handlers compared with their __weak defaults
The STM32 HAL defines these callbacks __weak and empty (and vectortable.S declares the interrupt handlers as weak aliases of default_handler); the firmware's drivers (usbd_conf.c, and on T3W1 nrf_spi.c, display_fb.c, display_driver.c) define them for real. The link map keeps the drivers' definitions and discards the HAL's (0x0 0x2 ...hal_*.o); cverif compares the binary with the weak definition (issue 24).
mismatch-triage · confidence high · covers 15 mismatches · cverif issue 24 · weak-callbacks
infocverif false alarmboot_command_t is a 64-bit enumeration
BOOT_COMMAND_POWER_OFF = 0x24EEE8828 makes boot_command_t 64-bit: g_boot_command is 8 bytes, commands are passed and returned in r0:r1. cverif reads the type as 32-bit (issue 25): the upper word of a stored command (2 for POWER_OFF in reboot_to_off, 0 otherwise) is missing in the source, and the binary's test of the returned upper word (r1 != 0 after bootargs_get_command in main, fw_on_headers) is one the source lacks. reboot_with_rsod's counterexample also puts pminfo (196 bytes at 0x2fffff44) right below g_boot_command, overlapping nothing the source distinguishes but the upper word.
mismatch-triage · confidence high · covers 4 mismatches · cverif issue 25 · boot-command-64bit
infounspecified in CFloating-point a*b+c computed with one rounding (vfma)
The battery model (io/power_manager/battery/battery_model.c) is built with -std=gnu11, where GCC contracts a * b + c into a fused multiply-add (-ffp-contract=fast; vfma.f32/vfms.f32/vfnms.f32 in calc_ocv, calc_soc_from_ocv, calc_ocv_slope, battery_rint, battery_meas_to_ocv), rounding once where the source's two operations round twice; C allows contraction (C11 6.5p8, FP_CONTRACT). The results differ in the last bit; battery_ocv and battery_ocv_slope differ through calc_ocv. cverif evaluates without contraction (issue 31).
mismatch-triage · confidence high · covers 7 mismatches · cverif issue 31 · fp-contract
infocverif false alarmble_write: a 6-byte memcpy done as a call
memcpy(&tx_buf[1], drv->connected_addr.addr, 6) is a call in the binary (bl memcpy at 0xc03a7b0, then the data copy at 0xc03a7c2), in the source's order; cverif expects GCC to expand the 6-byte copy inline, so its call numbering is off by one and it compares the data copy's arguments with the address copy's (issue 29).
mismatch-triage · confidence high · covers 1 mismatch · cverif issue 29 · ble-write-memcpy
infocverif false alarmmemcpy/memset/__aeabi_mem*: counterexample overlaps the callee's own frame
These are Rust compiler_builtins thunks with no C source, compared with cverif's library model. The counterexample puts the destination at 0xffffffff so that the thunk's push {r7, lr} writes the same byte: an object overlapping the callee's new stack frame, which no C caller can produce.
mismatch-triage · confidence medium · covers 7 mismatches · aeabi-mem
infounspecified in Cfb_queue_take: counterexample has rix == FRAME_BUFFER_COUNT
The counterexample's queue has rix == 2 with FRAME_BUFFER_COUNT == 2, so queue->entries[queue->rix] is past the array and lands on rix itself (r0 + 4): undefined behaviour. rix is only ever set by (rix + 1) % FRAME_BUFFER_COUNT or reset to 0.
mismatch-triage · confidence high · covers 1 mismatch · fb-queue-index

What the image is made of

Bytes by origin, from the link map. cverif verifies C and assembly; the rest counts as unverified.

OriginBytesShare
C147,97356.4%
Rust94,05335.9%
linker fill19,2437.3%
assembly6240.2%
toolchain libraries (newlib, libgcc)2500.1%

Functions

Every function of the image cverif compared with its source. Bounded: no difference within the explored paths, not a proof. Unsupported/inconclusive: a construct cverif doesn't model yet.

FunctionStatusBytesDetail
decode_basic_field
0xc02a610
mismatch900binary executes `mrs ipsr`, which the source does not do at this point
curve25519_contract
0xc024ba8
mismatch668binary executes `mrs ipsr`, which the source does not do at this point
expand256_modm
0xc02622c
mismatch484binary executes `mrs ipsr`, which the source does not do at this point
rtc_get_timestamp
0xc0391ac
mismatch408binary executes `mrs ipsr`, which the source does not do at this point
HAL_TIM_OnePulse_ConfigChannel
0xc030b94
mismatch308binary executes `mrs ipsr`, which the source does not do at this point
HAL_PCD_MspInit
0xc034c58
mismatch272binary reads 4 byte(s) of the peripheral register at 0x56020c8c (instruction at 0xc034c74) where the source makes no such access
battery_ocv
0xc03edb8
mismatch232return value: source gives 0x3f800002, binary gives 0x3f800004 for r0=0x58 s0=0x3f000001 s1=0xe6d82ef0 mem[0x44]=0x01 mem[0x45]=0x00 mem[0x46]=0x00 mem[0x47]=0x00 mem[0x48]=0x00 mem[0x49]=0x00 mem[0x4a]=0x80 mem[0x4b]=0x00
battery_ocv_slope
0xc03eea0
mismatch232return value: source gives 0x196e75c, binary gives 0x196e75d for r0=0x808280d8 s0=0xc06ad800 s1=0xe07bf859 mem[0x300c0028]=0xbe mem[0x300c0029]=0xac mem[0x300c002a]=0x85 mem[0x300c002b]=0x00 mem[0x300c0798]=0x85 mem[0x300c0799]=0x0e mem[0x300c079a]=0x89 mem[0x300c079b]=0x06
battery_model_init
0xc03f060
mismatch224binary executes `mrs ipsr`, which the source does not do at this point
ed25519_cosi_combine_publickeys
0xc025298
mismatch200binary executes `mrs ipsr`, which the source does not do at this point
HAL_DMAEx_List_Start_IT
0xc02c5e4
mismatch196binary executes `mrs ipsr`, which the source does not do at this point
pb_encode_submessage
0xc02b2d4
mismatch192binary executes `mrs ipsr`, which the source does not do at this point
pb_skip_field
0xc02a3e4
mismatch172binary executes `mrs ipsr`, which the source does not do at this point
ble_write
0xc03a760
mismatch160argument 2 of call #3 to memcpy: source gives 0xc800000e, binary gives 0x300c3490 for r0=0xc800000e ret3:nrf_send_msg=0x0 ret4:tsqueue_enqueue=0x0 mem[0x300c0028]=0x9c mem[0x300c0029]=0x7f mem[0x300c002a]=0xf5 mem[0x300c002b]=0x59 mem[0x300c0798]=0xf7 mem[0x300c0799]=0xff mem[0x300c079a]=0xff mem[0x300c079b]=0x7f
pb_read
0xc02a270
mismatch152binary executes `mrs ipsr`, which the source does not do at this point
pb_decode_varint
0xc02a310
mismatch140binary executes `mrs ipsr`, which the source does not do at this point
HAL_LTDC_LineEventCallback
0xc037050
mismatch136binary executes `mrs primask`, which the source does not do at this point
recv_msg_firmware_upload
0xc0298ac
mismatch128binary executes `mrs ipsr`, which the source does not do at this point
calc_soc_from_ocv
0xc03ec1e
mismatch108return value: source gives 0xc7896ee1, binary gives 0xc7896ee0 for r0=0x4 r1=0x10 s0=0xc346c000 mem[0x8]=0x8b mem[0x9]=0x84 mem[0xa]=0x8b mem[0xb]=0x8a mem[0xc]=0x04 mem[0xd]=0x85 mem[0xe]=0x84 mem[0xf]=0x82
recv_msg_ping
0xc0297b4
mismatch100binary executes `mrs ipsr`, which the source does not do at this point
pb_make_string_substream
0xc02a490
mismatch96binary executes `mrs ipsr`, which the source does not do at this point
calc_ocv
0xc03ebc0
mismatch94return value: source gives 0xa12f1a97, binary gives 0xa12f1a98 for r0=0x38 r1=0x4 s0=0xa9400d84 mem[0xc]=0x80 mem[0xd]=0x01 mem[0xe]=0x40 mem[0xf]=0x80 mem[0x10]=0x00 mem[0x11]=0x00 mem[0x12]=0x10 mem[0x13]=0x42
calc_ocv_slope
0xc03ec8a
mismatch94return value: source gives 0xd85c35bd, binary gives 0xd85c35bf for r0=0x4 r1=0x4 s0=0x81400000 mem[0x8]=0x00 mem[0x9]=0x00 mem[0xa]=0x00 mem[0xb]=0x00 mem[0xc]=0x0d mem[0xd]=0x07 mem[0xe]=0xd1 mem[0xf]=0x00
recv_msg_firmware_erase
0xc029818
mismatch88binary executes `mrs ipsr`, which the source does not do at this point
recv_msg_initialize
0xc0296b8
mismatch84binary executes `mrs ipsr`, which the source does not do at this point
recv_msg_get_features
0xc02970c
mismatch84binary executes `mrs ipsr`, which the source does not do at this point
recv_msg_wipe_device
0xc029760
mismatch84binary executes `mrs ipsr`, which the source does not do at this point
bootargs_set
0xc032b40
mismatch84memory at return: 4-byte value stored at 0x30000004: source gives 0x0, binary gives 0x80000006 for r1=0x80000006 mem[0x300c0028]=0x9c mem[0x300c0029]=0x7f mem[0x300c002a]=0xf5 mem[0x300c002b]=0x59 mem[0x300c0798]=0xf7 mem[0x300c0799]=0xff mem[0x300c079a]=0xff mem[0x300c079b]=0x7f
pb_decode_svarint
0xc02a550
mismatch76binary executes `mrs ipsr`, which the source does not do at this point
pb_decode_tag
0xc02a39c
mismatch72binary executes `mrs ipsr`, which the source does not do at this point
HAL_SPI_ErrorCallback
0xc03b948
mismatch64binary executes `mrs primask`, which the source does not do at this point
pb_decode_bool
0xc02a514
mismatch60binary executes `mrs ipsr`, which the source does not do at this point
pb_decode_fixed64
0xc02a5d4
mismatch60binary executes `mrs ipsr`, which the source does not do at this point
pb_decode_fixed32
0xc02a59c
mismatch56binary executes `mrs ipsr`, which the source does not do at this point
fb_queue_take
0xc037220
mismatch48memory at `msr primask` (event #3): 2-byte value stored at (r0 + 2*zext32(mem2.8[(r0 + 4)])): source gives 0xff00, binary gives 0xff01 for r0=0x1063fa mem[0x1063fe]=0x02 mem[0x1063ff]=0x7f mem[0x300c0028]=0x9f mem[0x300c0029]=0x7f mem[0x300c002a]=0x1f mem[0x300c002b]=0x84 mem[0x300c0798]=0x00 mem[0x300c0799]=0x00
HAL_PCD_MspDeInit
0xc034d68
mismatch44binary reads 4 byte(s) of the peripheral register at 0x56020c8c (instruction at 0xc034d72) where the source makes no such access
battery_rint
0xc03ece8
mismatch36return value: source gives 0x80583199, binary gives 0x805addc4 for r0=0x8080809c s0=0x41f40000 mem[0x300c0028]=0x80 mem[0x300c0029]=0x80 mem[0x300c002a]=0x80 mem[0x300c002b]=0x82 mem[0x300c0798]=0x80 mem[0x300c0799]=0x80 mem[0x300c079a]=0x80 mem[0x300c079b]=0x00
battery_meas_to_ocv
0xc03ed94
mismatch36return value: source gives 0x8d106a6c, binary gives 0x8d106a6d for r0=0x800028 s0=0x80800001 s1=0x9e51c170 s2=0x1 mem[0x800004]=0x01 mem[0x800005]=0x00 mem[0x800006]=0x80 mem[0x800007]=0x80 mem[0x800008]=0xf7 mem[0x800009]=0x19 mem[0x80000a]=0xd9 mem[0x80000b]=0xb4
bootargs_init
0xc032bdc
mismatch32memory at return: 4-byte value stored at 0x300c0824: source gives 0x7fffffff, binary gives 0x80000000 for mem[0x30000004]=0x00 mem[0x30000005]=0x00 mem[0x30000006]=0x00 mem[0x30000007]=0x80 mem[0x300c0028]=0xff mem[0x300c0029]=0x7f mem[0x300c002a]=0xaa mem[0x300c002b]=0xaa
HAL_PCD_ResetCallback
0xc034dca
mismatch32binary calls USBD_LL_OpenEP, which the source does not call at this point
reboot_to_off
0xc032c18
mismatch24memory at call #1 to call_with_new_stack: 4-byte value stored at 0x30000004: source gives 0x0, binary gives 0x2 for mem[0x300c0028]=0xff mem[0x300c0029]=0xff mem[0x300c002a]=0xff mem[0x300c002b]=0x7f mem[0x300c0798]=0xff mem[0x300c0799]=0xff mem[0x300c079a]=0xff mem[0x300c079b]=0x7f
reboot_with_rsod
0xc032c30
mismatch24memory at call #1 to call_with_new_stack: 4-byte value stored at 0x300000c8: source gives 0x4000000, binary gives 0x0 for r0=0x2fffff44 mem[0x30000004]=0x00 mem[0x30000005]=0x00 mem[0x30000006]=0x00 mem[0x30000007]=0x04 mem[0x300c0028]=0x5c mem[0x300c0029]=0xbe mem[0x300c002a]=0x79 mem[0x300c002b]=0x59
HAL_PCD_DataOutStageCallback
0xc034da0
mismatch18binary calls <indirect call>, which the source does not call at this point
HAL_PCD_DataInStageCallback
0xc034db2
mismatch16binary calls <indirect call>, which the source does not call at this point
HAL_PCD_SetupStageCallback
0xc034d94
mismatch12binary calls USBD_LL_StallEP, which the source does not call at this point
memcpy
0xc049f76
mismatch12memory at return: 1-byte value stored at r0: source gives 0x8, binary gives 0x0 for r0=0xffffffff r1=0x86281008 r2=0x1 mem[0x86281008]=0x08 mem[0xffffffff]=0x00
memmove
0xc04a214
mismatch12memory at return: 1-byte value stored at r0: source gives 0x80, binary gives 0x7f for r0=0xffffffff r1=0x100000 r2=0x1 mem[0x100000]=0x80 mem[0xffffffff]=0x7f
memset
0xc04a27a
mismatch12memory at return: 1-byte value stored at r0: source gives 0x8, binary gives 0x0 for r0=0xffffffff r1=0x8 r2=0x1 mem[0xffffffff]=0x00
__aeabi_memcpy
0xc04a2cc
mismatch12memory at return: 1-byte value stored at r0: source gives 0x1, binary gives 0x0 for r0=0xffffffff r1=0x6281008 r2=0x1 mem[0x6281008]=0x01 mem[0xffffffff]=0x00
__aeabi_memcpy4
0xc04a2f0
mismatch12memory at return: 1-byte value stored at r0: source gives 0x1, binary gives 0x0 for r0=0xffffffff r1=0x6281008 r2=0x1 mem[0x6281008]=0x01 mem[0xffffffff]=0x00
__aeabi_memclr
0xc04a32e
mismatch12memory at return: 1-byte value stored at r0: source gives 0x0, binary gives 0x1 for r0=0xffffffff r1=0x1 mem[0xffffffff]=0x01
__aeabi_memclr4
0xc04a348
mismatch12memory at return: 1-byte value stored at r0: source gives 0x0, binary gives 0x1 for r0=0xffffffff r1=0x1 mem[0xffffffff]=0x01
HAL_PCD_SOFCallback
0xc034dc2
mismatch8binary calls <indirect call>, which the source does not call at this point
HAL_PCD_SuspendCallback
0xc034dea
mismatch8memory at return: 1-byte value stored at (mem0.32[(r0 + 1288)] + 509): source gives 0x7f, binary gives 0x80 for r0=0x80808ace mem[0x300c0028]=0x80 mem[0x300c0029]=0x82 mem[0x300c002a]=0x80 mem[0x300c002b]=0x88 mem[0x300c0798]=0x80 mem[0x300c0799]=0x80 mem[0x300c079a]=0x80 mem[0x300c079b]=0x80
HAL_PCD_ResumeCallback
0xc034df2
mismatch8memory at return: 1-byte value stored at (mem0.32[(r0 + 1288)] + 508): source gives 0x7f, binary gives 0x80 for r0=0x80000096 mem[0x300c0028]=0x80 mem[0x300c0029]=0x80 mem[0x300c002a]=0xb0 mem[0x300c002b]=0x80 mem[0x300c0798]=0x80 mem[0x300c0799]=0x80 mem[0x300c079a]=0x80 mem[0x300c079b]=0x80
HAL_PCD_DisconnectCallback
0xc034e12
mismatch8binary calls <indirect call>, which the source does not call at this point
LTDC_ER_IRQHandler
0xc036944
mismatch4binary executes `mrs primask`, which the source does not do at this point
HAL_SPI_RxCpltCallback
0xc03b940
mismatch4binary calls nrf_spi_transfer_complete, which the source does not call at this point
HAL_SPI_TxRxCpltCallback
0xc03b944
mismatch4binary calls nrf_spi_transfer_complete, which the source does not call at this point
panel_init
0xc0369f4
proved1294
display_init
0xc036274
proved1260
backlight_init
0xc037564
proved672
nrf_init
0xc03b0f4
proved576
rgb_led_init
0xc03ba54
proved552
SystemInit
0xc032f40
proved544
HAL_GPIO_Init
0xc02d6ac
proved532
HAL_DMAEx_List_Init
0xc02c300
proved496
HAL_DSI_Init
0xc02ca30
proved492
HAL_DSI_ConfigVideoMode
0xc02cc44
proved492
mpu_reconfig
0xc032760
proved468
encode_basic_field
0xc02b394
proved456
rgb_led_linear_gc_effect
0xc03bf28
proved456
secret_prepare_fw
0xc031c70
proved452
ge25519_unpack_negative_vartime
0xc025830
proved416
backlight_set
0xc03781c
proved400
HAL_GTZC_TZSC_ConfigPeriphAttributes
0xc02d9dc
proved392
ge25519_pnielsadd
0xc025654
proved332
nrf_resume
0xc03af30
proved332
tamper_init
0xc031ed8
proved328
workflow_ble_pairing_request
0xc0289d4
proved316
workflow_wireless_setup
0xc028b10
proved308
unit_properties_init
0xc032164
proved308
stwlc38_init
0xc03f358
proved308
ble_init
0xc03a488
proved304
HAL_GTZC_TZSC_MPCWM_ConfigMemAttributes
0xc02db64
proved296
npm1300_fsm_continue
0xc03ccc4
proved292
ge25519_pnielsadd_p1p1
0xc0254ec
proved288
reduce256_modm
0xc025bb0
proved288
TIM_Base_SetConfig
0xc030778
proved276
HAL_GPIO_DeInit
0xc02d8c0
proved260
flash_area_write_data_padded
0xc03fab8
proved256
workflow_menu
0xc0284c8
proved252
LTDC_SetConfig
0xc02e81c
proved252
usb_class_setup
0xc03479c
proved244
mpu_init
0xc032660
proved240
touch_get_state
0xc037c64
proved240
curve25519_sub_after_basic
0xc023f70
proved230
tamper_build_pminfo
0xc032020
proved228
USB_SetTurnaroundTime
0xc035780
proved224
codec_send_msg
0xc028d6c
proved216

Showing 100 of 983.

Raw results

Results are produced by scripts anyone can re-run. MIT licensed.