Skip to content

Trezor Model T 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.

445 / 578
functions proved equal to the source
33.4%
of code bytes proved (41,119 of 123,027)
57.2%
of source statements and branches proved
42
mismatches reported: 42 cverif false alarm
445 proved67 bounded43 mismatch, cverif false alarm4 inconclusive19 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-t2t1-2.1.16.bin, sha256 0ffdbe7bb21af230d8577af763fe0b9ab12a65fc1c91a6356e87b9ce46336a90
  2. Header
    the signed header's code hashes match the code
  3. Source
    trezor/trezor-firmware, tag core/bl2.1.16, commit 764df17ae782…
  4. Reproducible build
    the vendor's own build reproduces the published image byte for byte, signatures aside
  5. Source bundle
    144 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
  6. Extraction
    code at 0x8020400, 127,488 bytes; every published byte is accounted for
  7. Verification
    cverif 0.1.4 on the published bytes: 445 of 578 functions proved, 1 flag group(s)

Findings

infoThe published bootloader reproduces
build-docker.sh --models T2T1 --targets bootloader core/bl2.1.16 (commit 764df17a) gives the published image bootloader-t2t1-2.1.16.bin once the signature fields (sigmask, signature) are zeroed; the instrumented rebuild (compiler calls logged) is byte-identical to it. Fingerprint 8dab2b56…4d269a.
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
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 22 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 10 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 1 mismatch · cverif issue 25 · boot-command-64bit
infocverif false alarm__atomic built-ins expanded inline
rdi.c guards the random-delay generator with __atomic_test_and_set; GCC expands it to dmb and exclusive loads/stores, which cverif compares with a call (issue 22; USBD_StdDevReq inlines drbg_random8).
mismatch-triage · confidence high · covers 3 mismatches · cverif issue 22 · atomics
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 6 mismatches · aeabi-mem

What the image is made of

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

OriginBytesShare
C75,95859.1%
Rust50,30439.1%
assembly1,4561.1%
linker fill5430.4%
toolchain libraries (newlib, libgcc)2500.2%

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
0x8028acc
mismatch904binary executes `mrs ipsr`, which the source does not do at this point
curve25519_contract
0x8023e30
mismatch668binary executes `mrs ipsr`, which the source does not do at this point
USBD_StdDevReq
0x802e068
mismatch588binary executes `dmb` where the source is calling __atomic_test_and_set
expand256_modm
0x80254b8
mismatch484binary executes `mrs ipsr`, which the source does not do at this point
encode_field
0x8029a20
mismatch336binary executes `mrs ipsr`, which the source does not do at this point
HAL_PCD_MspInit
0x802d9f4
mismatch276binary reads 4 byte(s) of the peripheral register at 0x40023830 (instruction at 0x802da12) where the source makes no such access
drbg_random8
0x802afc0
mismatch228binary executes `dmb` where the source is calling __atomic_test_and_set
ed25519_cosi_combine_publickeys
0x8024520
mismatch200binary executes `mrs ipsr`, which the source does not do at this point
pb_encode_submessage
0x8029798
mismatch192binary executes `mrs ipsr`, which the source does not do at this point
pb_skip_field
0x80288a0
mismatch172binary executes `mrs ipsr`, which the source does not do at this point
blake2s_init_param
0x8022634
mismatch168binary executes `mrs ipsr`, which the source does not do at this point
pb_read
0x802872c
mismatch152binary executes `mrs ipsr`, which the source does not do at this point
pb_decode_varint
0x80287cc
mismatch140binary executes `mrs ipsr`, which the source does not do at this point
rdi_handler
0x802b0a4
mismatch140binary executes `dmb` where the source is calling __atomic_test_and_set
recv_msg_firmware_upload
0x8027f68
mismatch128binary executes `mrs ipsr`, which the source does not do at this point
recv_msg_ping
0x8027e70
mismatch100binary executes `mrs ipsr`, which the source does not do at this point
pb_make_string_substream
0x802894c
mismatch96binary executes `mrs ipsr`, which the source does not do at this point
recv_msg_firmware_erase
0x8027ed4
mismatch88binary executes `mrs ipsr`, which the source does not do at this point
recv_msg_initialize
0x8027d74
mismatch84binary executes `mrs ipsr`, which the source does not do at this point
recv_msg_get_features
0x8027dc8
mismatch84binary executes `mrs ipsr`, which the source does not do at this point
recv_msg_wipe_device
0x8027e1c
mismatch84binary executes `mrs ipsr`, which the source does not do at this point
pb_decode_svarint
0x8028a0c
mismatch76binary executes `mrs ipsr`, which the source does not do at this point
pb_decode_tag
0x8028858
mismatch72binary executes `mrs ipsr`, which the source does not do at this point
pb_decode_bool
0x80289d0
mismatch60binary executes `mrs ipsr`, which the source does not do at this point
pb_decode_fixed64
0x8028a90
mismatch60binary executes `mrs ipsr`, which the source does not do at this point
pb_decode_fixed32
0x8028a58
mismatch56binary executes `mrs ipsr`, which the source does not do at this point
HAL_PCD_MspDeInit
0x802db08
mismatch56binary reads 4 byte(s) of the peripheral register at 0x40023834 (instruction at 0x802db12) where the source makes no such access
HAL_PCD_ResetCallback
0x802db76
mismatch32binary calls USBD_LL_OpenEP, which the source does not call at this point
HAL_PCD_DataOutStageCallback
0x802db4c
mismatch18binary calls <indirect call>, which the source does not call at this point
bootargs_init
0x802bd74
mismatch16memory at return: 4-byte value stored at 0x10004744: source gives 0x1, binary gives 0x0 for mem[0x1000400c]=0xff mem[0x1000400d]=0xff mem[0x1000400e]=0xff mem[0x1000400f]=0x7f mem[0x100046c4]=0xff mem[0x100046c5]=0xff mem[0x100046c6]=0xff mem[0x100046c7]=0x7f
HAL_PCD_DataInStageCallback
0x802db5e
mismatch16binary calls <indirect call>, which the source does not call at this point
HAL_PCD_SetupStageCallback
0x802db40
mismatch12binary calls USBD_LL_StallEP, which the source does not call at this point
memcpy
0x8038de6
mismatch12memory at return: 1-byte value stored at r0: source gives 0x12, binary gives 0x1 for r0=0xffffffff r1=0x822a1048 r2=0x1 mem[0x822a1048]=0x12 mem[0xffffffff]=0x01
memset
0x80390de
mismatch12memory at return: 1-byte value stored at r0: source gives 0x10, binary gives 0x0 for r0=0xffffffff r1=0x10 r2=0x1 mem[0xffffffff]=0x00
__aeabi_memcpy
0x8039130
mismatch12memory at return: 1-byte value stored at r0: source gives 0x20, binary gives 0x2 for r0=0xffffffff r1=0x6281048 r2=0x1 mem[0x6281048]=0x20 mem[0xffffffff]=0x02
__aeabi_memcpy4
0x8039154
mismatch12memory at return: 1-byte value stored at r0: source gives 0x20, binary gives 0x2 for r0=0xffffffff r1=0x6281048 r2=0x1 mem[0x6281048]=0x20 mem[0xffffffff]=0x02
__aeabi_memclr
0x803919e
mismatch12memory at return: 1-byte value stored at r0: source gives 0x0, binary gives 0x4 for r0=0xffffffff r1=0x1 mem[0xffffffff]=0x04
__aeabi_memclr4
0x80391b8
mismatch12memory at return: 1-byte value stored at r0: source gives 0x0, binary gives 0x4 for r0=0xffffffff r1=0x1 mem[0xffffffff]=0x04
HAL_PCD_SOFCallback
0x802db6e
mismatch8binary calls <indirect call>, which the source does not call at this point
HAL_PCD_SuspendCallback
0x802db96
mismatch8memory at return: 1-byte value stored at (mem0.32[(r0 + 1004)] + 509): source gives 0x7f, binary gives 0x80 for r0=0x808080ab mem[0x1000400c]=0x80 mem[0x1000400d]=0x80 mem[0x1000400e]=0x80 mem[0x1000400f]=0x80 mem[0x100046c4]=0x80 mem[0x100046c5]=0x80 mem[0x100046c6]=0x80 mem[0x100046c7]=0x80
HAL_PCD_ResumeCallback
0x802db9e
mismatch8memory at return: 1-byte value stored at (mem0.32[(r0 + 1004)] + 508): source gives 0x7f, binary gives 0x80 for r0=0x808081a5 mem[0x1000400c]=0x80 mem[0x1000400d]=0x80 mem[0x1000400e]=0x80 mem[0x1000400f]=0x80 mem[0x100046c4]=0x80 mem[0x100046c5]=0x80 mem[0x100046c6]=0x80 mem[0x100046c7]=0x80
HAL_PCD_DisconnectCallback
0x802dbbe
mismatch8binary calls <indirect call>, which the source does not call at this point
encode_basic_field
0x8029858
proved456
mpu_reconfig
0x802b7f0
proved440
ge25519_unpack_negative_vartime
0x8024ab8
proved416
USB_EPStartXfer
0x802e9e8
proved416
workflow_firmware_update
0x8026f78
proved404
ge25519_pnielsadd
0x80248dc
proved332
backlight_init
0x802fa48
proved324
unit_properties_init
0x802b228
proved316
_154a_init_seq
0x802f5b4
proved312
HAL_GPIO_DeInit
0x802a188
proved304
ge25519_pnielsadd_p1p1
0x8024774
proved288
reduce256_modm
0x8024e38
proved288
fw_check
0x80280c4
proved260
SystemInit
0x802bfd0
proved252
display_io_init_gpio
0x802ef94
proved252
usb_class_setup
0x802d538
proved244
USB_EP0StartXfer
0x802e8d8
proved232
curve25519_sub_after_basic
0x80231f8
proved230
tf15411a_init_seq
0x802f464
proved220
codec_send_msg
0x80277cc
proved216
mpu_init
0x802b6ec
proved216
touch_get_state
0x80306bc
proved216
load_descriptor_values
0x80282f4
proved214
USBD_StdEPReq
0x802e2e4
proved212
dma2d_rgb565_blend_mono8
0x80310c0
proved208
dma2d_wait
0x8030b6c
proved200
usb_webusb_add
0x802d280
proved196
touch_fsm_get_event
0x803081c
proved192
HAL_DMA2D_ConfigLayer
0x803133c
proved192
curve25519_swap_conditional
0x80240cc
proved186
sha512_Final
0x802626a
proved186
pb_validate_utf8
0x8028556
proved186
ge25519_double_p1p1
0x80246bc
proved184
expand_raw256_modm
0x802569c
proved184
bootloader_process_comm
0x8027594
proved180
curve25519_sub
0x8023148
proved176
workflow_menu
0x8027288
proved176
backlight_set
0x802f998
proved176
workflow_wipe_device
0x802710c
proved172
curve25519_add_after_basic
0x802309a
proved170
check_vendor_header_sig
0x8020e40
proved168
curve25519_neg
0x80232e4
proved168
HAL_FLASHEx_Erase
0x8029f18
proved168
pb_encode_varint
0x80295f0
proved164
systask_exit_fault
0x802c44c
proved164
dma2d_rgb565_copy_rgb565
0x8030e40
proved164
sha256_Final
0x8025b8a
proved160
lx154a2411_gamma
0x802f6ec
proved160
flash_area_write_data_padded
0x80315e0
proved160
HAL_PCD_Init
0x802a2ce
proved158
USBD_LL_DataInStage
0x802df18
proved158
usb_iface_init
0x8027980
proved156
memregion_del_range
0x802b62c
proved154
syshandle_write_blocking
0x802cfcc
proved152
blake2s_Init
0x80226dc
proved148
usb_start
0x802d82c
proved148
display_io_init_fmc
0x802f090
proved148
ft6x36_power_down
0x80303c8
proved148

Showing 100 of 578.

Raw results

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