Skip to content

Trezor Safe 3 rev. B bootloader 2.1.18

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.

507 / 636
functions proved equal to the source
45.8%
of code bytes proved (48,880 of 106,757)
65.5%
of source statements and branches proved
37
mismatches reported: 37 cverif false alarm
507 proved63 bounded38 mismatch, cverif false alarm7 inconclusive21 unsupported

Constant time

5 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). 60 spec entries are not in this image.

2 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 (core/vendor/trezor-crypto/memzero.c:55)
any input
consteq
marked
provedconstant time (every loop iteration, by induction)
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-t3b1-2.1.18.bin, sha256 92e0c8e10f1093e9be65cbb21c520d0643076ebc426cd36b67a822a84ec19db1
  2. Header
    the signed header's code hashes match the code
  3. Source
    trezor/trezor-firmware, tag core/bl2.1.18, commit 57998a4f7147…
  4. Reproducible build
    the vendor's own build reproduces the published image byte for byte, signatures aside
  5. Source bundle
    105 C/assembly units linked into the image; 8 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 0xc010400, 130,048 bytes; every published byte is accounted for
  7. Verification
    cverif 0.1.4 on the published bytes: 507 of 636 functions proved, 6 flag group(s)

Findings

infoThe published bootloader reproduces
build-docker.sh --models T3B1 --targets bootloader core/bl2.1.18 (commit 57998a4f) gives the published image bootloader-t3b1-2.1.18.bin once the signature fields (sigmask, signature) are zeroed; the instrumented rebuild (compiler calls logged) is byte-identical to it. Fingerprint 44965acc…2c8cb2.
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
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 26 mismatches · cverif issue 23 · canary-alias
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
infocverif false alarm__assert_impl calls system_exit_fatal: identical functions folded
rtl/error_handling.c defines system_exit_fatal(message, file, line) and __fatal_error(msg, file, line) with the same body; GCC's identical-code folding (-fipa-icf, on at -Os) made __fatal_error a call to system_exit_fatal, and __assert_impl calls system_exit_fatal("Assert", file, line) directly: the same code with the source's arguments. cverif compares it as a different callee (issue 30).
mismatch-triage · confidence high · covers 1 mismatch · cverif issue 30 · icf-fatal-error
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
C77,61059.2%
Rust28,90022.0%
linker fill21,44316.4%
assembly1,6481.3%
Rust compiler_builtins (toolchain)1,3521.0%
toolchain libraries (newlib, libgcc)1180.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
fw_on_headers
0xc016860
mismatch940binary calls secret_keys_present_any where the source is calling hash_processor_sha256_init
decode_basic_field
0xc018800
mismatch788binary calls __stack_chk_fail, which the source does not call at this point
curve25519_contract
0xc0251b0
mismatch668binary calls __stack_chk_fail, which the source does not call at this point
USBD_StdDevReq
0xc01b2c4
mismatch588binary calls __stack_chk_fail, which the source does not call at this point
main
0xc0163c0
mismatch540binary calls screen_boot_stage_1 where the source is calling erase_storage
decode_field
0xc018b14
mismatch524binary calls __stack_chk_fail, which the source does not call at this point
expand256_modm
0xc02680c
mismatch484binary calls __stack_chk_fail, which the source does not call at this point
fw_run_prepare
0xc016130
mismatch448binary calls __stack_chk_fail, which the source does not call at this point
read_vendor_header
0xc01bf00
mismatch432binary calls __stack_chk_fail, which the source does not call at this point
fw_check
0xc015fd8
mismatch344binary calls __stack_chk_fail, which the source does not call at this point
ed25519_cosi_combine_publickeys
0xc0260c4
mismatch200binary calls __stack_chk_fail, which the source does not call at this point
HAL_DMAEx_List_Start_IT
0xc01db90
mismatch196binary calls __stack_chk_fail, which the source does not call at this point
pb_decode_varint32_eof
0xc018400
mismatch176binary calls __stack_chk_fail, which the source does not call at this point
HAL_DMAEx_List_InsertNode_Tail
0xc01dda0
mismatch172binary calls __stack_chk_fail, which the source does not call at this point
HAL_DMAEx_List_Start
0xc01dae8
mismatch168binary calls __stack_chk_fail, which the source does not call at this point
HAL_DMAEx_List_SetCircularMode
0xc01dee4
mismatch132binary calls __stack_chk_fail, which the source does not call at this point
pb_read
0xc0184b0
mismatch124binary calls __stack_chk_fail, which the source does not call at this point
pb_decode_varint
0xc018534
mismatch124binary calls __stack_chk_fail, which the source does not call at this point
recv_msg_firmware_erase
0xc017ed8
mismatch88binary calls __stack_chk_fail, which the source does not call at this point
recv_msg_initialize
0xc017d78
mismatch84binary calls __stack_chk_fail, which the source does not call at this point
recv_msg_get_features
0xc017dcc
mismatch84binary calls __stack_chk_fail, which the source does not call at this point
recv_msg_wipe_device
0xc017e20
mismatch84binary calls __stack_chk_fail, which the source does not call at this point
bootargs_set
0xc022314
mismatch84memory at return: 4-byte value stored at 0x3002ff04: source gives 0x0, binary gives 0x80000006 for r1=0x80000006 mem[0x300325fc]=0x00
pb_make_string_substream
0xc018694
mismatch80binary calls __stack_chk_fail, which the source does not call at this point
pb_decode_svarint
0xc018740
mismatch76binary calls __stack_chk_fail, which the source does not call at this point
pb_decode_tag
0xc0185b0
mismatch72binary calls __stack_chk_fail, which the source does not call at this point
pb_decode_bool
0xc018704
mismatch60binary calls __stack_chk_fail, which the source does not call at this point
pb_decode_fixed64
0xc0187c4
mismatch60binary calls __stack_chk_fail, which the source does not call at this point
pb_decode_fixed32
0xc01878c
mismatch56binary calls __stack_chk_fail, which the source does not call at this point
bootargs_init
0xc0223b0
mismatch32memory at return: 4-byte value stored at 0x3003262c: source gives 0x7fffffff, binary gives 0x80000000 for mem[0x3002ff04]=0x00 mem[0x3002ff05]=0x00 mem[0x3002ff06]=0x00 mem[0x3002ff07]=0x80 mem[0x3003262c]=0xff mem[0x3003262d]=0xff mem[0x3003262e]=0xff mem[0x3003262f]=0x7f
__assert_impl
0xc023554
mismatch16argument 1 of call #1 to strlen: source gives 0x40000, binary gives 0xc029d42 for r0=0x40000
__aeabi_memclr
0xc027b1e
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
0xc027b2a
mismatch12memory at return: 1-byte value stored at r0: source gives 0x0, binary gives 0x4 for r0=0xffffffff r1=0x1 mem[0xffffffff]=0x04
__aeabi_memcpy
0xc027b36
mismatch12memory at return: 1-byte value stored at r0: source gives 0x20, binary gives 0xc for r0=0xffffffff r1=0xc6081048 r2=0x1 mem[0xc6081048]=0x20 mem[0xffffffff]=0x0c
__aeabi_memcpy4
0xc027b42
mismatch12memory at return: 1-byte value stored at r0: source gives 0x20, binary gives 0xc for r0=0xffffffff r1=0xc6081048 r2=0x1 mem[0xc6081048]=0x20 mem[0xffffffff]=0x0c
memcpy
0xc027b7a
mismatch12memory at return: 1-byte value stored at r0: source gives 0x28, binary gives 0x14 for r0=0xffffffff r1=0x40085048 r2=0x1 mem[0x40085048]=0x28 mem[0xffffffff]=0x14
memset
0xc027b86
mismatch12memory at return: 1-byte value stored at r0: source gives 0x10, binary gives 0x1 for r0=0xffffffff r1=0x10 r2=0x1 mem[0xffffffff]=0x01
HAL_DMA_Init
0xc01d1cc
proved876
HAL_GPIO_Init
0xc01e370
proved532
HAL_DMAEx_List_Init
0xc01d8f8
proved496
SystemInit
0xc02269c
proved488
encode_basic_field
0xc019468
proved484
USB_EPStartXfer
0xc020fc0
proved452
consumption_mask_init
0xc01b7f8
proved440
ge25519_unpack_negative_vartime
0xc025bf8
proved416
HAL_GTZC_TZSC_ConfigPeriphAttributes
0xc01e59c
proved400
secret_prepare_fw
0xc01ca2c
proved376
HAL_TIM_OC_Start
0xc0208a4
proved372
tz_init
0xc01ce98
proved360
HAL_DMAEx_List_BuildNode
0xc01dc54
proved332
ge25519_pnielsadd
0xc025a1c
proved332
HAL_SPI_Init
0xc01fdd8
proved324
tamper_init
0xc01cba8
proved320
unit_properties_init
0xc01d024
proved304
HASH_Start
0xc01ed68
proved300
ge25519_pnielsadd_p1p1
0xc0258b4
proved288
reduce256_modm
0xc026190
proved288
mpu_reconfig
0xc021e94
proved280
TIM_Base_SetConfig
0xc020570
proved276
HAL_GTZC_TZSC_MPCWM_ConfigMemAttributes
0xc01e72c
proved272
HAL_PCD_MspInit
0xc01acd0
proved256
flash_area_write_data_padded
0xc0217ac
proved256
HASH_Start_DMA
0xc01ef2c
proved252
HAL_TIM_PWM_ConfigChannel
0xc020790
proved248
usb_class_setup
0xc01a7d4
proved244
mpu_init
0xc021d94
proved240
HASH_DMAXferCplt
0xc01ec4c
proved232
curve25519_sub_after_basic
0xc024578
proved230
tamper_build_pminfo
0xc01cce8
proved228
USBD_StdEPReq
0xc01b540
proved224
USB_SetTurnaroundTime
0xc020a90
proved224
load_descriptor_values
0xc0180a8
proved214
codec_send_msg
0xc0177b4
proved212
HAL_GTZC_MPCBB_ConfigMem
0xc01e83c
proved212
button_init
0xc0199dc
proved200
usb_webusb_add
0xc01a51c
proved196
secret_bhk_regenerate
0xc01c900
proved196
HASH_GetDigest
0xc01ea08
proved196
bootloader_process_comm
0xc017564
proved192
reset_peripherals_and_interrupts
0xc02256c
proved192
pb_validate_utf8
0xc01830a
proved186
curve25519_swap_conditional
0xc02544c
proved186
sha512_Final
0xc0275c2
proved186
hash_processor_init
0xc01b9b0
proved184
ge25519_double_p1p1
0xc0257fc
proved184
expand_raw256_modm
0xc0269f0
proved184
workflow_menu
0xc017250
proved176
curve25519_sub
0xc0244c8
proved176
workflow_wipe_device
0xc0170d4
proved172
HAL_FLASHEx_Erase
0xc01e2c4
proved172
SPI_CloseTransfer
0xc01fd28
proved172
TIM_OC3_SetConfig
0xc020238
proved172
TIM_OC4_SetConfig
0xc0202e4
proved172
HAL_TIM_Base_Start
0xc0204c0
proved172
TIM_OC2_SetConfig
0xc0206e4
proved172
USB_DeactivateEndpoint
0xc020e68
proved172
curve25519_add_after_basic
0xc02441a
proved170
usb_get_state
0xc01ab5c
proved168
HASH_WriteData
0xc01eb40
proved168
jump_to_next_stage_phase_2
0xc02226c
proved168

Showing 100 of 636.

Raw results

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