About cverif-hww
Open, repeatable verification of the firmware that hardware-wallet vendors publish, against the source code they publish, using cverif.
A reproducible build shows that a build of the published source gives the published bytes. It does not say what those bytes do: it trusts the compiler, the build environment the vendor chose, and every binary blob in the tree. A miscompilation, or a compromised toolchain, reproduces perfectly. cverif closes that gap from the other side. It reads the C source and the machine code, both on their own terms, never running or trusting a compiler, and proves function by function that the code in the published image computes what the source says, for every input. So it checks two things at once: that the image is the published code, and that the compiler didn't change what that code means. For cryptographic code it also proves that the compiler kept it constant time: the published code's timing doesn't depend on keys, nonces or PINs (docs/constant-time.md). Code the proofs don't reach shows up as unverified bytes, and code that differs shows up with a concrete input that demonstrates the difference.
Results: https://karpeleslab.github.io/cverif-hww/ (one page per vendor, device and release, built from results/ by site/).
This repository holds the scripts that do this end to end for each wallet (download, source checkout, vendor build, image extraction, cverif, report), the documentation of how it is done, and the results.
Status
| Vendor | Target | Firmware | Status |
|---|---|---|---|
| Trezor | trezor/t1b1 Model One | legacy, C, Cortex-M3 | reproduces (1.14.3); cverif 0.1.4, full run: 753 functions proved, 59.5% of code bytes; 207 mismatches, none a real difference (cverif false alarms, or inputs needing undefined behaviour); constant time: low-severity timing dependence of the Cortex-M3's variable-time multiplies (umull/umlal) on secret limbs in bn_multiply, curve25519 and libsecp256k1 |
| Trezor | trezor/t3t1boot Safe 5 bootloader | C + Rust UI | reproduces (2.1.16); cverif 0.1.5: 517 functions proved, 41.7% of code bytes; 19 mismatches, 18 cverif false alarms and 1 needing undefined behaviour; no constant-time violation |
| Trezor | trezor/t3t1 Safe 5 | core: C + MicroPython + Rust (C verified) | reproduces (2.13.1); kernel only published, cverif 0.1.1 and without -mcmse read as secure: re-run queued |
| Trezor | trezor/t2t1 Model T | core | reproduces (2.13.1); verify to run |
| Trezor | trezor/t2b1, trezor/t3b1 Safe 3 | core | target written, queued |
| Trezor | trezor/t2t1boot, trezor/t2b1boot, trezor/t3b1boot bootloaders | C + Rust UI | reproduce (2.1.16, 2.1.18, 2.1.18); cverif 0.1.4: 445, 455, 507 functions proved (33.4%, 40.3%, 45.8% of code bytes); 42, 35, 37 mismatches, all cverif false alarms; no constant-time violation |
| Trezor | trezor/t3w1boot Safe 7 bootloader | C + Rust UI, TRZQ header | reproduces (2.1.16); cverif 0.1.4: 762 functions proved, 38.8% of code bytes; 59 mismatches: 51 cverif false alarms, 7 floating-point contractions C allows, 1 needing undefined behaviour; no constant-time violation |
| Trezor | trezor/t3w1 Safe 7 | core: secmon + kernel + coreapp | reproduces (2.13.1), embedded secmon reproduces too; verify queued |
| OneKey | onekey/pro-bootloader Pro bootloader | C | reproduces (2.8.4); cverif 0.1.4: 700 functions proved, 67.5% of code bytes; 36 mismatches, all cverif false alarms; constant time: one low-severity timing leak (trezor-crypto's bn_cmov/bn_cnegate asserts compiled into branches on the secret condition, built without NDEBUG; reached with the MCU–SE session's ephemeral ECDH key) |
| OneKey | onekey/pro Pro | Trezor core fork | reproduces (4.21.0); verify to run |
| OneKey | onekey/classic1s Classic 1S | Trezor legacy fork | reproduces (3.21.0); verify to run |
| KeepKey | keepkey/keepkey KeepKey | C, Cortex-M3 (Trezor One-derived) | reproduces (7.14.2); verify to run |
| KeepKey | keepkey/keepkey-btconly KeepKey Bitcoin-only | C, Cortex-M3 | reproduces (7.14.3); verify to run |
| Coldcard, BitBox, Keystone | documented in docs/vendors/, no target yet |
See docs/vendors/ for what is known about each vendor's release channel, image format and build, and results/ for the verification reports.
How it works
For one published release of one device, bin/hww run <target> <version> runs these steps:
- fetch: download the signed image from the vendor's official channel and record what the vendor's release metadata says about it (hash, fingerprint, source commit).
- source: check out the source at the tag the vendor gives for that release, and check that the tag resolves to the commit the vendor's metadata names.
- build: run the vendor's own reproducible-build procedure, unmodified. Then rebuild once more inside the same container with every compiler and archiver call recorded, check that this rebuild is identical, and export the source bundle: every file the compiler read for each translation unit that the final link pulled in (sources, headers, generated headers, toolchain headers), with its compile flags and the link map.
- extract: strip the signed headers off the published image, check the header's hashes against the code, and compare the result with the rebuild.
- verify: run cverif on the published code bytes at their load address, with the symbol table from the link map, against the source bundle. Translation units are grouped by compile flags and verified group by group, then the results are merged.
- report: write
results/<target>/<version>/with a summary, per-function results, and the manifest (sha256) of every source file verified.
The symbol table only says where functions start. cverif proves each function on its own against the published bytes, so it does not have to trust the build. The reproducible build is what makes the symbol table exact; where a vendor's build doesn't reproduce, cverif --discover recovers functions from the stripped image instead. The method, the trust model, and what a result does and does not establish are in docs/methodology.md.
Running it
Needs: Linux x86-64, Docker (running, user in the docker group), git, curl, jq, python3, and a Rust toolchain with the x86_64-unknown-linux-musl target (to install the pinned cverif release as a static binary).
bin/hww list # known targets
bin/hww releases trezor/t1b1 # published versions
bin/hww run trezor/t1b1 1.14.3 # every step
bin/hww run trezor/t1b1 1.14.3 verify report # some stepsEverything downloaded or built goes to work/ (ignored by git). Vendor builds take from minutes to an hour the first time (their Docker environments are large, tens of GB of images in all). The build step of Trezor core and OneKey needs the network (Rust crates, submodules, Nix).
| variable | meaning | default |
|---|---|---|
HWW_WORK | where downloads, checkouts, builds and runs go | work/ |
HWW_JOBS | cverif's parallel jobs (and build jobs) | all cores |
HWW_TIMEOUT | deadline of each cverif flag group, seconds; functions unfinished at it are BOUNDED; 0: none | 1800 |
HWW_WORK_LIMIT | cverif's effort budget per function (--work-limit); lower: faster, more BOUNDED | cverif's (500000) |
HWW_CACHE | cverif --cache directory: an interrupted or extended run keeps what finished | none |
HWW_CT_SPECS | constant-time specs to apply instead of the target's CT_SPECS (empty: none) | the target's |
CVERIF | a cverif binary to use instead of the pinned release | the pin |
cverif is the slow part: about 100 s of CPU per function on average at the default work limit with cverif 0.1.3 (docs/cverif-issues.md, 18; 0.1.4 is faster: the T3T1 bootloader took 18 minutes at 64 jobs, 45 with 0.1.3), so a whole firmware is days of CPU. Use many cores, a cache, and a deadline that fits; the flag groups of a run go one after the other. To finish a run whose groups hit the deadline, run verify report again with the same HWW_CACHE and a longer HWW_TIMEOUT.
The cverif release is pinned in tools/cverif.pin and installed from crates.io (bin/hww setup), so a given result can be reproduced exactly. Each result records the cverif that verified it; bin/hww stale lists the results verified with a release other than the pin, which are due to be re-run.
Queue
What is to be run (each bin/hww run <target> <version>, every step, then triage the mismatches and constant-time violations in the result's findings.json, see docs/findings.md, and python3 -I lib/hww/findings.py check results). Every result is being produced again with cverif 0.1.5: two runs at a time (64 jobs each, a new one started only while the machine's load and free memory allow), each flag group with a 3-hour deadline (HWW_TIMEOUT=10800; 0.1.5 shares it so that every function is tried, the rest BOUNDED, and the cache lets a later run extend it). Firmwares first:
trezor/t3t1boot 2.1.16(to confirm 0.1.5's fixes),onekey/classic1s 3.21.0,keepkey/keepkey 7.14.2,keepkey/keepkey-btconly 7.14.3,trezor/t1b1 1.14.3trezor/t3t1,trezor/t3w1 2.13.1,onekey/pro 4.21.0,trezor/t2t1,trezor/t2b1,trezor/t3b1 2.13.1(large: kernel and application)- the bootloaders again:
onekey/pro-bootloader 2.8.4,trezor/t3w1boot,trezor/t2t1boot 2.1.16,trezor/t2b1boot,trezor/t3b1boot 2.1.18
Known cverif problems that still cost coverage or give false alarms are in docs/cverif-issues.md (16 to 36 found; 17 fixed in 0.1.4; 0.1.5 addresses 19 to 23, to be confirmed on its runs).
Layout
bin/hww the driver
lib/common.sh shell helpers (download, checkout, pinned cverif)
lib/container/ run inside vendor build containers: compiler-call logger, bundle exporter
lib/hww/ host-side Python (standard library only): image formats, verify, report
targets/<vendor>/ one script per device, plus the vendor's shared steps
docs/ methodology, per-vendor notes, how to add a target
results/ published results, one directory per target and version, with findings.json
site/ the results website (VitePress), deployed to GitHub Pages by .github/workflows/site.ymlTo preview the site locally: cd site && npm install && npm run dev.
License
MIT, see LICENSE. Vendor sources and firmware are not redistributed here; the scripts download them from their official locations.