bmc Bitcoin Machine Code Security Audit
GitHub

Security & 2026-11-27 Full Audit Remediation Report

Complete engineering record of the 2026-11-27 full 8-track code audit (~363,183 LOC / 258 files reviewed) and the Wave 1 + Wave 2 remediation campaign resolving 15/15 CRITICAL, 21/21 HIGH, and 12 high-impact MEDIUM defects across Linux x86-64, macOS Apple Silicon (ARM64), and CUDA.

15 / 15
CRITICAL defects fixed & regression-tested
21 / 21
HIGH finding groups fixed across x86-64, ARM64 & CUDA
12 Fixed
High-impact MEDIUM consensus, HTTP, P2P & storage fixes
483 / 483
Linux x86-64 gate + ASan/UBSan + macOS ARM64 gate PASS
Hardening Highlights (Wave 1 + Wave 2)
  • Zero remote memory-safety bugs left from the audit: Fixed inbound getblocktxn .bss overflow (CRIT-01), script_asm() heap overflow (CRIT-03), node_fetch_headers stack overflow on x86-64/ARM64 (CRIT-04), cons_verify 1 MiB stack overlap (CRIT-02), PSBT/raw-tx bounds overflows (CRIT-05), and uninitialized-stack munmap/close on macOS (CRIT-07, H-15).
  • Consensus, Funds & Mempool Integrity: Fixed P2TR/P2WSH prog32 zero-length bug (CRIT-08), addhdkey xprv corruption & BnB overrun (CRIT-06), mempool duplicate-input / MAX_MONEY checks (CRIT-09), atomic multi-tx package rollback + ephemeral-dust lookup (CRIT-10), Miniscript thresh(>255) (CRIT-11), live fee estimation & BIP133 feefilter wiring (H-01, H-02), and contextual bad-version/BIP94 enforcement on submitted/pushed blocks (H-06).
  • DoS, Privacy & Concurrency: Replaced O(N) chain scan in getblocktxn with O(1) ht_idx lookup + hash verification (H-08), eliminated Tor/proxy clearnet leaks in addr_gather_from & added full SOCKS5 stream isolation (H-10), hardened HTTP framing against request smuggling (MED-09), yielded g_exec_lock + enforced 30s process-group timeout on external signers (H-17), and eliminated multithreaded data races in RPC, Esplora, and MuSig2 (H-16, H-18, MED-10).
  • Storage Durability & Process Safety: Protected store_truncate_to against boundary holes (CRIT-12), fixed store_prune fd mismatch (CRIT-13), deduplicated & fail-closed WAL tombstone reload (H-13), added on-disk tail truncation on reorg (H-14), added Darwin F_FULLFSYNC barriers & hardened macOS compiler flags (H-20), and replaced unsafe SIGCHLD=SIG_IGN waitpid() calls with pipe synchronization (CRIT-14, CRIT-15).

2026-11-29 Formal Verification Campaign (v0.2.1)

Full 4-suite re-verification against v0.2.1 using CBMC 6.11.0 + CaDiCaL, Z3 5.3.1, TLC2 2.19, and angr, expanded with 3 new wallet & PSBT CBMC proofs and a tightened zero-branch constant-time assertion in formal/secp. Full attestation: docs/audits/FORMAL_VERIFICATION_2026-11-29.md.

SuiteSolver / EngineVerified Proofs & ChecksMutantsVerdict
formal/secp x86-64 Symbolic Lifter + Z3 5.3.1 80 / 80 unbounded ASM proofs (incl. 27 / 27 CT proofs with 0 forced branches across sc_split_lambda & GLV avx2/cmov) + 2,342 lifter-vs-CPU runs ct_forced == [] enforced ALL PASS
formal/arith CBMC 6.11.0 + CaDiCaL + Z3 5.3.1 + angr 142 / 142 consensus arithmetic checks (money, locks, pow, limits, scriptnum) vs Bitcoin Core All caught ALL PASS
formal/storage TLC2 2.19 (OpenJDK 21) + Crash Driver 30 / 30 TLA+ configs (80,970,455 distinct states in fixed-ext4-async-n3full) + 42 / 42 test_sto_crash healed 6/6 TLA+ & 6/6 C/ASM ALL PASS
formal/parsers CBMC 6.11.0 + CaDiCaL 19 / 19 bounded proofs (16 existing + 3 new v0.2.1: P-PSBTUPD, P-COINSEL, P-COINSEL-BNB), 100% cover goals, 7 / 7 Core divergences GONE 27 / 27 caught ALL PASS
Real Bugs Caught & Fixed by the 2026-11-29 Formal Campaign
  • FV-2026-11-29-01 (asm/wallet_coinsel.c): CBMC (P-COINSEL) caught a pickcap <= 0 out-of-bounds write to pick[0] and silent subset truncation in wallet_knapsack_select() that returned coin sets with sum < target when selected coins exceeded pickcap. Fixed with strict bounds/overflow checks and lowest_larger fallback; verified by P-COINSEL (7/7 cover, 2/2 mutants caught) and 5 new regression tests in test_coinsel.c (18/18 PASS).
  • FV-2026-11-29-02 (asm/psbt_update.c): Identified missing 1 + n_in + n_out map-terminator byte count in psbt_update_bytes_from_descs() outcap sizing (latent outbuf overrun above 26 empty maps) plus addition-overflow checks in walk_tx() and ar(). Fixed and verified by P-PSBTUPD (10/10 cover, 3/3 mutants caught including the exact v0.2.1 witness_utxo wraparound shape).
  • Zero-Branch CT Exemption Removed (formal/secp/proofs_ct.py): Permanently deleted the obsolete jne <sc_split_lambda.bad> branch exemption after all 27 constant-time x86-64 proofs verified with 0 forced branches.

Complete 2026-11-27 Remediation Ledger

Filter by severity or search by finding ID, file, or subsystem:

ID Severity Wave Component & Files Defect & Remediation Summary Status
CRIT-01CRITICALWave 1asm/bitcoin_serve.asm, port/osx/bitcoin_serve.SInbound getblocktxn compared byte offset against virtual address and truncated indices to 16 bits. Fixed bounds check against 8 MiB capacity with overflow guard and rejected indices ≥ 0x10000.FIXED
CRIT-02CRITICALWave 1asm/bitcoin_cons.asmcons_verify 1 MiB stack buffer overlapped locals and saved rbx. Realigned frame reservation so the 1 MiB scratch sits cleanly below all locals with 16-byte stack alignment.FIXED
CRIT-03CRITICALWave 1asm/rpc_chain.cHeap overflow & size_t underflow via unchecked snprintf truncation in script_asm(). Replaced with checked dynamic buffer growth before every append.FIXED
CRIT-04CRITICALWave 1asm/bitcoind.asm, port/osx/bitcoind.SStack buffer overflow in node_fetch_headers for multi-hash locators (≥3 hashes on ARM64, ≥8 on x86-64). Expanded buffer to ≥1152 bytes and capped locator count ≤ 32.FIXED
CRIT-05CRITICALWave 1asm/rpc_commands.c, asm/rpc_wallet_ops.cStack/.bss overflows and OOB reads in psbt_decode_common, cmd_fundrawtransaction, cmd_signrawtransactionwithkey, and psbt_process. Enforced strict key/tx length bounds everywhere.FIXED
CRIT-06CRITICALWave 1asm/rpc_wallet_ops.c, asm/bitcoin_bip32.asm, port/osx/bitcoin_bip32.S, asm/wallet_bnb.ccmd_addhdkey passed 33-byte key to bip32_extkey_serialize overflowing ser[78] and corrupting xprvs; wallet_bnb_select overran pickcap. Fixed caller, clamped priv keylen ≤ 32, and enforced BnB backtrack at depth limit.FIXED
CRIT-07CRITICALWave 1port/osx/bitcoin_idxscan.S, port/osx/bitcoind.S, port/osx/node_log.SUninitialized stack read & arbitrary close() on openat failure plus Darwin svc #0x80 carry-flag bug in _idxscan_progress. Fixed error branches and carry-flag checks.FIXED
CRIT-08CRITICALWave 1asm/wallet_core.cwallet_validate_address_ex omitted *proglen = 32 for P2TR and P2WSH, leaving caller's prog32 uninitialized. Set *proglen = 32 with capacity check on both paths.FIXED
CRIT-09CRITICALWave 1asm/bitcoin_mempool_policy.cMempool admission lacked duplicate-input and MAX_MONEY / output-sum overflow checks. Added strict duplicate prevout, non-null prevout, per-output ≤ MAX_MONEY, and cumulative sum checks.FIXED
CRIT-10CRITICALWave 1+2asm/bitcoin_mempool_policy.c, asm/daemon/tx_accept.c, asm/daemon/tx_relay.c, asm/daemon/main.cEphemeral dust missed parents staged only in package overlay (Wave 1), and Pass-2 commits lacked rollback (Wave 2). Added package-overlay lookup and reverse-order rollback via tx_accept_rollback_tx().FIXED
CRIT-11CRITICALWave 1asm/miniscript.h, asm/miniscript.cms_node_t.nsubs truncated thresh() counts to uint8_t. Widened nsubs to uint32_t and validated bounds cleanly across Tapscript (>255 subs).FIXED
CRIT-12CRITICALWave 1asm/bitcoin_store.asm, port/osx/bitcoin_store.Sstore_truncate_to wiped the entire block archive when target_height + 1 was an all-zero hole. Added hole detection rejecting truncation cleanly without modifying files.FIXED
CRIT-13CRITICALWave 1asm/bitcoin_store.asm, port/osx/bitcoin_store.Sstore_prune ignored store_set_prune failure and left cur_blk_fd mismatched with cur_file_no. Checked return and closed/reset cur_blk_fd = -1 after compaction.FIXED
CRIT-14CRITICALWave 1asm/daemon/index_trail.cUnder SIGCHLD=SIG_IGN, waitpid() returned ECHILD which reap() treated as success, deleting live tails after crashed builders. Replaced with status pipe verification + target file existence check.FIXED
CRIT-15CRITICALWave 1asm/daemon/notify.cnotify_run() called waitpid() under SIGCHLD=SIG_IGN, blocking the download worker until all children exited. Replaced with CLOEXEC pipe synchronization.FIXED
H-01HIGHWave 1asm/daemon/tx_accept.cg_pol_state_for_fees was assigned before g_pol_state initialized, permanently disabling live estimatesmartfee & BIP133 feefilter. Fixed initialization order.FIXED
H-02HIGHWave 1asm/bitcoin_serve.asm, port/osx/bitcoin_serve.SInbound feefilter command compare matched "ilt\0" instead of "ilte". Corrected compare on both architectures.FIXED
H-03HIGHWave 1asm/bitcoin_net.asmp2p_read_core clobbered fd_read_full return value, ignoring short reads. Preserved and checked return before accepting payload.FIXED
H-04HIGHWave 1asm/rpc_server.c63-byte username truncation in auth_ok() bypassed -rpcwhitelist for ≥64-char usernames. Widened TLS buffer to 256 bytes matching rpcuser[256].FIXED
H-05HIGHWave 1asm/daemon/utxo_live.c, asm/daemon/blk_submit.cPointer-wrap OOB read in val_read_tx and block submission parser. Replaced pointer addition checks with overflow-free remaining-byte checks.FIXED
H-06HIGHWave 1asm/daemon/utxo_live.cSubmitted and pushed blocks bypassed contextual bad-version and BIP94 timewarp rules. Enforced hdr_contextual_ok and hdr_timewarp_ok across all apply paths.FIXED
H-07HIGHWave 1port/osx/bitcoin_cons.SOOB read, non-0x01 SegWit flag acceptance, and 0xff witness count bug on ARM64. Brought into strict parity with x86-64 and Core.FIXED
H-08HIGHWave 2asm/bitcoin_serve.asm, port/osx/bitcoin_serve.SUnauthenticated getblocktxn called node_serve_block_by_hash (full-chain ~1 TB disk scan per unknown hash). Switched to O(1) ht_idx lookup + STO-10 header-hash verification.FIXED
H-09HIGHWave 1asm/bitcoind.asm, port/osx/bitcoind.SUnchecked -1 return from p2p_headers_count in node_sync_multi. Added signed < 0 rejection on both architectures.FIXED
H-10HIGHWave 2asm/daemon/addr_ingest.c, asm/daemon/dialer.caddr_gather_from() bypassed -proxy/-onlynet (clearnet IP leak), and proxied IPv6/CJDNS/DNS dials omitted SOCKS5 stream isolation. Routed through dialer_connect and enforced dialer_isolation_creds on all proxied paths.FIXED
H-11HIGHWave 1asm/rpc_server.c, asm/daemon/main.cStale BIP324 v2 cipher state on fd reuse and leaked Esplora/RPC listener FDs across fork(). Added bmc_v2_close on teardown, FD_CLOEXEC, and child close of g_esp_fd.FIXED
H-12HIGHWave 1asm/daemon/tx_accept.cHard-coded 512-input cap failed open in txacc_sigop_cost and txacc_witness_standard. Replaced with dynamic allocation supporting arbitrarily many inputs.FIXED
H-13HIGHWave 2asm/bitcoin_utxo_lsm.asm, port/osx/bitcoin_utxo_lsm.Sutxo_lsm_reload appended duplicate WAL tombstones and silently dropped/aborted past tomb_cap (resurrecting spent UTXOs). Added probe-first deduplication and fail-closed -1 return on overflow.FIXED
H-14HIGHWave 1+2asm/daemon/bfilter_index.c, asm/daemon/tx_index_tail.c, asm/daemon/txosp_tail.cReorg closed bfilter fd before truncating (Wave 1), and txindex.tail / txospender.tail left stale post-reorg records on disk (Wave 2). Added atomic on-disk tail truncation on reorg and boot.FIXED
H-15HIGHWave 2port/osx/bitcoin_store_fast.S_store_map_init / _store_map_close called munmap() on uninitialized slots without checking MAP_MAGIC. Added MAP_MAGIC verification before unmapping.FIXED
H-16HIGHWave 1+2asm/rest.c, asm/rpc_chain.c, asm/rpc_node.cFixed unauth POST /rest/getutxos.hex 4.5 MB/req leak (Wave 1); eliminated data races in opname() (const table), g_pri[] (g_pri_mu mutex + snapshot), and cmd_abortprivatebroadcast (stack buffer).FIXED
H-17HIGHWave 2asm/rpc_signer.c, asm/rpc_signer.hExternal signer blocked indefinitely while holding exclusive g_exec_lock. Yielded g_exec_lock under dedicated g_signer_mu, isolated signer in own process group, and enforced 30s poll() timeout + SIGTERM/SIGKILL cleanup.FIXED
H-18HIGHWave 1+2asm/rpc_wallet_ops.c, asm/musig2.c, asm/musig2.h, asm/wallet_core.cWiped g_hdk on wallet switch/unload (Wave 1); moved MuSig2 buffers off static .bss onto stack, wiped all MuSig2/BIP39 secret intermediates, and added musig2_secnonce_wipe() (Wave 2).FIXED
H-19HIGHWave 1asm/rpc_commands.c, asm/bip32_ckdpub.c, asm/wallet_msgsign.c, asm/rpc_wallet_ops.cFixed BIP143 SIGHASH_SINGLE bug, msg_digest stack overflow, CRY-2 borrow-wrap & x==p checks, and enforced 0600 O_NOFOLLOW + fsync on wallet backups.FIXED
H-20HIGHWave 1+2port/osx/bitcoind.S, port/osx/build_*.sh, port/osx/run_tests.sh, asm/cuda/*.cu, asm/bmc_fsync.hFixed ARM64 IBD slot aliasing, added -fstack-protector-strong -D_FORTIFY_SOURCE=2, set -o pipefail, CUDA BIP340/SHA256 bounds/math fixes (Wave 1), and Darwin F_FULLFSYNC durability helper (Wave 2).FIXED
H-21HIGHWave 1+2asm/daemon/node_config.c, asm/daemon/zmq_notify.c, asm/daemon/main.cRejected out-of-range par= values, advanced lapped ZMQ sequence cursors (Wave 1), and invoked zmqpub_close() on worker shutdown (Wave 2).FIXED
MED-01MEDIUMWave 2asm/daemon/tx_verify.cFixed dangling g_txv_in pointer if first realloc() succeeded and second failed by committing each capacity update atomically.FIXED
MED-02MEDIUMWave 2asm/daemon/tx_verify.cAdded fork-PID guard in txvb_pool_ensure() so forked children spawn fresh script-verify threads instead of deadlocking on dead parent handles.FIXED
MED-03MEDIUMWave 2asm/daemon/tx_verify.cGuarded tx_legacy_sigops() < 0 against unsigned (u64)(-1) * 4 wrap, failing closed above MAX_BLOCK_SIGOPS_COST.FIXED
MED-04MEDIUMWave 2asm/daemon/mempool_cfg.cmp_lock_at() now fails loudly and aborts on non-EOWNERDEAD mutex errors (ENOTRECOVERABLE/EINVAL) instead of running unprotected.FIXED
MED-05MEDIUMWave 2asm/daemon/fee_estimator.cFixed unsigned bin underflow when height < confct on early blocks, and added isfinite() + non-negative validation when loading fee_estimates.dat.FIXED
MED-07MEDIUMWave 2asm/daemon/banlist.cReplaced fixed 64 KiB read buffer in banlist_load() with dynamic fstat() + malloc() (up to 16 MiB) so large banlists never truncate.FIXED
MED-08MEDIUMWave 2asm/daemon/cmpct_recv.cCopied mempool-matched transactions into S.pre (8 MiB) inside cmpct_recv_cmpctblock() so pointers cannot dangle into compactable shared mempool blobs across getblocktxn round trips.FIXED
MED-09MEDIUMWave 2asm/rpc_server.cAdded strict parse_content_length() rejecting Transfer-Encoding, duplicate Content-Length, negative/non-numeric/oversize lengths with 400 Bad Request on both RPC and Esplora listeners.FIXED
MED-10MEDIUMWave 2asm/rpc_esplora.cAdded g_mp_refreshing re-entrancy guard around mp_refresh_locked() across lock releases and NULL checks on all realloc() calls.FIXED
MED-11MEDIUMWave 2asm/utxo_lsm_mm.cRegistered a pthread_key destructor (mm_thread_dtor) to cleanly munmap() and close() per-thread LSM run cache slots on thread exit.FIXED
MED-12MEDIUMWave 2asm/daemon/main.cExpanded four 162 KB tx_txid scratch buffers in the worker submit loop to 1 MiB so large valid transactions never fail txid hashing.FIXED
MED-13MEDIUMWave 2scripts/makefile_prereq_audit.pyAuto-detects GNU Make ≥ 4.0 (gmake on macOS) and fails loudly instead of silently passing with 0 rules checked under GNU Make 3.81.FIXED

Cross-Platform Verification Matrix

Platform / GateChecks ExecutedResult
Static Auditorsabi_stack_audit --external-only (482 fns), abi_callee_saved_audit (482 fns), makefile_prereq_audit (629 rules), makefile_runlist_audit (487 sources / 474 gated), log_literal_len_checkALL PASS
Linux x86-64 Full Gatemake -C asm test + gate-log-check at commit 025a5e16 (483 gated tests, ASan+UBSan san-check, link-check, script-flags-check vs Core v31.1, 16-check test_audit_2026_11_27)483/483 PASS
macOS Apple Silicon GateHardened -Wall -Werror -fstack-protector-strong -D_FORTIFY_SOURCE=2 daemon + 18 tools + 6 helpers + port/osx/run_tests.sh455 PASS / 0 FAIL
Live Mainnet Production NodeAtomic deploy (commit 025a5e16, bmc_build_dirty: false), synced at mainnet tip 977,862 (warnings: []), mempool loaded (12,905 txs, optimal: true), live estimatesmartfee 6 = 0.00002226VERIFIED LIVE

Continuous Fuzzing Ledger & Audit History

Continuous Fuzzing Attestation (Full Fuzzing Page · docs/audits/FUZZING_ATTESTATION.md)
As of 2026-11-28 (commit 579e9b61), the 24/7 bmc-fuzz.service runner has logged 248.70 billion (248,702,148,162) mutated executions across 7 targets (guard-paged x86-64 NASM, ASan/UBSan C, and 36.44 billion in-process Bitcoin Core v31.1 EvalScript differential comparisons) with 0 crashes and 0 consensus mismatches. Cumulative totals are persisted atomically in fuzz/fuzz_stats.json and rendered via fuzz/record_fuzz_stats.py into docs/audits/FUZZING_ATTESTATION.md. See Continuous Fuzzing & Assembly Validation for architecture diagrams, per-target rates, caught ARM64 bugs, and honest scope limits.
  • 2026-11-29 (v0.2.1 Formal Verification): Full 4-suite re-verification (formal/secp 80/80 PROVED with 0 forced CT branches, formal/arith 142/142 PASS, formal/storage 30/30 TLC2 + 42/42 real-code crash tests + 6/6 mutants, formal/parsers 19/19 CBMC proofs + 27/27 mutants + 7/7 Core divergences GONE), adding 3 new wallet/PSBT CBMC proofs (P-PSBTUPD, P-COINSEL, P-COINSEL-BNB) and fixing FV-2026-11-29-01 (wallet_knapsack_select OOB/truncation) and FV-2026-11-29-02 (psbt_update map-terminator sizing). Full report: docs/audits/FORMAL_VERIFICATION_2026-11-29.md.
  • 2026-11-28 (v0.1.0): Shipped assembly-first continuous hardening infrastructure — AArch64 static ABI/syscall auditor (scripts/arm64_abi_audit.py), checked assembly cursor macros (asm/macros_safe.inc, port/osx/macros_safe.inc), dual-arch consensus spec codegen (scripts/gen_consensus_inc.py), 7-target guard-paged assembly + ASan/UBSan C + 2.06M exec/s in-process Core v31.1 differential script fuzzer (fuzz/, running 24/7 via bmc-fuzz.service), and cross-platform GitHub Actions CI + checksummed 3-platform release pipeline. Immediately caught and fixed 2 additional real ARM64 assembly bugs in port/osx/bitcoin_tx.S (transient 8-byte SP misalignment + remote 0xff CompactSize x9-clobber SIGSEGV).
  • 2026-11-27: Full 8-track code audit (258 files / 363k LOC) & Wave 1 + Wave 2 remediation (15/15 CRITICAL, 21/21 HIGH, 12 MEDIUM fixed; regression suite asm/tests/test_audit_2026_11_27.c).
  • 2026-10-23: Security review & formal verification across 4 areas (9 HIGH, 18 MEDIUM, 36 LOW fixed in PRs #424–#435; verified by from-genesis MuHash parity sync at height 972,848).
  • 2026-09-03: Full codebase audit & remediation (docs/audits/AUDIT_2026-09-03_REMEDIATION.md).
  • 2026-08-29 – 2026-09-02: Initial security & P2P/RPC hardening audits (docs/audits/SECURITY_AUDIT_2026-08-29.md, SECURITY_AUDIT_2026-09-02.md).

Vulnerability Disclosure

Report security vulnerabilities privately via the repository's GitHub Security tab (“Report a vulnerability”). Never post private keys, wallet files, seeds, .cookie credentials, or Tor/I2P keys in public issues or pull requests. See SECURITY.md in the repository root for full scope and disclosure guidelines.