Skip to content

Trezor Safe 3 rev. A 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.

455 / 577
functions proved equal to the source
40.3%
of code bytes proved (39,473 of 97,859)
58.7%
of source statements and branches proved
35
mismatches reported: 35 cverif false alarm
455 proved65 bounded36 mismatch, cverif false alarm5 inconclusive16 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-t2b1-2.1.18.bin, sha256 2bd714bccce87b63a7cfcbf80cb0bbfebcb3464159ea1ebd61fd7ae67675b2e8
  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
    98 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 0x8020400, 100,352 bytes; every published byte is accounted for
  7. Verification
    cverif 0.1.4 on the published bytes: 455 of 577 functions proved, 6 flag group(s)

Findings

infoThe published bootloader reproduces
build-docker.sh --models T2B1 --targets bootloader core/bl2.1.18 (commit 57998a4f) gives the published image bootloader-t2b1-2.1.18.bin once the signature fields (sigmask, signature) are zeroed; the instrumented rebuild (compiler calls logged) is byte-identical to it. Fingerprint e0986066…8b3857.
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 23 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 3 mismatches · 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).
mismatch-triage · confidence high · covers 2 mismatches · cverif issue 22 · atomics
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
C68,85467.9%
Rust28,91628.5%
assembly1,4561.4%
Rust compiler_builtins (toolchain)1,3521.3%
linker fill6790.7%
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
0x80267a4
mismatch940binary calls secret_bootloader_locked where the source is calling blake2s_Init
decode_basic_field
0x8028754
mismatch792binary calls __stack_chk_fail, which the source does not call at this point
curve25519_contract
0x8033044
mismatch668binary calls __stack_chk_fail, which the source does not call at this point
USBD_StdDevReq
0x802b280
mismatch588binary calls __stack_chk_fail, which the source does not call at this point
main
0x8026314
mismatch524binary calls screen_boot_stage_1 where the source is calling erase_storage
decode_field
0x8028a6c
mismatch524binary calls __stack_chk_fail, which the source does not call at this point
expand256_modm
0x80346a4
mismatch484binary calls __stack_chk_fail, which the source does not call at this point
fw_run_prepare
0x8026084
mismatch448binary calls __stack_chk_fail, which the source does not call at this point
read_vendor_header
0x802bc68
mismatch432binary calls __stack_chk_fail, which the source does not call at this point
fw_check
0x8025f2c
mismatch344binary calls __stack_chk_fail, which the source does not call at this point
drbg_random8
0x802c084
mismatch228binary executes `dmb` where the source is calling __atomic_test_and_set
ed25519_cosi_combine_publickeys
0x8033f58
mismatch200binary calls __stack_chk_fail, which the source does not call at this point
pb_decode_varint32_eof
0x8028354
mismatch176binary calls __stack_chk_fail, which the source does not call at this point
blake2s_init_param
0x8031810
mismatch168binary calls __stack_chk_fail, which the source does not call at this point
rdi_handler
0x802c168
mismatch140binary executes `dmb` where the source is calling __atomic_test_and_set
pb_read
0x8028404
mismatch124binary calls __stack_chk_fail, which the source does not call at this point
pb_decode_varint
0x8028488
mismatch124binary calls __stack_chk_fail, which the source does not call at this point
recv_msg_firmware_erase
0x8027e30
mismatch88binary calls __stack_chk_fail, which the source does not call at this point
recv_msg_initialize
0x8027cd0
mismatch84binary calls __stack_chk_fail, which the source does not call at this point
recv_msg_get_features
0x8027d24
mismatch84binary calls __stack_chk_fail, which the source does not call at this point
recv_msg_wipe_device
0x8027d78
mismatch84binary calls __stack_chk_fail, which the source does not call at this point
pb_make_string_substream
0x80285e8
mismatch80binary calls __stack_chk_fail, which the source does not call at this point
pb_decode_svarint
0x8028694
mismatch76binary calls __stack_chk_fail, which the source does not call at this point
pb_decode_tag
0x8028504
mismatch72binary calls __stack_chk_fail, which the source does not call at this point
pb_decode_bool
0x8028658
mismatch60binary calls __stack_chk_fail, which the source does not call at this point
pb_decode_fixed64
0x8028718
mismatch60binary calls __stack_chk_fail, which the source does not call at this point
pb_decode_fixed32
0x80286e0
mismatch56binary calls __stack_chk_fail, which the source does not call at this point
bootargs_init
0x802f260
mismatch16memory at return: 4-byte value stored at 0x100081fc: source gives 0x1, binary gives 0x0 for mem[0x100081fc]=0x01 mem[0x100081fd]=0x00 mem[0x100081fe]=0x00 mem[0x100081ff]=0x00
__assert_impl
0x8030240
mismatch16argument 1 of call #1 to strlen: source gives 0x40000, binary gives 0x8037aba for r0=0x40000
__aeabi_memclr
0x80359b2
mismatch12memory at return: 1-byte value stored at r0: source gives 0x0, binary gives 0x2 for r0=0xffffffff r1=0x1 mem[0xffffffff]=0x02
__aeabi_memclr4
0x80359be
mismatch12memory at return: 1-byte value stored at r0: source gives 0x0, binary gives 0x2 for r0=0xffffffff r1=0x1 mem[0xffffffff]=0x02
__aeabi_memcpy
0x80359ca
mismatch12memory at return: 1-byte value stored at r0: source gives 0x4, binary gives 0x42 for r0=0xffffffff r1=0x86181048 r2=0x1 mem[0x86181048]=0x04 mem[0xffffffff]=0x42
__aeabi_memcpy4
0x80359d6
mismatch12memory at return: 1-byte value stored at r0: source gives 0x4, binary gives 0x42 for r0=0xffffffff r1=0x86181048 r2=0x1 mem[0x86181048]=0x04 mem[0xffffffff]=0x42
memcpy
0x8035a0e
mismatch12memory at return: 1-byte value stored at r0: source gives 0x84, binary gives 0x40 for r0=0xffffffff r1=0x84481048 r2=0x1 mem[0x84481048]=0x84 mem[0xffffffff]=0x40
memset
0x8035a1a
mismatch12memory at return: 1-byte value stored at r0: source gives 0xa2, binary gives 0x8 for r0=0xffffffff r1=0xa2 r2=0x1 mem[0xffffffff]=0x08
encode_basic_field
0x80293c0
proved484
mpu_reconfig
0x802ec80
proved464
HAL_GPIO_Init
0x802c6ec
proved456
ge25519_unpack_negative_vartime
0x8033a8c
proved416
USB_EPStartXfer
0x802d4a8
proved408
consumption_mask_init
0x802b7b4
proved388
ge25519_pnielsadd
0x80338b0
proved332
unit_properties_init
0x802c41c
proved304
USB_DevInit
0x802d134
proved292
ge25519_pnielsadd_p1p1
0x8033748
proved288
reduce256_modm
0x8034024
proved288
HAL_PCD_MspInit
0x802abe4
proved276
HAL_DMA_Init
0x802c5f0
proved252
SystemInit
0x802f4f4
proved252
usb_class_setup
0x802a6e8
proved244
curve25519_sub_after_basic
0x803240c
proved230
USBD_StdEPReq
0x802b4fc
proved226
USB_EP0StartXfer
0x802d3a0
proved224
mpu_init
0x802eb7c
proved216
load_descriptor_values
0x8027ffc
proved214
codec_send_msg
0x802770c
proved212
reset_peripherals_and_interrupts
0x802f424
proved208
usb_webusb_add
0x802a430
proved196
bootloader_process_comm
0x80274bc
proved192
button_init
0x8029930
proved192
pb_validate_utf8
0x802825e
proved186
curve25519_swap_conditional
0x80332e0
proved186
sha512_Final
0x8035456
proved186
HAL_TIM_PWM_ConfigChannel
0x802cf08
proved184
ge25519_double_p1p1
0x8033690
proved184
expand_raw256_modm
0x8034888
proved184
workflow_menu
0x80271ac
proved176
curve25519_sub
0x803235c
proved176
workflow_wipe_device
0x8027030
proved172
curve25519_add_after_basic
0x80322ae
proved170
usb_get_state
0x802aa70
proved168
check_vendor_header_sig
0x802be2c
proved168
HAL_FLASHEx_Erase
0x802e3c4
proved168
flash_area_write_data_padded
0x802e684
proved168
jump_to_next_stage_phase_2
0x802f034
proved168
curve25519_neg
0x80324f8
proved168
pb_encode_varint
0x8029188
proved164
systask_exit_fault_ex
0x802fa58
proved160
sha256_Final
0x8034d76
proved160
USBD_LL_DataInStage
0x802b130
proved158
HAL_PCD_Init
0x802d828
proved158
real_jump_to_firmware
0x8026264
proved156
usb_iface_init
0x80278cc
proved156
memregion_del_range
0x802eabc
proved154
button_fsm_get_event
0x8029848
proved152
TIM_Base_SetConfig
0x802cddc
proved152
syshandle_write_blocking
0x802f9a0
proved152
usb_start
0x802a9dc
proved148
blake2s_Init
0x80318b8
proved148
USBD_LL_SetupStage
0x802b042
proved142
random_delays_init
0x802c1f8
proved140
HAL_RCC_GetSysClockFreq
0x802c99c
proved140
SPI_WaitFlagStateUntilTimeout
0x802ca34
proved140
FLASH_SetErrorCode
0x802e148
proved140
HAL_FLASH_Program
0x802e25c
proved140
halt_device_phase_2
0x802efac
proved136
systask_exit_error
0x802fb9c
proved136
workflow_auto_update
0x802743c
proved128
OTG_HS_WKUP_IRQHandler
0x802af34
proved128
flash_otp_write
0x802e9d8
proved128

Showing 100 of 577.

Raw results

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