bmc Bitcoin Machine Code Continuous Fuzzing
GitHub

Continuous Fuzzing & Assembly Validation

Validating hand-authored x86-64 NASM and AArch64 assembly requires fuzzing machinery built specifically for machine code. BMC-GAUNTLET combines double-sided hardware PROT_NONE guard pages, a hand-authored x86-64/ARM64 ABI register-poison trampoline, 7 in-process Bitcoin Core v32.1 & libsecp256k1 differential oracles, Valgrind ctgrind constant-time secret-taint proofs, stateful mempool/PSBT/LSM storage chaos, and 6-worker Clang libFuzzer coverage guidance seeded from Core's qa-assets running 24/7.

248.70B
Mutated executions logged (248,702,148,162 across 1516 slices)
36.44B
In-process Core v31.1 EvalScript differential comparisons
6.08M / 2.13M
Peak exec/s: NASM tx_parse / Core v31.1 differential script
0 Crashes
Unresolved crashes or consensus divergences across all 18 targets
4 Fixed
Real assembly, constant-time & PSBT bugs caught, patched & regression-pinned
100,344 Seeds
18-target libFuzzer + Core qa-assets · llvm-cov 61.2% lines / 61.3% branches · ctgrind PASS
Verified Attestation Snapshot — 2026-11-29T06:00:55Z
Latest cumulative totals recorded at commit 6e3c9839 (v0.2.1) on Linux x86_64 across 18 BMC-GAUNTLET targets (7 in-process Bitcoin Core v32.1 / libsecp256k1 differential oracles): 248,702,148,162 mutated executions over 65.93 fuzz-hours (1516 completed slices), including 36,439,868,287 direct Core differential checks, 100,344 unique corpus seeds, and 10,565 tracked edges with 0 crashes and 0 mismatches. Valgrind ctgrind constant-time proof: PASS (0 secret-dependent branches/loads). Full Markdown ledger: docs/audits/FUZZING_ATTESTATION.md.

1. Assembly-Native Fuzzing & Differential Architecture

Standard compiler sanitizers (AddressSanitizer / UndefinedBehaviorSanitizer) instrument C and C++ code, but they are blind inside hand-written x86-64 NASM (asm/*.asm) and AArch64 Mach-O (port/osx/*.S) routines. fuzz/ closes that blind spot with hardware virtual-memory traps and direct in-process differential checking:

A. Double-Sided PROT_NONE Guard Pages (fuzz/guard_buf.h) Every assembly input runs TWICE per fuzz iteration: Pass 1 (Over-read trap — flush to upper guard): PROT_NONE padding input[0..n] PROT_NONE Pass 2 (Under-read / wrap trap — flush to lower guard): PROT_NONE input[0..n] padding PROT_NONE • 1-byte read past end or negative ptr wrap triggers instant hardware SIGSEGV • Signal handler writes exact crashing input to fuzz/crashes/ before abort B. In-Process Core v32.1 Differential Oracle (2.14M exec/s) Zero fork/pipe IPC — single process comparing both VMs on every input: Mutated Input flags + sigver + script bmc script_eval (NASM) guard-paged x86-64 assembly Core v32.1 EvalScript linked libbitcoin_consensus.a Exact Equivalence Assert (on every execution) verdict (ok/fail) + stack depth + byte-for-byte stack elements → abort on diff

Guard Pages & ABI Poison Trampoline

Every assembly target (tx_parse/tx_txid, cons_verify, script_eval, p2p/cmpct, bech32, sha256, muhash, ecdsa) runs flush against double-sided PROT_NONE pages AND through fuzz/abi_poison.S—filling every callee-saved register (x86-64 rbx, rbp, r12–r15 + DF==0 → ud2; ARM64 x19–x28 + d8–d15 → brk #0x51a0) with per-input poison on every call.

7 Core v32.1 & libsecp256k1 Diff Oracles

Zero subprocess/pipe overhead—7 in-process differential harnesses link bmc directly against Bitcoin Core v32.1 static libraries: EvalScript (2.14M/s), CTransaction (txid/wtxid), MuHash3072 (ADX/IFMA/shard), libsecp256k1 (ECDSA + ElligatorSwift ECDH), BIP324Cipher (v2 handshake, AEAD & forged-tag rejection), bech32/bech32m + CSHA256, and BIP158 GCSFilter.

Valgrind ctgrind Constant-Time Proof

fuzz/ctgrind_secp256k1.c taints secret 256-bit scalars with VALGRIND_MAKE_MEM_UNDEFINED and executes all 5 constant-time secp256k1 ASM routines (_gen_ct, _ct, _win_ct, _glv_ct, _glvj_ct) under Valgrind Memcheck—catching any secret-dependent branch or memory load (already caught and eliminated 6 real GLV branches on run 1).

Stateful Mempool, Custody & LSM Chaos

Beyond stateless parsers, Phase 3 drives deep stateful invariants: fuzz_cluster_mempool (DAG topology, chunk monotonicity & Dinkelbach optimality), fuzz_psbt_descriptor (PSBT v0/v2 Updater & output descriptors—caught psbt_update.c heap OOB in 45 min), fuzz_wallet_coinsel (BnB/SRD/Knapsack exact satoshi conservation), fuzz_p2p_cmpct_asm (BIP152 compact blocks), and fuzz_utxo_lsm_chaos (Put/Del/Flush/Compact/Reload model check).

Coverage Guidance & llvm-cov Telemetry

All 18 targets run under Clang libFuzzer (with ASan + UBSan on C boundaries) seeded from Bitcoin Core's public qa-assets OSS-Fuzz corpora (73,000+ unique seeds, 10,400+ tracked edges). fuzz/measure_coverage.py periodically replays live corpora through -fprofile-instr-generate binaries to track real llvm-cov line, branch, and function coverage (61.0% lines / 60.8% branches).

Cross-ISA ARM64 Corpus Replay

fuzz/replay_arm64_cross_isa.sh syncs coverage-discovered x86-64 corpora onto Apple Silicon and replays every seed through the AArch64 assembly ports (port/osx/*.S) with ARM64 PROT_NONE guard pages and x19–x28 / d8–d15 register-poison verification—catching architecture-specific defects that x86-64 runs alone cannot reach.

2. Cumulative Fuzzing Ledger & Target Throughput

Measured throughput and verified cumulative execution counts from the continuous Linux x86-64 fuzzing runner (fuzz/fuzz_stats.json → docs/audits/FUZZING_ATTESTATION.md):

Sustained Single-Target Throughput (Higher is Better)
fuzz_tx_asm
6.08M exec/s (guard-paged NASM)
6.08M/s
fuzz_cons_asm
5.08M exec/s (guard-paged NASM)
5.08M/s
fuzz_script_diff
2.13M exec/s (Core v32.1 diff)
2.13M/s
fuzz_script_asm
1.72M exec/s (guard-paged NASM)
1.72M/s
fuzz_wallet_addr
633.9k/s
633.9k/s
fuzz_miniscript
559.5k/s
559.5k/s
fuzz_rpc_json
105.0k/s
Target Surface Under Test Slices Total Executions Avg Rate Corpus Edges Crashes
fuzz_tx_asm x86-64 NASM (bitcoin_tx.asm) — PROT_NONE + ABI poison 125 77,597,296,994 4.27M/s 1,217 15 0
fuzz_cons_asm x86-64 NASM (bitcoin_cons.asm) — PROT_NONE + ABI poison 125 75,799,636,122 4.17M/s 814 9 0
fuzz_script_diff_inproc x86-64 NASM vs Core v32.1 (EvalScript diff + ABI poison) 122 21,531,265,505 1.21M/s 9,090 120 0
fuzz_script_asm x86-64 NASM (bitcoin_interp.asm) — BASE / V0 / TAPSCRIPT 125 22,680,586,246 1.25M/s 8,684 34 0
fuzz_tx_diff_core x86-64 NASM vs Core v32.1 (CTransaction txid/wtxid diff) 59 1,916,414,869 188.5k/s 3,685 165 0
fuzz_muhash_diff x86-64 NASM vs Core v32.1 (MuHash3072 ADX/IFMA/shard diff) 59 222,320,427 21.9k/s 732 32 0
fuzz_secp256k1_diff x86-64 NASM vs libsecp256k1 (ecdsa_verify + ellswift_ecdh) 59 100,310,013 9.9k/s 3,100 55 0
fuzz_bip324_diff C + asm vs Core v32.1 (BIP324Cipher v2 handshake & AEAD) 59 89,051,797 8.8k/s 1,866 206 0
fuzz_bech32_diff x86-64 NASM vs Core v32.1 (bech32/bech32m + CSHA256) 59 10,969,176,096 1.08M/s 54 41 0
fuzz_blockfilter_diff C (block_filter.c) vs Core v32.1 (BIP158 GCSFilter) 59 1,611,329,580 158.5k/s 10,713 120 0
fuzz_p2p_cmpct_asm x86-64 NASM (bitcoin_p2p/cmpct.asm) — PROT_NONE + ABI poison 59 22,128,452,817 2.18M/s 1,217 26 0
fuzz_cluster_mempool C (mempool_cluster.c) + ASan/UBSan — DAG & chunk monotonicity 59 109,312,683 10.8k/s 1,785 573 0
fuzz_psbt_descriptor C (descriptor.c, psbt_update.c) + ASan/UBSan — PSBT v0/v2 59 212,580,529 22.1k/s 17,535 4,811 0
fuzz_wallet_coinsel C (wallet_bnb.c, wallet_coinsel.c) + ASan/UBSan — BnB/SRD/Knapsack 59 11,188,370 1.1k/s 697 237 0
fuzz_utxo_lsm_chaos C + asm (bitcoin_utxo_lsm.asm) — stateful LSM flush/compact chaos 59 37,287,364 3.7k/s 621 6 0
fuzz_wallet_addr C + asm (wallet_core.c, bech32) + ASan/UBSan + CRIT-08 124 8,351,095,566 462.8k/s 213 103 0
fuzz_miniscript C (miniscript.c) + ASan/UBSan — P2WSH & Tapscript 124 4,176,150,610 231.4k/s 20,608 3,172 0
fuzz_rpc_json C (rpc_json.c) + ASan/UBSan — UniValue heap + arena 122 1,158,692,574 65.3k/s 17,713 840 0
Total (All 18 Targets) Snapshot 2026-11-29T06:00:55Z (commit 6e3c9839 · 3955.8 min) 1516 248,702,148,162 1.05M/s 100,344 10,565 0

3. Real Assembly Bugs Caught & Regression-Pinned

Within hours of bringing up the guard-paged assembly fuzzers and the static AArch64 ABI auditor, the hardening suite immediately uncovered two genuine, latent ARM64 assembly bugs that had slipped past all 455 deterministic unit tests. Both were fixed in commit dbaff5b3 and locked down with permanent regression seeds:

Date Tool / Target Architecture Defect Discovered Fix & Permanent Guard
2026-11-28 lf_psbt_descriptor
HEAP OOB READ
Cross-platform C
(asm/psbt_update.c)
AddressSanitizer caught a heap-buffer-overflow read (+ uint64 wraparound) in input_spk() within 45 minutes of launching BMC-GAUNTLET: a malformed PSBT witness_utxo with a 0xff CompactSize at the buffer tail reached a leftover unbounded rd_varint() call. Removed unbounded rd_varint() completely, replaced with bounded rd_varint_b() and overflow-free sl <= wu->vl - 8 - cc, and pinned the exact 74-byte crashing PSBT reproducer in fuzz/gen_seeds.py (shipped in v0.2.1).
2026-11-28 ctgrind_secp256k1
TIMING SIDE-CHANNEL
Linux x86-64 & ARM64
(secp256k1_scalar & point_ct)
Valgrind Memcheck secret-taint analysis (VALGRIND_MAKE_MEM_UNDEFINED on secret scalars) caught 4 secret-dependent cmp/jne branches in sc_split_lambda and 2 secret-dependent jz .fallback / cbz w0, 9f branches in point_scalar_mul_glv_ct & point_scalar_mul_glvj_ct across both NASM and AArch64. Rewrote sc_split_lambda identity check to branchless XOR/OR + (x | -x) >> 63, added constant-time canonical reduction sc_add(k, 0) before GLV split, and removed the unreachable fallback branches. Verified valgrind --error-exitcode=42 fuzz/ctgrind_secp256k1 exits 0 across all 5 CT routines.
2026-11-28 fuzz_tx_asm
REMOTE SIGSEGV
macOS ARM64
(port/osx/bitcoin_tx.S)
In _tx_txid, comparing a non-canonical 9-byte 0xff CompactSize script length loaded #0x02000000 into x9—clobbering the live input cursor register x9 in both input and output loops and causing an out-of-bounds read at 0x02000008. Changed both comparisons to scratch register x13 (dbaff5b3). Pinned minimal crashing input as deterministic seed 05_ff_scriptlen_arm64_clobber.bin in fuzz/gen_seeds.py (replayed on every CI run).
2026-11-28 arm64_abi_audit.py
ABI VIOLATION
macOS ARM64
(port/osx/bitcoin_tx.S)
Transient 8-byte stack-pointer misalignment (ldr x27, [sp], #8; add sp, sp, #8) violating AArch64's strict 16-byte SP alignment invariant. Replaced with atomic 16-byte post-indexed ldr x27, [sp], #16 (dbaff5b3). Audited across all 50 port/osx/*.S files (323 global fns, 1,293 SP ops, 25 Darwin svc #0x80 carry-flag checks; 0 violations).
Assembly-Native Prevention Toolkit
Alongside continuous fuzzing, v0.1.0 introduced mechanical safeguards designed specifically for hand-written assembly: checked cursor/bounds macros (asm/macros_safe.inc & port/osx/macros_safe.inc), single-source consensus constant codegen across both architectures (scripts/gen_consensus_inc.py, 25 synced limits), and static ABI/register auditors for both x86-64 (abi_stack_audit.py, abi_callee_saved_audit.py) and AArch64 (arm64_abi_audit.py).

4. 24/7 Continuous Infrastructure & GitHub Actions CI

Unattended 24/7 Runner (bmc-fuzz.service)

fuzz/run_continuous_fuzz.sh cycles continuously through all 18 BMC-GAUNTLET targets with 6 parallel Clang libFuzzer workers seeded from Bitcoin Core qa-assets under systemd (Nice=19, IOSchedulingClass=idle, CPUQuota=600%, MemoryMax=12G), plus periodic llvm-cov coverage measurement and Valgrind ctgrind constant-time checks.

Atomic Ledger & Crash Capture

After every slice, fuzz/record_fuzz_stats.py atomically updates fuzz/fuzz_stats.json (fsync + rename) and rotates fuzz_continuous.log at 20 MiB. Any signal (SIGSEGV/SIGBUS/SIGILL/SIGABRT) or Core mismatch immediately writes the exact reproducer bytes to fuzz/crashes/.

Per-Commit Cross-Platform CI

.github/workflows/ci.yml builds and runs static ABI/consensus auditors, deterministic seed replay (make -C fuzz replay), and fuzz smoke campaigns on every push and PR across both Linux x86-64 and macOS Apple Silicon.

5. Honest Scope Limits & Remaining Milestones

What BMC-GAUNTLET Proves Today — and What Remains

BMC-GAUNTLET (all 4 phases live) now runs 18 Clang libFuzzer coverage-guided targets across 6 idle-priority workers seeded from Bitcoin Core's qa-assets corpus (48,000+ inputs), 7 in-process Bitcoin Core v32.1 / libsecp256k1 differential oracles (EvalScript, CTransaction, MuHash3072, libsecp256k1, BIP324Cipher, bech32/CSHA256, and BIP158 GCSFilter), an x86-64/ARM64 assembly ABI register-poison trampoline, stateful cluster-mempool & LSM storage chaos, llvm-cov coverage telemetry, and Valgrind ctgrind constant-time proofs.

  • Multi-Month Soak Time: Coverage-guided differential fuzzing compounds over months—the 24/7 service publishes updated cumulative stats daily at 06:00 UTC via bmc-fuzz-publish.timer.
  • Live Network & Multi-Node Regtest Chaos: In-process P2P framing (fuzz_p2p_cmpct_asm) and BIP324 cipher parity are verified, while adversarial live-socket multi-node eclipse/reorg fuzzing remains separate.
  • Ecosystem Differential Integration: Registering bmc as an independent consensus/script target in upstream bitcoinfuzz alongside Bitcoin Core, btcd, and rust-bitcoin remains a follow-on milestone.

6. Reproducing & Updating Locally

The entire fuzzing suite runs out of the box on Linux x86-64 and macOS Apple Silicon with zero extra dependencies for standalone guard-paged targets, or with Clang for libFuzzer:

# 1. Generate deterministic regression corpus (incl. ARM64 0xff clobber & PSBT heap-OOB seeds) & replay
make -C fuzz replay

# 2. Run a short multi-target smoke fuzz campaign (guard-paged + ABI-poisoned asm & ASan/UBSan C)
make -C fuzz smoke

# 3. Build all 18 BMC-GAUNTLET Clang libFuzzer targets + llvm-cov binaries + ctgrind (Linux x86-64 w/ Core v32.1)
make -C fuzz gauntlet

# 4. Run Valgrind ctgrind constant-time secret-taint verification across all 5 CT secp256k1 ASM routines
valgrind --quiet --error-exitcode=42 fuzz/ctgrind_secp256k1

# 5. Replay x86-64 discovered corpora on macOS Apple Silicon (ARM64 guard pages + x19-x28/d8-d15 ABI poison)
bash fuzz/replay_arm64_cross_isa.sh

# 6. Measure LLVM C-boundary line/branch coverage & refresh docs/Pages ledger
python3 fuzz/measure_coverage.py --corpus-root fuzz/corpus_live
python3 scripts/sync_fuzz_docs.py --stats fuzz/fuzz_stats.json