Skip to content

Trezor Safe 5 2.13.1

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

Verified with cverif 0.1.1; 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.

15 / 183
functions proved equal to the source
4.5%
of code bytes proved (7,189 of 160,588)
2.0%
of source statements and branches proved
124
mismatches reported: 124 cverif false alarm
15 proved28 bounded1 timing leak125 mismatch, cverif false alarm1 mark too broad5 inconclusive8 unsupported

Constant time

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

3 bounded1 timing leak1 mismatch, cverif false alarm1 mark too broad4 inconclusive
FunctionClaimDetail
aes_encrypt
marked
violationthe condition of the branch `beq 0xc06cbd6` depends on secrets (core/vendor/trezor-crypto/aes/aescrypt.c:104)
true with secret cx[240] = 0xa0; false with secret cx[240] = 0x0 (public: cx = 0xa4)
aes_encrypt_key128
marked
violationthe address of a 1-byte load depends on secrets (core/vendor/trezor-crypto/aes/aeskey.c:99)
0xc07699e with secret key[12] = 0x7e, key[3] = 0x0, key[2] = 0x0, key[1] = 0x0, key[0] = 0x0, key[5] = 0x0; 0xc076920 with secret key[12] = 0x0, key[3] = 0x0, key[2] = 0x0, key[1] = 0x0, key[0] = 0x0, key[5] = 0x0 (public: key = 0x7fffff0, cx = 0x80e689c)
consteq
marked
violationargument 1 of the call to __stack_chk_fail depends on secrets (core/vendor/trezor-crypto/consteq.c:46)
0x1 with secret *(u8 *)0xd1125037 = 0x4, *(u8 *)0x7b001ff8 = 0x0; 0x0 with secret *(u8 *)0xd1125037 = 0x0, *(u8 *)0x7b001ff8 = 0x0 (public: s1 = 0x29edefc7, s2 = 0x80002006)
ECRYPT_keysetup
marked
inconclusiveconstant time not checked: the binary differs from the source
hmac_sha256
marked
inconclusiveconstant time not checked: the binary differs from the source
hmac_sha256_Init
marked
inconclusiveconstant time not checked: the binary differs from the source
memzero
marked
inconclusiveconstant time not checked: the binary differs from the source
rfc7539_init
marked
boundedconstant time on the explored paths only
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
    trezor-t3t1-2.13.1.bin, sha256 d0b2d2e113ea3375517f4c899fdcdd274499a2ad3bc02edf4ea33d7b99b8c7bd
  2. Fingerprint
    the header's fingerprint 0d242f4ef04fef04… equals the vendor's release metadata
  3. Header
    the signed header's code hashes match the code
  4. Source
    trezor/trezor-firmware, tag core/v2.13.1, commit 4289e23b317e…, the commit the vendor names for this release
  5. Reproducible build
    the vendor's own build reproduces the published image byte for byte, signatures aside
  6. Source bundle
    327 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; arm-none-eabi-gcc (Arm GNU Toolchain 13.3.Rel1 (Build arm-13.24)) 13.3.1 20240614
  7. Extraction
    code at 0xc050800, 1,589,760 bytes; every published byte is accounted for
  8. Verification
    cverif 0.1.1 on the published bytes: 15 of 183 functions proved, 12 flag group(s)

Findings

lowtiming leakAES key expansion indexes a table with key bytes
aes_encrypt_key128 (Gladman's table-based AES) loads an S-box entry at an address computed from a key byte (ldrb sl, [r0, r3]). cverif counts any secret-dependent address as a violation; on this MCU the table is in flash, and whether that changes the timing depends on the memory system, which is not settled here.
ct-triage · confidence high · findings.md · ct-aes-key-expansion
infoThe firmware build reproduces the published image
build-docker.sh --models T3T1 --skip-bitcoinonly --targets firmware core/v2.13.1 gives the published image byte for byte once the 65-byte signature is zeroed; its fingerprint is the one releases.json gives. The script's default target list fails for this model (it includes secmon).
reproducibility · confidence high · findings.md · reproducible
infoThe header commits to the code and matches releases.json
All 16 SHA-256 chunk hashes (128 KiB chunks) match the code, and the computed fingerprint equals the one releases.json publishes. The bootloader embedded in the image decompresses to exactly the published bootloader 2.1.16.
integrity · confidence high · header
infoThis run covers the kernel only
The image is a kernel (C) and an application (MicroPython, trezor-crypto, Rust). The cverif runs were stopped before the application's flag groups finished, so the figures here are the kernel's: 151 units, 15 functions proved, 4.5% of the counted code bytes. The application is left for a later run.
coverage · confidence high · findings.md · kernel-only
info116 of the kernel's 151 units skipped by cverif
79 units include CMSIS's cmsis_compiler.h, whose __CSMC__ branch (never read by GCC) contains @; 37 include rtl/error_handling.h, which uses typedef enum : int32_t. cverif 0.1.1 rejects both. What remains is mostly trezor-crypto.
coverage · confidence high · cverif issue 6 · cmsis-enum
infoAbout a third of the image is C
From the link maps: C 36.5% of the image (409 KB of code), Rust 34% (245 KB of code), frozen MicroPython bytecode 22%, the embedded bootloader 6%. Rust and the bytecode's meaning are out of cverif's scope. memcpy and memset are Rust compiler_builtins code here.
scope · confidence high · composition
infomark too broadaes_encrypt branches on the key length
The reported branch reads cx->inf.b[0] (offset 240 of the context), the number of rounds, which is public; the spec marks the whole key schedule secret and cannot exclude one field. The table lookups after it are secret-indexed as in the key expansion.
ct-triage · confidence high · ct-aes-encrypt-length
infocverif false alarmconsteq: secret in a register passed to __stack_chk_fail
The call to __stack_chk_fail only happens when the stack canary was overwritten, and passes whatever r0 holds; it is not a timing dependency.
ct-triage · confidence high · cverif issue 8 · ct-consteq-canary
infocverif false alarmStack-protector canary checks
Every unit is built with -fstack-protector-all. The epilogue compares __stack_chk_guard with its saved copy and calls __stack_chk_fail if they differ; cverif lets the guard change across a call and reports that call as one the source doesn't make.
mismatch-triage · confidence high · covers 65 mismatches · cverif issue 8 · findings.md · stack-protector
infocverif false alarmCalls through compiler_builtins' memcpy/memset wrappers
memcpy and memset are 12-byte weak wrappers that tail-jump to Rust's compiler_builtins; cverif names a call by the end of the tail-call chain and compares names. The binary calls the symbol the source names (or the memset GCC emits for a zero-initialised aggregate).
mismatch-triage · confidence high · covers 49 mismatches · cverif issue 11 · findings.md · thunk-compiler-builtins
infocverif false alarmexplicit_bzero falls into bzero
newlib's explicit_bzero is laid out immediately before bzero and falls into it; the call is the source's, named by where it ends.
mismatch-triage · confidence high · covers 7 mismatches · cverif issue 11 · thunk-bzero
infocverif false alarmmemcpy/memset thunks: counterexample overlaps the callee's own frame
Rust compiler_builtins thunks with no C source, compared with cverif's library model; the counterexample puts the destination at 0xffffffff, where the thunk's push {r7, lr} writes.
mismatch-triage · confidence medium · covers 2 mismatches · rust-mem-model
infocverif false alarmpoly1305_update: counterexample object wraps the address space
The counterexample places the context at 0xffffffc4, so its fields run past 0xffffffff and wrap to address 0; no C object can. Not re-examined in detail (a 20-minute proof attempt).
mismatch-triage · confidence medium · covers 1 mismatch · findings.md · poly1305-wrap

Full analysis (findings.md)

What the image is made of

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

OriginBytesShare
C580,33436.5%
Rust543,55234.1%
MicroPython frozen bytecode (generated C)352,30622.1%
embedded binary .bootloader93,8495.9%
linker fill10,0380.6%
Rust compiler_builtins (toolchain)6,0630.4%
assembly4,3440.3%
embedded binary .vendorheader1,0240.1%
toolchain libraries (newlib, libgcc)2980.0%

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
ECRYPT_encrypt_bytes
0xc06f4c0
mismatch1272binary calls _RNvNtCsjw4xenbWbbc_17compiler_builtins3mem6memset, which the source does not call at this point
uzlib_uncompress
0xc06bf5c
mismatch792binary calls __stack_chk_fail, which the source does not call at this point
aes_ctr_crypt
0xc06c320
mismatch708binary calls _RNvNtCsjw4xenbWbbc_17compiler_builtins3mem6memset, which the source does not call at this point
curve25519_contract
0xc0719b4
mismatch668binary calls __stack_chk_fail, which the source does not call at this point
expand256_modm
0xc0731e4
mismatch464binary calls _RNvNtCsjw4xenbWbbc_17compiler_builtins3mem6memset where the source is calling memcpy
point_double
0xc070620
mismatch428binary calls _RNvNtCsjw4xenbWbbc_17compiler_builtins3mem6memset, which the source does not call at this point
poly1305_finish
0xc06fcbc
mismatch416binary calls __stack_chk_fail, which the source does not call at this point
tls_prf_sha256
0xc074ebc
mismatch416binary calls _RNvNtCsjw4xenbWbbc_17compiler_builtins3mem6memset where the source is calling explicit_bzero
point_add
0xc070860
mismatch396binary calls _RNvNtCsjw4xenbWbbc_17compiler_builtins3mem6memset, which the source does not call at this point
sha512_Update
0xc074c64
mismatch380binary calls _RNvNtCsjw4xenbWbbc_17compiler_builtins3mem6memcpy where the source is calling memcpy
cbc_mac_update
0xc06c620
mismatch368binary calls __stack_chk_fail, which the source does not call at this point
expand_message_xmd_sha256
0xc07361c
mismatch352binary calls _RNvNtCsjw4xenbWbbc_17compiler_builtins3mem6memset where the source is calling explicit_bzero
ge25519_pnielsadd
0xc072394
mismatch332binary calls _RNvNtCsjw4xenbWbbc_17compiler_builtins3mem6memset, which the source does not call at this point
aes_ccm_decrypt
0xc06ca6c
mismatch328binary calls _RNvNtCsjw4xenbWbbc_17compiler_builtins3mem6memset, which the source does not call at this point
reduce256_modm
0xc072b1c
mismatch320binary calls __stack_chk_fail, which the source does not call at this point
aes_ccm_init
0xc06c7dc
mismatch312binary calls _RNvNtCsjw4xenbWbbc_17compiler_builtins3mem6memset where the source is calling memcpy
ge25519_pnielsadd_p1p1
0xc07222c
mismatch288binary calls _RNvNtCsjw4xenbWbbc_17compiler_builtins3mem6memset, which the source does not call at this point
sha256_Update
0xc074520
mismatch272binary calls _RNvNtCsjw4xenbWbbc_17compiler_builtins3mem6memcpy where the source is calling memcpy
aes_ccm_encrypt
0xc06c964
mismatch264binary calls _RNvNtCsjw4xenbWbbc_17compiler_builtins3mem6memset, which the source does not call at this point
curve25519_sub_after_basic
0xc070c80
mismatch264binary calls __stack_chk_fail, which the source does not call at this point
flash_area_write_data_padded
0xc0687b0
mismatch256binary calls __stack_chk_fail, which the source does not call at this point
ge25519_nielsadd2_p1p1
0xc072140
mismatch236binary calls _RNvNtCsjw4xenbWbbc_17compiler_builtins3mem6memset, which the source does not call at this point
ed25519_sign_open
0xc072940
mismatch232binary calls _RNvNtCsjw4xenbWbbc_17compiler_builtins3mem6memset, which the source does not call at this point
expand_raw256_modm
0xc0733b4
mismatch228binary calls __stack_chk_fail, which the source does not call at this point
curve25519_swap_conditional
0xc071c50
mismatch220binary calls __stack_chk_fail, which the source does not call at this point
sha512_Final
0xc074de0
mismatch220binary calls bzero where the source is calling explicit_bzero
blake2s_InitKey
0xc06ee50
mismatch216binary calls _RNvNtCsjw4xenbWbbc_17compiler_builtins3mem6memset, which the source does not call at this point
pbkdf2_hmac_sha256_Init
0xc074080
mismatch216binary calls _RNvNtCsjw4xenbWbbc_17compiler_builtins3mem6memset where the source is calling explicit_bzero
curve25519_sub
0xc070bac
mismatch212binary calls __stack_chk_fail, which the source does not call at this point
curve25519_add_after_basic
0xc070ab4
mismatch204binary calls __stack_chk_fail, which the source does not call at this point
curve25519_neg
0xc070db4
mismatch204binary calls __stack_chk_fail, which the source does not call at this point
ed25519_cosi_combine_publickeys
0xc072a28
mismatch200binary calls _RNvNtCsjw4xenbWbbc_17compiler_builtins3mem6memset, which the source does not call at this point
sha256_Final
0xc074630
mismatch196binary calls bzero where the source is calling explicit_bzero
blake2s_Final
0xc06ef58
mismatch192binary calls _RNvNtCsjw4xenbWbbc_17compiler_builtins3mem6memset, which the source does not call at this point
hmac_sha256_prepare
0xc073f98
mismatch188binary calls _RNvNtCsjw4xenbWbbc_17compiler_builtins3mem6memset where the source is calling explicit_bzero
flash_area_erase_bulk
0xc0688b0
mismatch184binary calls __stack_chk_fail, which the source does not call at this point
poly1305_init
0xc06fc04
mismatch184binary calls __stack_chk_fail, which the source does not call at this point
ge25519_double_p1p1
0xc072088
mismatch184binary calls _RNvNtCsjw4xenbWbbc_17compiler_builtins3mem6memset, which the source does not call at this point
der_read_length
0xc0702e0
mismatch176binary calls __stack_chk_fail, which the source does not call at this point
blake2s_init_param
0xc06ed14
mismatch168binary calls bzero where the source is calling explicit_bzero
der_reencode_int
0xc0704d0
mismatch168binary calls _RNvNtCsjw4xenbWbbc_17compiler_builtins3mem6memset, which the source does not call at this point
bn_read_be_512
0xc06d358
mismatch164binary calls _RNvNtCsjw4xenbWbbc_17compiler_builtins3mem6memset, which the source does not call at this point
rfc7539_finish
0xc06ffbc
mismatch160binary calls _RNvNtCsjw4xenbWbbc_17compiler_builtins3mem6memset, which the source does not call at this point
poly1305_update
0xc06fe5c
mismatch156memory at return: 4-byte value stored at (r0 + 20): source gives 0x545d981e, binary gives 0x1515d90 for r0=0xffffffc4 r1=0xd063fffe r2=0x1 mem[0x0]=0x6d mem[0x1]=0x52 mem[0x2]=0xa2 mem[0x3]=0x60 mem[0x4]=0x50 mem[0x5]=0x7d mem[0x6]=0x1f mem[0x7]=0x52
curve25519_expand
0xc071918
mismatch156binary calls __stack_chk_fail, which the source does not call at this point
hash_to_curve_optiga
0xc073d7c
mismatch152binary calls _RNvNtCsjw4xenbWbbc_17compiler_builtins3mem6memset where the source is calling explicit_bzero
blake2s_Init
0xc06edbc
mismatch148binary calls _RNvNtCsjw4xenbWbbc_17compiler_builtins3mem6memset, which the source does not call at this point
hmac_sha256_Init
0xc073e14
mismatch
CT inconclusive
148binary calls _RNvNtCsjw4xenbWbbc_17compiler_builtins3mem6memset where the source is calling explicit_bzero
bn_multiply_reduce_step
0xc06d4f4
mismatch136binary calls __stack_chk_fail, which the source does not call at this point
der_read_item
0xc07040c
mismatch136binary calls __stack_chk_fail, which the source does not call at this point
get_sector_and_offset
0xc06857c
mismatch124binary calls __stack_chk_fail, which the source does not call at this point
der_write_length
0xc070390
mismatch124binary calls _RNvNtCsjw4xenbWbbc_17compiler_builtins3mem6memcpy, which the source does not call at this point
curve25519_add
0xc070a3c
mismatch120binary calls __stack_chk_fail, which the source does not call at this point
bn_fast_mod
0xc06d614
mismatch116binary calls __stack_chk_fail, which the source does not call at this point
pbkdf2_hmac_sha256_Update
0xc074158
mismatch116binary calls __stack_chk_fail, which the source does not call at this point
ECRYPT_keysetup
0xc06f3e8
mismatch
CT inconclusive
112binary calls __stack_chk_fail, which the source does not call at this point
ed25519_hram
0xc0728d0
mismatch112binary calls _RNvNtCsjw4xenbWbbc_17compiler_builtins3mem6memset where the source is calling explicit_bzero
flash_area_get_address
0xc06868c
mismatch108binary calls __stack_chk_fail, which the source does not call at this point
blake2s
0xc06f018
mismatch108binary calls _RNvNtCsjw4xenbWbbc_17compiler_builtins3mem6memset, which the source does not call at this point
ge25519_p1p1_to_full
0xc071fc0
mismatch100binary calls __stack_chk_fail, which the source does not call at this point
ge25519_full_to_pniels
0xc072024
mismatch100binary calls __stack_chk_fail, which the source does not call at this point
flash_area_write_block
0xc068750
mismatch96binary calls __stack_chk_fail where the source is calling flash_write_block
bn_mult_half
0xc06d3fc
mismatch96binary calls __stack_chk_fail, which the source does not call at this point
hmac_sha256_Final
0xc073ed8
mismatch96binary calls bzero where the source is calling explicit_bzero
hmac_sha256
0xc073f38
mismatch
CT inconclusive
96binary calls _RNvNtCsjw4xenbWbbc_17compiler_builtins3mem6memset where the source is calling explicit_bzero
bn_multiply
0xc06d5b8
mismatch92binary calls _RNvNtCsjw4xenbWbbc_17compiler_builtins3mem6memset where the source is calling explicit_bzero
bn_mod
0xc06da34
mismatch92binary calls _RNvNtCsjw4xenbWbbc_17compiler_builtins3mem6memset where the source is calling bn_cmov
flash_area_write_burst
0xc0686f8
mismatch88binary calls __stack_chk_fail where the source is calling flash_write_burst
uzlib_get_byte
0xc06bccc
mismatch88binary calls __stack_chk_fail, which the source does not call at this point
bn_write_be
0xc06d020
mismatch88binary calls __stack_chk_fail, which the source does not call at this point
bn_subtractmod
0xc06d98c
mismatch88binary calls __stack_chk_fail, which the source does not call at this point
rfc7539_auth
0xc06ff64
mismatch88binary calls _RNvNtCsjw4xenbWbbc_17compiler_builtins3mem6memset, which the source does not call at this point
bn_read_be
0xc06cfcc
mismatch84binary calls __stack_chk_fail, which the source does not call at this point
ge25519_p1p1_to_partial
0xc071f6c
mismatch84binary calls __stack_chk_fail, which the source does not call at this point
pbkdf2_hmac_sha256_Final
0xc0741cc
mismatch84binary calls _RNvNtCsjw4xenbWbbc_17compiler_builtins3mem6memcpy where the source is calling explicit_bzero
cbc_mac_final
0xc06c914
mismatch80binary calls bzero where the source is calling explicit_bzero
bn_subtract
0xc06d9e4
mismatch80binary calls __stack_chk_fail, which the source does not call at this point
buffer_read_buffer
0xc06f1d0
mismatch80binary calls __stack_chk_fail, which the source does not call at this point
curve25519_copy
0xc0709ec
mismatch80binary calls __stack_chk_fail, which the source does not call at this point
sha256_Raw
0xc0746f4
mismatch80binary calls _RNvNtCsjw4xenbWbbc_17compiler_builtins3mem6memset where the source is calling explicit_bzero
erase_sector
0xc0685f8
mismatch76binary calls __stack_chk_fail, which the source does not call at this point
bn_lshift
0xc06d2c0
mismatch76binary calls __stack_chk_fail, which the source does not call at this point
bn_rshift
0xc06d30c
mismatch76binary calls __stack_chk_fail, which the source does not call at this point
buffer_write_array
0xc06f2a4
mismatch76binary calls _RNvNtCsjw4xenbWbbc_17compiler_builtins3mem6memcpy where the source is calling memcpy
flash_area_get_size
0xc068644
mismatch72binary calls __stack_chk_fail, which the source does not call at this point
bn_add
0xc06d860
mismatch72binary calls __stack_chk_fail, which the source does not call at this point
bn_addmod
0xc06d8a8
mismatch72binary calls __stack_chk_fail, which the source does not call at this point
buffer_write_buffer
0xc06f2f0
mismatch72binary calls _RNvNtCsjw4xenbWbbc_17compiler_builtins3mem6memcpy where the source is calling memcpy
ge25519_double
0xc07234c
mismatch72binary calls _RNvNtCsjw4xenbWbbc_17compiler_builtins3mem6memset, which the source does not call at this point
bn_read_uint32
0xc06d078
mismatch68binary calls __stack_chk_fail, which the source does not call at this point
buffer_put
0xc06f260
mismatch68binary calls __stack_chk_fail, which the source does not call at this point
chacha20poly1305_decrypt
0xc06f3a4
mismatch68binary calls _RNvNtCsjw4xenbWbbc_17compiler_builtins3mem6memset, which the source does not call at this point
sha256_Init_ex
0xc0742f4
mismatch68binary calls _RNvNtCsjw4xenbWbbc_17compiler_builtins3mem6memcpy where the source is calling explicit_bzero
uzlib_uncompress_init
0xc06bf1c
mismatch64binary calls __stack_chk_fail, which the source does not call at this point
bn_one
0xc06d0f4
mismatch64binary calls __stack_chk_fail, which the source does not call at this point
bn_addi
0xc06d8f0
mismatch64binary calls __stack_chk_fail, which the source does not call at this point
buffer_peek
0xc06f120
mismatch64binary calls __stack_chk_fail, which the source does not call at this point
buffer_lstrip
0xc06f220
mismatch64binary calls __stack_chk_fail, which the source does not call at this point
chacha20poly1305_encrypt
0xc06f364
mismatch64binary calls _RNvNtCsjw4xenbWbbc_17compiler_builtins3mem6memset, which the source does not call at this point
ECRYPT_keystream_bytes
0xc06f9b8
mismatch64binary calls _RNvNtCsjw4xenbWbbc_17compiler_builtins3mem6memset, which the source does not call at this point

Showing 100 of 183.

Raw results

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