Skip to content

cverif issues found on real firmware ​

Limits of cverif met while verifying vendor firmware. Each one costs coverage (a skipped file, an unproved function) or produces a false MISMATCH. They are reported to cverif; this list says which results they affect and whether this repository works around them.

cverif 0.1.2 (changelog of 2026-12-04) addresses 1, 2, 3, 5 (--compile-commands), 6, 7, 8, 9, 10 and 11, and 12 for callers passing array lengths. cverif 0.1.3 addresses 13 (attributes wherever GCC takes them), 14 (__FILE__ as the build named it) and 15 (. in assembly). Each entry stays here until a rerun of the result it names confirms the fix. cverif 0.1.5 (changelog of 2026-12-05) addresses 19 and 23 (stores through arguments are not stores to __stack_chk_guard; a program's own __stack_chk_fail is a call), 20 (-ftrivial-auto-var-init for VLAs), 21 (a pure library call repeated over unchanged memory; memcpy/memset into a local), 22 (__atomic, ldrex/strex) and asserts under NDEBUG; 27 is still there (#0*4, tested). The 0.1.5 rerun of the T3T1 bootloader confirms 23 (none of its 20 canary false alarms is left). cverif 0.1.4 fixes 17 (wide string literals). The 0.1.4 rerun of the T3T1 bootloader 2.1.16 confirms 6 (the 90 CMSIS units are read), 10 (chacha_drbg_* verified), 11 (no thunk-named call left) and 12 (erase_areas no longer differs; bounded).

#IssueSeen inEffectWorkaround here
1An empty declaration inside a struct (;;, e.g. a macro that ends in ; used as M(x);) is a parse error: type expected, found ';'. GCC accepts it (a pedantic warning). Still in cverif 0.1.1 (OneKey Classic 1S).Trezor One legacy/firmware/config.h:57 (STORAGE_BYTES(private_key, 32);); OneKey Classic 1S, same line (legacy/firmware/config.h:61)11 firmware files skipped (fsm.c, config.c, signing.c, u2f.c, ...), their code counted as unverified; Classic 1S: 21 files skipped (fsm.c, config.c, protect.c, se_chip.c, layout2.c, ...)none (would mean editing vendor source)
2The C standard (__STDC_VERSION__) is taken from the image's records, once per image, while units are built with different -std (libopencm3 -std=c99, the rest -std=gnu11). With c99 chosen, max_align_t is undeclared (GCC's stddef.h defines it for C11 only).Trezor One vendor/trezor-crypto/zkp_context.cfile skippedverify.py passes each group's -std as -D__STDC_VERSION__=... (cverif lets -D override the records)
3binary omits the source's 4-byte read of the volatile object where the binary keeps a pointer loaded from memory (usbd_dev->driver) across a store to a volatile MMIO register whose address is computed from memory. The disassembly does every register access the source does on every path; the compiler's reuse of the pointer is allowed by strict aliasing (a uint32_t store can't modify a pointer-typed field). Likely a false alarm.Trezor One, libopencm3 dwc_ep_stall_set, dwc_poll (lib/usb/usb_dwc_common.c)2 false MISMATCHnone; triaged in the result's findings.md
4A raw image (no ELF) gives cverif no records: no core, no compiler, and __STDC_HOSTED__ defaults to 0, so GCC's stdint.h takes its freestanding branch, unlike the build.all targetswrong reading of the toolchain headersthe published bytes are transplanted into the rebuilt ELF (fwimage.py transplant) so cverif reads the build's records; toolchain include directories are copied whole into the bundle
5One set of -I/-D per run: no per-file flags (no compile_commands.json input).all targetsneeds one run per flag group, with the cost of re-reading the image each time and cross-group calls seen as calls to code without sourceverify.py groups units by flags and merges the results
6A character that is not a C token (@) inside a skipped conditional group is a lexing error (stray character '@'), even under #if 0. GCC accepts it: skipped groups are only scanned for directives, and @ is a valid preprocessing token anyway. Still in cverif 0.1.1.Trezor core (T3T1 2.13.1, T3T1 bootloader): CMSIS cmsis_compiler.h:250 (the __CSMC__ branch, #define __PACKED @packed), included by every STM32 HAL and driver unitevery unit that includes the STM32 HAL is skipped: most of the kernel, the drivers and the bootloader's platform codenone (would mean editing vendor source)
7An enum with a fixed underlying type (typedef enum : int32_t {...}, C23, a GCC extension in -std=gnu11) is a parse error: declarator name expected, found ':'. Still in cverif 0.1.1.Trezor core: core/embed/rtl/inc/rtl/error_handling.h:33, included widely in embed/units including it are skippednone
8-fstack-protector-all is not modelled: the canary check in each epilogue (load __stack_chk_guard, compare with the copy saved in the frame, call __stack_chk_fail if they differ) is reported as binary calls __stack_chk_fail, which the source does not call, because a callee may (as far as the proof knows) change __stack_chk_guard. The flag is read from the image (-fstack-protector (95%)) but not used in proofs.Trezor core: every unit is built with -fstack-protector-allfalse MISMATCH on every function with a call and a framenone; triaged in the result's findings.md
9GNU assembler .macro name arg:req is an unknown directive: the routines of the file are not verified.Trezor core core/embed/sys/startup/stm32u5/vectortable.Svector table and handlers of that file unverifiednone
10GCC's predefined __FILE_NAME__ (GCC 12+, the source file's base name) is not defined: functions using it (through ensure()-style macros) are UNSUPPORTED: undeclared identifier __FILE_NAME__. Seen with cverif 0.1.0; to recheck on 0.1.1 results.Trezor core: trezor-crypto bignum.c, chacha_drbg.c (via rtl/error_handling.h)those functions unverifiednone (a per-file -D would need one cverif run per file)
11A call is identified by the end of a chain of tail-call thunks, not by the symbol called: in an image linked with Rust, memcpy/memset are compiler_builtins' weak wrappers that tail-jump to _RNv...compiler_builtins3mem6memcpy/memset, and newlib's explicit_bzero falls into bzero, which jumps to memset. cverif then reports binary calls _RNv...mem6memset where the source is calling explicit_bzero (or memcpy, or a compiler-generated memset for T x[1] = {0}, "which the source does not call"). The binary calls the very symbol the source names.Trezor core kernel and coreapp (any firmware linking Rust)false MISMATCH on most functions that copy or clear memorynone; triaged in the result's findings.md
12A static function is verified for every input, while GCC may compile it for the arguments its callers actually pass (here a for loop compiled as a do-while because every call passes a non-zero constant count). The counterexample uses an argument no caller passes.Trezor T3T1 bootloader erase_areas (sys/flash/flash_utils.c)false MISMATCHnone; triaged in the result's findings.md
13A GNU attribute after the declarator of a function-pointer typedef, before the ; (typedef CborError (*CborStreamFunction)(void *, const char *, ...) __attribute__((__format__(printf, 2, 3)));) is a parse error: expected ';' but found '__attribute__'. GCC accepts it. Still in cverif 0.1.1.OneKey Classic 1S, tinycbor src/cbor.h:584 (included by every CBOR user)16 firmware files skipped (signing.c, ethereum.c, fido2/ctap.c, coin_signing_state.c, ...)none
14__FILE__ expands to the path of the file cverif reads (the bundle's copy), not the path the compiler was given. Builds that compile with relative paths (SCons runs GCC in core/ with vendor/trezor-crypto/bignum.c) put that relative path in assert/ensure messages, so the string literal the binary passes differs from the source's. A -ffile-prefix-map-like option (or -D-style override per unit) would fix it. Still in cverif 0.1.1.OneKey Pro bootloader 2.8.4: bn_*, point_jacobian_*, chacha_drbg_generate, se_get_statefalse MISMATCH on every function with an assert or ensure that is not inlined awaynone; triaged in the result's findings.json
15GNU assembler b . (branch to the current location) is read as a reference to a symbol named .: the binary neither defines nor refers to '.'. Still in cverif 0.1.1.OneKey Pro bootloader 2.8.4: shutdown_privileged (embed/trezorhal/util.s:168)false MISMATCHnone
16With -fstack-protector-all and a plain global uint32_t __stack_chk_guard (defined in the firmware, set at boot), the canary check is still binary calls __stack_chk_fail, which the source does not call at this point, despite 0.1.2's stack-protector assumption. Seen in cverif 0.1.3.Trezor One 1.14.3 (legacy/setup.c:32): sha256_Init, bn_one, ... (34 in the first flag group alone)false MISMATCH on every function with a canarynone
17sizeof(u"...") (a UTF-16 string literal in a macro used in a designated initializer) is a parse error: expression expected, found '.' at the next designator. GCC accepts it. Seen in cverif 0.1.3; fixed in 0.1.4 (a 10-line test with the same initializer proves).Trezor One 1.14.3: legacy/winusb.c:72 (WINUSB_EXTENDED_PROPERTIES_GUID_NAME u"DeviceInterfaceGUIDs", winusb_defs.h:32)winusb.c skippednone
18Speed: at 6 jobs, the 96-source flag group of Trezor One (993 functions) got through 112 functions in 30 minutes (cverif 0.1.3, default work limit, constant-time marks); the slowest took 279 s (bn_cnegate), 164 s (sha512_Update), 151 s (sha256_Update). A whole firmware is days of CPU at this rate.Trezor One 1.14.3; also Classic 1S and Trezor core application groups, which never finishedruns end at the deadline with most functions not trieda lower HWW_WORK_LIMIT per function (more BOUNDED, all tried)
19In the flag group whose sources define __stack_chk_fail (Trezor One's setup.c, a noreturn function that calls fault_handler, then shutdown), the canary check's bl __stack_chk_fail is reported as binary calls memzero, which the source does not call at this point: the call is given the wrong name. The disassembly of every function reported this way calls memzero nowhere. Seen in cverif 0.1.3.Trezor One 1.14.3, flag group 1: random_buffer, data2hex, svc_handler_main, the libopencm3 usb_standard_* handlers (13 functions)false MISMATCH (the canary of issue 16, misnamed)none; triaged in the result's findings.json
20-ftrivial-auto-var-init=zero is not modelled: GCC zero-fills every local the source leaves uninitialised, a VLA with a call to memset, so the binary makes a memset call (or holds a zero in a stack slot) the source doesn't. Seen in cverif 0.1.3.Trezor One 1.14.3: every trezor-crypto unit is built with it (50 units): b58tobin, base58_encode_check, base58_decode_checkfalse MISMATCH (binary calls memset where the source is calling ...)none
21Calls to C library functions GCC knows as built-ins are compared one for one: when GCC reuses the result of a pure call (strlen(word) called twice on an unchanged string), the binary makes one call fewer than the source and the next calls are misaligned. Seen in cverif 0.1.3. The same knowledge is missing in the other direction: a value loaded before a call to strlen may change during it, so the source's reload differs from the binary, which keeps the value in a register (GCC knows strlen writes no memory). Still in 0.1.4.Trezor One 1.14.3: recovery_word (via recovery_scrambledword, firmware/recovery.c:544-546); with 0.1.4 also webusb_control_vendor_request (webusb_https_url) and render_address_dialog (coin->cashaddr_prefix)false MISMATCH (binary calls memcpy where the source is calling strlen)none
22GCC's __atomic_* built-ins (__atomic_test_and_set, __atomic_clear) are treated as calls; GCC expands them inline (dmb, ldrexb/strexb or a plain store). Seen in cverif 0.1.3.Trezor One 1.14.3: zkp_context_init, zkp_context_destroy, zkp_context_acquire_writable, zkp_context_release_writable (trezor-crypto zkp_context.c)false MISMATCH (binary executes dmb where the source is calling __atomic_clear)none
23The stack-protector assumption doesn't keep pointer arguments clear of __stack_chk_guard: the counterexample points an argument (a pb_istream_t *, a result buffer) at the guard, the source's store through it (stream->errmsg = ...) overwrites the canary, the binary's epilogue check fails and __stack_chk_fail runs (error_shutdown ... systask_exit_fatal), reported as binary executes `mrs ipsr`, which the source does not do at this point. No caller can pass such a pointer: the guard is a compiler-introduced object the source can't name. Seen in cverif 0.1.3.Trezor Safe 5 bootloader 2.1.16 (__stack_chk_guard at 0x30030220): pb_read, pb_decode_*, recv_msg_*, ed25519_cosi_combine_publickeys, HAL_DMAEx_List_Start_IT (21 functions)false MISMATCHnone; triaged in the result's findings.json
24When the sources define a function twice, once __weak (the STM32 HAL's default callbacks in stm32u5xx_hal_pcd.c) and once strong (the firmware's in usbd_conf.c), the binary's function (the strong one: the link map shows the weak .text.HAL_PCD_* sections discarded) is compared with the weak definition: binary calls USBD_LL_StallEP, which the source does not call at this point. Seen in cverif 0.1.3 and 0.1.4. Worse, cverif may reject the unit holding the strong definition as a whole (redefinition of HAL_QSPI_CmdCpltCallback), so its other functions go unverified.Trezor Safe 5 bootloader 2.1.16: HAL_PCD_MspInit, HAL_PCD_MspDeInit, HAL_PCD_SetupStageCallback, HAL_PCD_SOFCallback, ... (10 functions); OneKey Pro bootloader 2.8.4: 25 callbacks, and the units qspi_flash.c, usbd_conf.c, spi_legacy.c, usart.c, camera.c, stm32_it_handler.c skippedfalse MISMATCHnone; triaged in the result's findings.json
25An enumeration with an enumerator that doesn't fit 32 bits (BOOT_COMMAND_POWER_OFF = 0x24EEE8828) is 64-bit in GCC (g_boot_command is 8 bytes; the binary copies it with ldrd/strd and takes it in r0:r1), but is read by cverif as a 32-bit type: the upper word of a stored command is 0 in the source, and a loaded one is clamped. Seen in cverif 0.1.4.Trezor core sys/startup/inc/sys/bootargs.h: bootargs_init, bootargs_setfalse MISMATCHnone
26ARMv8-M instructions not decoded: LDAEXB (0xe8d63fcf, from __atomic built-ins) and MSR MSPLIM (0xf383880a). Seen in cverif 0.1.4.Trezor Safe 5 bootloader 2.1.16: drbg_random8, rdi_handler, USBD_StdDevReq (inlined callee), reset_handlerUNSUPPORTEDnone
27An immediate written as an expression in inline assembly (AND R0, R0, #~7, GNU as computes ~7) is a parse error: register expected. The same for ldr r7, [r1, #0*4] (expression 0*4; its routines are not verified): libsecp256k1's whole ARM field arithmetic is skipped. And the directive . = . + 2 is unknown. Seen in cverif 0.1.4 and 0.1.5.Trezor core ensure_thread_mode; Trezor One 1.14.3: secp256k1-zkp/src/asm/field_10x26_arm.s (secp256k1_fe_mul_inner, secp256k1_fe_sqr_inner), firmware/header.SUNSUPPORTED; assembly files' routines not verifiednone
28A static function the compiler inlined everywhere (so with no symbol) is compared with another unit's static function of the same name that has one: flash_area.c's erase_sector (inlined into flash_area_erase_bulk) with norcow.c's (.text.erase_sector from norcow.o in the link map). The link map says which object defines the code at the address. Seen in cverif 0.1.4.Trezor One 1.14.3: erase_sector (flag group 1)false MISMATCH in the group without the defining unitverify.py keeps the result of the group holding the unit the link map names
29A local aggregate initialised with = {0} that GCC clears with a call to memset (7.6 KB here) is not matched with that call: binary calls memset where the source is calling explicit_bzero (the next call the source makes). The converse too: a 6-byte memcpy of a constant size that GCC calls (-Os) is taken as expanded inline, so cverif's numbering of the calls is off by one. Likewise an initializer copied from a constant template with memcpy (Features msg_send = Features_init_default). Seen in cverif 0.1.4.Trezor One 1.14.3: u2fhid_read_start (U2F_ReadBuffer readbuffer = {0}); Trezor Safe 7 bootloader 2.1.16: ble_write; OneKey Pro bootloader 2.8.4: send_msg_features_simplefalse MISMATCHnone
30GCC's identical-code folding (-fipa-icf, on at -O2/-Os): two functions of a unit with the same body become one, the other a call to it, and their callers may call the kept one. A call to __fatal_error that the binary makes to system_exit_fatal (same body, rtl/error_handling.c) is compared as a different callee, and cverif then follows it with different arguments folded. Seen in cverif 0.1.4.Trezor Safe 3 bootloaders 2.1.18 (T2B1, T3B1): __assert_implfalse MISMATCHnone
31Floating-point contraction: with -std=gnu11 GCC contracts a * b + c into a fused multiply-add (-ffp-contract=fast, vfma.f32), rounding once; C allows it (C11 6.5p8). cverif evaluates the source with two roundings, so results differ in the last bit. Seen in cverif 0.1.4.Trezor Safe 7 bootloader 2.1.16: the battery model (calc_ocv, battery_rint, ... 7 functions)MISMATCH (an implementation choice C leaves open)none
32A pointer argument is placed in the peripheral range (the default --mmio 40000000-5fffffff): the counterexample has a DMA_HandleTypeDef at 0x40000000, so the source's reads of hdma->Instance are fresh peripheral values while the binary reads it once. No caller passes a handle outside RAM. Seen in cverif 0.1.4.OneKey Pro bootloader 2.8.4: HAL_DMA_Start_ITfalse MISMATCHnone
33Initializers GCC folds as constants are rejected (initializer element is not a compile-time constant): a member of a const struct (.end_x = lcd_params.hres - 1) and a subscripted string literal ((TO_STR(x))[0]). Seen in cverif 0.1.4.OneKey Pro bootloader 2.8.4: mipi_lcd.c:81, usbd_msc_storage.c:83units skippednone
34In a helper checked "for the secrets its callers give it", every byte reached through a pointer is taken as secret unless shown public, including constants in flash (secp256k1's prime, curve->a), public inputs (a public key under validation) and globals (SystemCoreClock, an I2C handle); the error path of every marked function (ensure → __fatal_error → display, touch, I2C) is then reported. Similarly, once secrets are anywhere in memory a function can read (or after a call that stored secrets outside its frame), branches on public fields are reported: the SHA-2 bit count, a digest read after init_rfc6979, a constant algorithm tag, the infinity flag of a public point. Seen in cverif 0.1.4.OneKey Pro bootloader 2.8.4: 36 functions; Trezor One 1.14.3: sha256_Update, sha512_Update, sha512_Raw, tc_ecdsa_sign_digest, nonce_function_bip340, secp256k1_ecmult_const (9 with callers)false CT-VIOLATIONnone
35A call to newlib's explicit_bzero is "not known to be constant time", though it is explicit_bzero → bzero → memset, and cverif trusts memset by name. Seen in cverif 0.1.4.Trezor One 1.14.3: memzero, sha256_Final, sha512_Final and 15 callers; every Trezor bootloader: memzerofalse CT-VIOLATIONnone
36The stack canary's bl __stack_chk_fail (no arguments, never returns) is taken as a call given a pointer to secret memory when a register still holds one (r1 at 0x8041014), despite the stack-protector assumption. Seen in cverif 0.1.4.Trezor One 1.14.3: sha3_Update, keccak_512false CT-VIOLATIONnone

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