From c4951723bd15a1aeb3cf7b97bcbe2c83cad0cd98 Mon Sep 17 00:00:00 2001 From: Shuvam Pandey Date: Fri, 16 Oct 2026 18:27:42 +0545 Subject: [PATCH 1/7] Test that Floor reads only a config it wrote and a buffer the loader owns Three checks survived deletion with every program test green (tasks/error-codes-floor/mutants.log, base 43bfa31, full program suite): lib.rs:179, load_config's "Floor owns the config"; state.rs:132, Config::load's length and discriminator; and loader.rs:14, check_frozen_buffer's "the loader owns the buffer". No test sent Floor a copy of its own account under another owner, or an account Floor owns but never wrote, and the substitution sweep only swaps in real accounts. What each guards, seen with the check deleted (STATE=c1, and r5c1 on the final test): F01 lib.rs:179: a copy of a program's config under another owner, naming a thief as the owner and no abort buffer staged, is read as the config. close_buffer never writes the config, so the loader closes the REAL staged abort buffer (frozen to the real Floor authority) and pays its rent to the thief ("Closed Buffer ..." in test-c1-F01.log). The real config still names the closed buffer, so every stop fails until a live quorum stages another. F02 state.rs:132: anyone can create an account Floor owns (a system CreateAccount assigns it, without Floor). A zero-filled one of a config's length, created by the thief, is read as a config, and a heartbeat naming it is refused only later, as 7014 NotLiveGuardian. F13 loader.rs:14: a byte-identical copy of the pinned snapshot under its writer is pinned, a buffer the loader could never install. New test floor_reads_only_a_config_it_wrote_and_a_buffer_the_loader_ owns: the forged config's close -> NOT_A_FLOOR_CONFIG; the heartbeat on the thief's zero-filled Floor account -> NOT_A_FLOOR_CONFIG; pinning the copied snapshot -> NOT_LOADER_V3. Helper copy_under copies an account to a fresh address under another owner. Evidence (tasks/error-codes-floor/mutants.log, STATE=c1 and r5c1, full program suite): F01, F02 and F13 KILLED by the new test; all three SURVIVED at base. Floor hash 8ca8a608 unchanged (tests only). The run's base, 43bfa31, is a commit of the earlier vault-error-tests-r3 branch, not of this history; its programs and core equal this commit's (git diff --stat 43bfa31 HEAD -- programs/floor/src programs/vault/src programs/harbor/src crates/: empty). Counts: Floor 50 -> 51, programs 165 -> 166 (claims.py OK). Co-Authored-By: Claude Opus 5.5 --- README.md | 4 +- docs/04-THREAT-MODEL.md | 2 +- docs/09-VERIFICATION.md | 4 +- programs/tests/tests/common/mod.rs | 2 + programs/tests/tests/floor.rs | 60 ++++++++++++++++++++++++++++++ 5 files changed, 67 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 128368d..31d284b 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Bulkhead is a small Solana program that holds a protocol's token accounts on the **[The attack](#what-it-does-to-an-attack)** · **[How it works](#how-it-works)** · **[Verify it](#verify-it-yourself)** · **[Devnet](#live-on-devnet)** · **[FAQ](docs/FAQ.md)** · **[Docs](#documentation)** -[![CI](https://github.com/shuv-amp/bulkhead/actions/workflows/ci.yml/badge.svg)](https://github.com/shuv-amp/bulkhead/actions/workflows/ci.yml) [![devnet](https://img.shields.io/badge/devnet-live-57606A?style=flat-square)](#live-on-devnet) [![Kani](https://img.shields.io/badge/Kani_proofs-19%2F19-57606A?style=flat-square)](docs/09-VERIFICATION.md) [![tests](https://img.shields.io/badge/program_tests-165%2F165-57606A?style=flat-square)](docs/09-VERIFICATION.md) [![audit](https://img.shields.io/badge/audit-not_yet,_not_for_real_funds-E5481B?style=flat-square)](SECURITY.md) [![license](https://img.shields.io/badge/license-Apache--2.0-57606A?style=flat-square)](LICENSE) +[![CI](https://github.com/shuv-amp/bulkhead/actions/workflows/ci.yml/badge.svg)](https://github.com/shuv-amp/bulkhead/actions/workflows/ci.yml) [![devnet](https://img.shields.io/badge/devnet-live-57606A?style=flat-square)](#live-on-devnet) [![Kani](https://img.shields.io/badge/Kani_proofs-19%2F19-57606A?style=flat-square)](docs/09-VERIFICATION.md) [![tests](https://img.shields.io/badge/program_tests-166%2F166-57606A?style=flat-square)](docs/09-VERIFICATION.md) [![audit](https://img.shields.io/badge/audit-not_yet,_not_for_real_funds-E5481B?style=flat-square)](SECURITY.md) [![license](https://img.shields.io/badge/license-Apache--2.0-57606A?style=flat-square)](LICENSE)
@@ -165,7 +165,7 @@ These scripts install nothing. The core has zero dependencies, and Cloud and the | Check | Result (latest run of each) | |---|---| -| **Programs on the real runtime**
LiteSVM, mainnet feature set, mainnet token program | **165/165**: every scenario (S1 Drift, S4 bank run, S7, S8, S9, S10 Floor), the negative tests, measured compute, and an account-substitution sweep of every instruction (7,075 swaps refused, 16 Oct) | +| **Programs on the real runtime**
LiteSVM, mainnet feature set, mainnet token program | **166/166**: every scenario (S1 Drift, S4 bank run, S7, S8, S9, S10 Floor), the negative tests, measured compute, and an account-substitution sweep of every instruction (7,075 swaps refused, 16 Oct) | | **Bounded proofs**
Kani, and exhaustive checks | **19/19 harnesses verified** on 16 Oct (16 for every value of their types), 240 s of verification ([`09 §5`](docs/09-VERIFICATION.md#5-bounded-proofs-kani-and-exhaustive-checks)). 6 exhaustive tests over ~584M inputs | | **Differential**
an independent Python reference vs the Rust core | **6,943,561 lines identical** (6 seeds × 200k cases, 27 Sep); 33 commands now, 300k cases on every pull request and 3M weekly in CI | | **Program vs model** | Random steps on-chain, every outcome equal to the core's prediction: 12,000 (Vault), 300,000 with random limits and every brake (Vault), 200,000 (Floor) | diff --git a/docs/04-THREAT-MODEL.md b/docs/04-THREAT-MODEL.md index c4d2f36..ce83cc2 100644 --- a/docs/04-THREAT-MODEL.md +++ b/docs/04-THREAT-MODEL.md @@ -71,7 +71,7 @@ A security product with a bug is worse than no product. This file lists every ad | I12 | No token leaves a vault except release, settle, lifeboat | program-vs-model differential (vault balance equals the model after every step) | | I13 | Releases fail before the seal | program `nothing_can_be_released_before_the_seal…` | | I14 | `vault.queued_amount == Σ pending tickets` | program-vs-model differential, after every step | -| I15 | Floor: no new binary before 72h unless a quorum approved that exact frozen buffer during a restore, or the snapshot is restored | 50 Floor tests on the real loader (`programs/tests/tests/floor.rs`) | +| I15 | Floor: no new binary before 72h unless a quorum approved that exact frozen buffer during a restore, or the snapshot is restored | 51 Floor tests on the real loader (`programs/tests/tests/floor.rs`) | | I16 | Python reference and Rust core agree on every input | diff (6,943,561 identical lines in the final 6-seed run; 36 fixtures with expected outputs) | ## 4. The #1 risk: a bug in Bulkhead itself diff --git a/docs/09-VERIFICATION.md b/docs/09-VERIFICATION.md index 63e3440..383938e 100644 --- a/docs/09-VERIFICATION.md +++ b/docs/09-VERIFICATION.md @@ -31,7 +31,7 @@ The programs are checked against the core as a model (§7). Two implementations | **Bounded proofs (Kani)** | 19 harnesses: logic at full width, 3 at small width (§5) | **19/19 verified** (16 Oct) | | **Coverage-guided fuzzing** | 9 libFuzzer targets (`fuzz/`, cargo-fuzz, overflow checks and AddressSanitizer on): the Token-2022 mint policy, the token-account reader and the guardian-set parser Floor and the Vault share against independent statements of them; the Pyth `PriceUpdateV2` parser against the documented layout; load-store-load round trips of every Vault and Floor account; the loader-v3 parsers and snapshot identity; the limiter at full width (exact `available_now`, instant and queue rules, errors change nothing, window changes keep the used fraction); the ledger (backed ≤ requested, the same amount on a re-ask, `debit_backed` accepts it). Line coverage is measured (`cargo fuzz coverage`); seeds in `fuzz/seeds/` reach what a mutator rarely builds | 6 Oct: 10 min per target, 36M–277M executions each; one harness-oracle crash (finding 40), no program bug; every targeted parser at 100% of lines after the seeds (finding 41; but the same loader target never got past `elf_info`'s magic check in 417M runs on 17 Oct, below). That run had 8 targets; the guardian-set target came on 14 Oct. 17 Oct (`SECONDS_PER=1800 scripts/fuzz.sh`, all 9 targets at once): 30 min per target, 125M–440M executions each (the guardian-set target's 259M), no crash; the two targets changed after it (below) have run 120 s each since, no crash. Region coverage of that corpus (`llvm-cov`, measured by hand) found, among other missed regions, two parsers that their own target never fully ran. Line coverage hid one: the guardian-set target could not build an empty set (every line, 60 of 61 regions). The other is in the loader-parser target, which finding 41's change left decoding its input with `arbitrary` (that finding's cause) and without seeds: no input got past `elf_info`'s ELF magic check. After a fix to the guardian-set target, and the loader target moved to raw bytes with four ELF-header seeds, their corpora and seeds run `GuardianSet::parse` and `elf_info` at every line and region (`llvm-cov` after 120 s runs, 17 Oct); the loader target now catches a mutant (`elf_info` reading past a short header) within seconds, even unseeded, that 45M runs of the old one missed. It checks only `snapshot_matches`' result and runs the other parsers for panics only (`elf_info`'s values are checked by golden G-13 and the property and unit tests). The other regions the targets miss in the functions they call are not listed here in full: some are unreachable, and some are refusals no harness asks for, which the fuzzing does not test (a closed limiter lane: the target makes every capacity at least 1; a full ledger: the ledger target uses at most 4 distinct mints). No target calls `elf_extent`, `snapshot_restorable` (finding 88's length rule) or `is_canonical_abort`: unit tests and the core's mutation testing (§6) check them (`is_canonical_abort` also the differential's `FC` command), the fuzzer does not. CI: 60 s per target (25 min weekly, §8) | | **Mutation testing** | `cargo-mutants` on the core: 797 mutants (run 10, §6), and in CI on every pull request's changed lines | Every non-equivalent mutant killed; 22 equivalents, each explained and excluded by exact pattern | -| **Program tests** | Floor (50) and Vault (115) on the real agave runtime: LiteSVM, mainnet feature set, the mainnet token program | 165/165 | +| **Program tests** | Floor (51) and Vault (115) on the real agave runtime: LiteSVM, mainnet feature set, the mainnet token program | 166/166 | | **Account substitution** (`programs/tests/tests/common/sweep.rs`) | For every Vault and Floor instruction (all 30 of the Vault's, tags 0–29, including the read-only views `attest` and `quote_release` and both scopes of `unfreeze`; registration both by the caller PDA and by the upgrade authority; the Floor lifecycle end to end): a transaction that succeeds, then each account swapped in turn for a fresh address, every other account of the transaction, a second market's or a second protected program's accounts, a stranger's token accounts and buffers, other tickets, programs and sysvars, and for a signer every other known key; then each key that signs at any slot (a free one included) and stands at a checked slot: unsigned at every checked slot (a free slot where it signed gets the payer, once a control shows the payer is accepted there; not for the fee payer, which signs anyway), since signing is per key and unsigning one slot of a key that signs at another proves nothing. A key at several slots is otherwise swapped one slot at a time, so a check that only compares those slots with each other is not tested by a consistent attacker key at all of them. Every swap must fail, except at the positions each program leaves free on purpose, each listed with its reason (a rent payer, a ticket account only used when part of a release queues, another guardian of the same set). The first version missed two of four bugs planted to test it (a settle that pays anyone, a cancel of another vault's ticket): it had no look-alike token account or ticket to offer. With them, all four are caught | 16 Oct, with four guardians in the test sets (finding 107; an eject's signers may now be any two of the three others, so each of those slots is free for the third, never for the target or the other signer again; with a guardian listed twice counted as two, the sweep fails): 5,365 Vault and 1,710 Floor substitutions (37 and 18 transactions), refused. 16 Oct, with `attest`, `quote_release` (read-only accounts, quoting an owner's own deposit; as in every release here, the price slot is left free) and the vault-scope `unfreeze`: 5,308 Vault and 1,683 Floor substitutions (37 and 18 transactions), refused. Each of three one-site mutants fails the sweep and passes without those three runs: `attest` not checking its token account, a quote skipping the vault-account check a release makes, and the vault-scope `unfreeze` loading a vault without checking its protocol. 16 Oct, with signing keys tried per key (before, a key that signs at two slots was never tried unsigned: the user of Harbor's deposit and withdraw; with the withdraw's signer check deleted, the sweep now fails): 4,887 Vault and 1,683 Floor substitutions (34 and 18 transactions; one of the 34, "withdraw (signed at the free slot only)", repeats Harbor's withdrawal with the user signing only at a free slot, which adds no program coverage; the test checks that the user was tried unsigned there, so it fails if the sweep stops picking such a key), refused. 10 Oct, with a release to none signed by the owner (finding 95; with that check deleted, the sweep accepts the owner unsigned and fails): 4,499 Vault and 1,683 Floor substitutions (33 and 18 transactions), refused (9 Oct, with `close_buffer`, the signing release and the exit's account 6: 4,508 and 1,549; 8 Oct: 4,474 and 1,472). Found finding 53. Accepted and explained: a veto of a lifeboat exit where none is pending changes nothing (the next proposal clears it) | | **Program ↔ model differential** | Random operation sequences on-chain vs a host model built only from the core; invariants after every step (§7) | 12,000 steps across 24 seeds, identical; 24,000 steps across 24 seeds after the A1 fix (29 Sep), identical | | **Wide program differential** | The same, with a limit configuration drawn per seed (floors and caps far above the balance, a closed lane, a queue delay past the horizon) and every instruction that changes what can leave: protocol and vault freezes, quorum unfreezes, ticket extensions, backlog resets, lifeboat moves both ways, limit changes; `quote_release` against the release, every `attest` field against the core (§7) | 5 Oct: 200,000 steps across 400 configurations, then 100,000 with limit changes after finding 30, identical | @@ -84,7 +84,7 @@ scripts/mutants.sh # mutation testing, release profile (~45 scripts/fuzz.sh # libFuzzer, every target 60 s in parallel (SECONDS_PER=600 for longer) (cd fuzz && cargo clippy --all-targets -- -D warnings) # lint the fuzz crate (its own workspace; CI's fuzz job) scripts/build-programs.sh # Floor, Vault, Harbor for sBPF v3; checks e_flags == 3 -(cd programs/tests && cargo test --release) # 165 program tests + the program-vs-model differentials +(cd programs/tests && cargo test --release) # 166 program tests + the program-vs-model differentials (cd programs/tests && BULKHEAD_PROGRAM_SEEDS=24 BULKHEAD_PROGRAM_STEPS=500 cargo test --release --test differential) cloud/e2e/run.sh # validator + guardian + attacker node --test cloud/test/*.test.mjs # client, policy, JS vs Python vs Rust differential (needs the worker) diff --git a/programs/tests/tests/common/mod.rs b/programs/tests/tests/common/mod.rs index 430f524..5add98e 100644 --- a/programs/tests/tests/common/mod.rs +++ b/programs/tests/tests/common/mod.rs @@ -32,6 +32,8 @@ pub const T0: i64 = 1_790_000_000; // a fixed start time (Sep 2026) /// Floor error codes (programs/floor/src/error.rs), checked by the tests. pub mod err { pub const INVALID_INSTRUCTION: u32 = 7000; + pub const NOT_A_FLOOR_CONFIG: u32 = 7001; + pub const NOT_LOADER_V3: u32 = 7005; pub const NOT_CURRENT_AUTHORITY: u32 = 7007; pub const INVALID_GUARDIANS: u32 = 7008; pub const INVALID_THRESHOLD: u32 = 7009; diff --git a/programs/tests/tests/floor.rs b/programs/tests/tests/floor.rs index 11f48e0..238eb09 100644 --- a/programs/tests/tests/floor.rs +++ b/programs/tests/tests/floor.rs @@ -1711,3 +1711,63 @@ fn the_config_layout_matches_what_off_chain_readers_decode() { assert_eq!((k(852), d[884]), (c.recovery, c.pending_by_recovery)); } } + +/// A copy of `real`'s account at a fresh address, under `owner`, with `edit` +/// applied to its data. +fn copy_under( + env: &mut Env, + real: &solana_address::Address, + owner: solana_address::Address, + edit: impl FnOnce(&mut Vec), +) -> solana_address::Address { + let mut a = env.account(real); + a.owner = owner; + edit(&mut a.data); + let at = solana_address::Address::new_unique(); + env.svm.set_account(at, a).unwrap(); + at +} + +/// Floor trusts a config only if Floor owns it and wrote it, and a buffer +/// only if the loader owns it. A copy of either under another owner is +/// refused, whatever its bytes say. `close_buffer` never writes the config +/// it reads, so without the owner check a copy naming a stranger as the +/// owner, with no abort buffer staged, would let that stranger close the real +/// abort buffer, which is frozen to the real Floor authority, and take its +/// rent. The real config would still name the closed buffer, so every stop +/// would fail until a live quorum staged another. And anyone can create an +/// account Floor owns (the system program assigns it without Floor), so a +/// config Floor owns must also carry Floor's discriminator. +#[test] +fn floor_reads_only_a_config_it_wrote_and_a_buffer_the_loader_owns() { + let mut env = Env::new(); + let p = protect(&mut env, &honest_v1()); + let f = &p.f; + let thief = Keypair::new(); + env.fund(&thief); + let forged = copy_under(&mut env, &f.config, solana_address::Address::new_unique(), |d| { + let mut c = bulkhead_floor::Config::load(d).unwrap(); + c.owner = thief.pubkey().to_bytes(); + c.abort_buffer = [0; 32]; + c.store(d).unwrap(); + }); + let mut close = f.close_buffer(&thief.pubkey(), &p.abort_buffer); + close.accounts[0].pubkey = forged; + assert_eq!(env.fails(&[close], &[&thief]), err::NOT_A_FLOOR_CONFIG); + + // A zero-filled account of a config's length, created for Floor by a + // stranger's own CreateAccount. + let blank = Keypair::new(); + let len = env.account(&f.config).data.len(); + let rent = env.svm.minimum_balance_for_rent_exemption(len); + let create = solana_system_interface::instruction::create_account(&thief.pubkey(), &blank.pubkey(), rent, len as u64, &env.floor); + env.ok(&[create], &[&thief, &blank]); + let mut beat = f.heartbeat(&p.g[0].pubkey()); + beat.accounts[0].pubkey = blank.pubkey(); + assert_eq!(env.fails(&[beat], &[&p.g[0]]), err::NOT_A_FLOOR_CONFIG); + + // A byte-identical copy of the pinned snapshot, under its writer: the + // loader could never install it, so a stop naming it could not restore. + let fake_pin = copy_under(&mut env, &p.snapshot, thief.pubkey(), |_| {}); + assert_eq!(env.fails(&[f.pin_snapshot(&fake_pin)], &[]), err::NOT_LOADER_V3); +} From 8308a7fa736c34ed3b6260825e9be2717413a8d3 Mon Sep 17 00:00:00 2001 From: Shuvam Pandey Date: Fri, 16 Oct 2026 18:28:05 +0545 Subject: [PATCH 2/7] Test that registration reads only the program's own programdata Three registration checks survived deletion with every program test green (tasks/error-codes-floor/mutants.log, base 43bfa31): register.rs:63, "the program names this programdata", register.rs:58, "the loader owns the program and the programdata", and register.rs:69, "the programdata has a header". Registration takes the upgrade authority from that programdata, so these are what make the signer the program's own authority. Seen with each check deleted (STATE=r2c2), or for :69, whose code is a value, changed to another code: F07 register.rs:63: a thief registers another team's program with the thief's own programdata, of which the thief holds the key. It SUCCEEDS: the loader moves the thief's programdata to Floor, and the config at the team's program address is the thief's. The team could never register. F06 register.rs:58 (and F06a, the program clause of :57 alone): a copy of the team's program account under another owner, naming the thief's real programdata, is registered. It SUCCEEDS: a config for an address the loader never deployed, holding the thief's programdata. F08 register.rs:69: the program's upgrade authority closes the programdata with the loader and registers, in one transaction. A closed programdata stays loader-owned until the transaction ends, and the program still names it, so :57 and :63 pass and :69 is the check that refuses (found by B's review of r5, probe tasks/review-floor-error-tests-r5/zz_probe_b.rs). With :69 mapped to InvalidInstruction (F08) or Overflow (F08o), the registration fails with that code instead of PROGRAM_MISMATCH. Across two transactions the programdata is gone and :57 refuses first (NOT_LOADER_V3), so only the same-transaction case reaches :69. F06b, the programdata clause of :57 alone, SURVIVES, and the test's comment says so: a program the loader owns names its own programdata, which the loader owns too, so :63 refuses any other. Covered only jointly. New test registration_reads_only_the_programs_own_programdata: the thief's programdata -> PROGRAM_MISMATCH; the copied program -> NOT_LOADER_V3; the team's Close then register in one transaction, for both forms of the close (SIMD-0432 tombstone false and true) -> PROGRAM_MISMATCH at instruction 1; then the team registers, and Floor holds its key (the failed transactions undid the closes). copy_under now clears `executable`: LiteSVM refuses an executable account no loader owns, and a copied program needs it off. Evidence (tasks/error-codes-floor/mutants.log, STATE=r2c2, full program suite): F06, F06a, F07 KILLED by the new test; F06 and F07 SURVIVED at base; F06b SURVIVED (joint, above). F08 and F08o (tasks/floor-error-tests-r6/mutants.log, full program suite): KILLED by the new test alone at STATE=r6wip (Floor 56 passed / 1 failed, Vault 115 passed; "left: InstructionError(1, Custom(7034)) right: InstructionError(1, Custom(7006))" for F08o), and both SURVIVED with the test file as it was before this case (STATE=r6parent). Floor hash 8ca8a608 unchanged. Counts: Floor 51 -> 52, programs 166 -> 167 (claims.py OK). Co-Authored-By: Claude Opus 5.5 --- README.md | 4 +- docs/04-THREAT-MODEL.md | 2 +- docs/09-VERIFICATION.md | 4 +- programs/tests/tests/common/mod.rs | 1 + programs/tests/tests/floor.rs | 75 +++++++++++++++++++++++++++++- 5 files changed, 80 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 31d284b..6324d2a 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Bulkhead is a small Solana program that holds a protocol's token accounts on the **[The attack](#what-it-does-to-an-attack)** · **[How it works](#how-it-works)** · **[Verify it](#verify-it-yourself)** · **[Devnet](#live-on-devnet)** · **[FAQ](docs/FAQ.md)** · **[Docs](#documentation)** -[![CI](https://github.com/shuv-amp/bulkhead/actions/workflows/ci.yml/badge.svg)](https://github.com/shuv-amp/bulkhead/actions/workflows/ci.yml) [![devnet](https://img.shields.io/badge/devnet-live-57606A?style=flat-square)](#live-on-devnet) [![Kani](https://img.shields.io/badge/Kani_proofs-19%2F19-57606A?style=flat-square)](docs/09-VERIFICATION.md) [![tests](https://img.shields.io/badge/program_tests-166%2F166-57606A?style=flat-square)](docs/09-VERIFICATION.md) [![audit](https://img.shields.io/badge/audit-not_yet,_not_for_real_funds-E5481B?style=flat-square)](SECURITY.md) [![license](https://img.shields.io/badge/license-Apache--2.0-57606A?style=flat-square)](LICENSE) +[![CI](https://github.com/shuv-amp/bulkhead/actions/workflows/ci.yml/badge.svg)](https://github.com/shuv-amp/bulkhead/actions/workflows/ci.yml) [![devnet](https://img.shields.io/badge/devnet-live-57606A?style=flat-square)](#live-on-devnet) [![Kani](https://img.shields.io/badge/Kani_proofs-19%2F19-57606A?style=flat-square)](docs/09-VERIFICATION.md) [![tests](https://img.shields.io/badge/program_tests-167%2F167-57606A?style=flat-square)](docs/09-VERIFICATION.md) [![audit](https://img.shields.io/badge/audit-not_yet,_not_for_real_funds-E5481B?style=flat-square)](SECURITY.md) [![license](https://img.shields.io/badge/license-Apache--2.0-57606A?style=flat-square)](LICENSE)
@@ -165,7 +165,7 @@ These scripts install nothing. The core has zero dependencies, and Cloud and the | Check | Result (latest run of each) | |---|---| -| **Programs on the real runtime**
LiteSVM, mainnet feature set, mainnet token program | **166/166**: every scenario (S1 Drift, S4 bank run, S7, S8, S9, S10 Floor), the negative tests, measured compute, and an account-substitution sweep of every instruction (7,075 swaps refused, 16 Oct) | +| **Programs on the real runtime**
LiteSVM, mainnet feature set, mainnet token program | **167/167**: every scenario (S1 Drift, S4 bank run, S7, S8, S9, S10 Floor), the negative tests, measured compute, and an account-substitution sweep of every instruction (7,075 swaps refused, 16 Oct) | | **Bounded proofs**
Kani, and exhaustive checks | **19/19 harnesses verified** on 16 Oct (16 for every value of their types), 240 s of verification ([`09 §5`](docs/09-VERIFICATION.md#5-bounded-proofs-kani-and-exhaustive-checks)). 6 exhaustive tests over ~584M inputs | | **Differential**
an independent Python reference vs the Rust core | **6,943,561 lines identical** (6 seeds × 200k cases, 27 Sep); 33 commands now, 300k cases on every pull request and 3M weekly in CI | | **Program vs model** | Random steps on-chain, every outcome equal to the core's prediction: 12,000 (Vault), 300,000 with random limits and every brake (Vault), 200,000 (Floor) | diff --git a/docs/04-THREAT-MODEL.md b/docs/04-THREAT-MODEL.md index ce83cc2..74120b0 100644 --- a/docs/04-THREAT-MODEL.md +++ b/docs/04-THREAT-MODEL.md @@ -71,7 +71,7 @@ A security product with a bug is worse than no product. This file lists every ad | I12 | No token leaves a vault except release, settle, lifeboat | program-vs-model differential (vault balance equals the model after every step) | | I13 | Releases fail before the seal | program `nothing_can_be_released_before_the_seal…` | | I14 | `vault.queued_amount == Σ pending tickets` | program-vs-model differential, after every step | -| I15 | Floor: no new binary before 72h unless a quorum approved that exact frozen buffer during a restore, or the snapshot is restored | 51 Floor tests on the real loader (`programs/tests/tests/floor.rs`) | +| I15 | Floor: no new binary before 72h unless a quorum approved that exact frozen buffer during a restore, or the snapshot is restored | 52 Floor tests on the real loader (`programs/tests/tests/floor.rs`) | | I16 | Python reference and Rust core agree on every input | diff (6,943,561 identical lines in the final 6-seed run; 36 fixtures with expected outputs) | ## 4. The #1 risk: a bug in Bulkhead itself diff --git a/docs/09-VERIFICATION.md b/docs/09-VERIFICATION.md index 383938e..7fdbef8 100644 --- a/docs/09-VERIFICATION.md +++ b/docs/09-VERIFICATION.md @@ -31,7 +31,7 @@ The programs are checked against the core as a model (§7). Two implementations | **Bounded proofs (Kani)** | 19 harnesses: logic at full width, 3 at small width (§5) | **19/19 verified** (16 Oct) | | **Coverage-guided fuzzing** | 9 libFuzzer targets (`fuzz/`, cargo-fuzz, overflow checks and AddressSanitizer on): the Token-2022 mint policy, the token-account reader and the guardian-set parser Floor and the Vault share against independent statements of them; the Pyth `PriceUpdateV2` parser against the documented layout; load-store-load round trips of every Vault and Floor account; the loader-v3 parsers and snapshot identity; the limiter at full width (exact `available_now`, instant and queue rules, errors change nothing, window changes keep the used fraction); the ledger (backed ≤ requested, the same amount on a re-ask, `debit_backed` accepts it). Line coverage is measured (`cargo fuzz coverage`); seeds in `fuzz/seeds/` reach what a mutator rarely builds | 6 Oct: 10 min per target, 36M–277M executions each; one harness-oracle crash (finding 40), no program bug; every targeted parser at 100% of lines after the seeds (finding 41; but the same loader target never got past `elf_info`'s magic check in 417M runs on 17 Oct, below). That run had 8 targets; the guardian-set target came on 14 Oct. 17 Oct (`SECONDS_PER=1800 scripts/fuzz.sh`, all 9 targets at once): 30 min per target, 125M–440M executions each (the guardian-set target's 259M), no crash; the two targets changed after it (below) have run 120 s each since, no crash. Region coverage of that corpus (`llvm-cov`, measured by hand) found, among other missed regions, two parsers that their own target never fully ran. Line coverage hid one: the guardian-set target could not build an empty set (every line, 60 of 61 regions). The other is in the loader-parser target, which finding 41's change left decoding its input with `arbitrary` (that finding's cause) and without seeds: no input got past `elf_info`'s ELF magic check. After a fix to the guardian-set target, and the loader target moved to raw bytes with four ELF-header seeds, their corpora and seeds run `GuardianSet::parse` and `elf_info` at every line and region (`llvm-cov` after 120 s runs, 17 Oct); the loader target now catches a mutant (`elf_info` reading past a short header) within seconds, even unseeded, that 45M runs of the old one missed. It checks only `snapshot_matches`' result and runs the other parsers for panics only (`elf_info`'s values are checked by golden G-13 and the property and unit tests). The other regions the targets miss in the functions they call are not listed here in full: some are unreachable, and some are refusals no harness asks for, which the fuzzing does not test (a closed limiter lane: the target makes every capacity at least 1; a full ledger: the ledger target uses at most 4 distinct mints). No target calls `elf_extent`, `snapshot_restorable` (finding 88's length rule) or `is_canonical_abort`: unit tests and the core's mutation testing (§6) check them (`is_canonical_abort` also the differential's `FC` command), the fuzzer does not. CI: 60 s per target (25 min weekly, §8) | | **Mutation testing** | `cargo-mutants` on the core: 797 mutants (run 10, §6), and in CI on every pull request's changed lines | Every non-equivalent mutant killed; 22 equivalents, each explained and excluded by exact pattern | -| **Program tests** | Floor (51) and Vault (115) on the real agave runtime: LiteSVM, mainnet feature set, the mainnet token program | 166/166 | +| **Program tests** | Floor (52) and Vault (115) on the real agave runtime: LiteSVM, mainnet feature set, the mainnet token program | 167/167 | | **Account substitution** (`programs/tests/tests/common/sweep.rs`) | For every Vault and Floor instruction (all 30 of the Vault's, tags 0–29, including the read-only views `attest` and `quote_release` and both scopes of `unfreeze`; registration both by the caller PDA and by the upgrade authority; the Floor lifecycle end to end): a transaction that succeeds, then each account swapped in turn for a fresh address, every other account of the transaction, a second market's or a second protected program's accounts, a stranger's token accounts and buffers, other tickets, programs and sysvars, and for a signer every other known key; then each key that signs at any slot (a free one included) and stands at a checked slot: unsigned at every checked slot (a free slot where it signed gets the payer, once a control shows the payer is accepted there; not for the fee payer, which signs anyway), since signing is per key and unsigning one slot of a key that signs at another proves nothing. A key at several slots is otherwise swapped one slot at a time, so a check that only compares those slots with each other is not tested by a consistent attacker key at all of them. Every swap must fail, except at the positions each program leaves free on purpose, each listed with its reason (a rent payer, a ticket account only used when part of a release queues, another guardian of the same set). The first version missed two of four bugs planted to test it (a settle that pays anyone, a cancel of another vault's ticket): it had no look-alike token account or ticket to offer. With them, all four are caught | 16 Oct, with four guardians in the test sets (finding 107; an eject's signers may now be any two of the three others, so each of those slots is free for the third, never for the target or the other signer again; with a guardian listed twice counted as two, the sweep fails): 5,365 Vault and 1,710 Floor substitutions (37 and 18 transactions), refused. 16 Oct, with `attest`, `quote_release` (read-only accounts, quoting an owner's own deposit; as in every release here, the price slot is left free) and the vault-scope `unfreeze`: 5,308 Vault and 1,683 Floor substitutions (37 and 18 transactions), refused. Each of three one-site mutants fails the sweep and passes without those three runs: `attest` not checking its token account, a quote skipping the vault-account check a release makes, and the vault-scope `unfreeze` loading a vault without checking its protocol. 16 Oct, with signing keys tried per key (before, a key that signs at two slots was never tried unsigned: the user of Harbor's deposit and withdraw; with the withdraw's signer check deleted, the sweep now fails): 4,887 Vault and 1,683 Floor substitutions (34 and 18 transactions; one of the 34, "withdraw (signed at the free slot only)", repeats Harbor's withdrawal with the user signing only at a free slot, which adds no program coverage; the test checks that the user was tried unsigned there, so it fails if the sweep stops picking such a key), refused. 10 Oct, with a release to none signed by the owner (finding 95; with that check deleted, the sweep accepts the owner unsigned and fails): 4,499 Vault and 1,683 Floor substitutions (33 and 18 transactions), refused (9 Oct, with `close_buffer`, the signing release and the exit's account 6: 4,508 and 1,549; 8 Oct: 4,474 and 1,472). Found finding 53. Accepted and explained: a veto of a lifeboat exit where none is pending changes nothing (the next proposal clears it) | | **Program ↔ model differential** | Random operation sequences on-chain vs a host model built only from the core; invariants after every step (§7) | 12,000 steps across 24 seeds, identical; 24,000 steps across 24 seeds after the A1 fix (29 Sep), identical | | **Wide program differential** | The same, with a limit configuration drawn per seed (floors and caps far above the balance, a closed lane, a queue delay past the horizon) and every instruction that changes what can leave: protocol and vault freezes, quorum unfreezes, ticket extensions, backlog resets, lifeboat moves both ways, limit changes; `quote_release` against the release, every `attest` field against the core (§7) | 5 Oct: 200,000 steps across 400 configurations, then 100,000 with limit changes after finding 30, identical | @@ -84,7 +84,7 @@ scripts/mutants.sh # mutation testing, release profile (~45 scripts/fuzz.sh # libFuzzer, every target 60 s in parallel (SECONDS_PER=600 for longer) (cd fuzz && cargo clippy --all-targets -- -D warnings) # lint the fuzz crate (its own workspace; CI's fuzz job) scripts/build-programs.sh # Floor, Vault, Harbor for sBPF v3; checks e_flags == 3 -(cd programs/tests && cargo test --release) # 166 program tests + the program-vs-model differentials +(cd programs/tests && cargo test --release) # 167 program tests + the program-vs-model differentials (cd programs/tests && BULKHEAD_PROGRAM_SEEDS=24 BULKHEAD_PROGRAM_STEPS=500 cargo test --release --test differential) cloud/e2e/run.sh # validator + guardian + attacker node --test cloud/test/*.test.mjs # client, policy, JS vs Python vs Rust differential (needs the worker) diff --git a/programs/tests/tests/common/mod.rs b/programs/tests/tests/common/mod.rs index 5add98e..a2ebc3e 100644 --- a/programs/tests/tests/common/mod.rs +++ b/programs/tests/tests/common/mod.rs @@ -34,6 +34,7 @@ pub mod err { pub const INVALID_INSTRUCTION: u32 = 7000; pub const NOT_A_FLOOR_CONFIG: u32 = 7001; pub const NOT_LOADER_V3: u32 = 7005; + pub const PROGRAM_MISMATCH: u32 = 7006; pub const NOT_CURRENT_AUTHORITY: u32 = 7007; pub const INVALID_GUARDIANS: u32 = 7008; pub const INVALID_THRESHOLD: u32 = 7009; diff --git a/programs/tests/tests/floor.rs b/programs/tests/tests/floor.rs index 238eb09..9b2f605 100644 --- a/programs/tests/tests/floor.rs +++ b/programs/tests/tests/floor.rs @@ -1713,7 +1713,8 @@ fn the_config_layout_matches_what_off_chain_readers_decode() { } /// A copy of `real`'s account at a fresh address, under `owner`, with `edit` -/// applied to its data. +/// applied to its data. Never executable: only a loader may own an executable +/// account. fn copy_under( env: &mut Env, real: &solana_address::Address, @@ -1722,6 +1723,7 @@ fn copy_under( ) -> solana_address::Address { let mut a = env.account(real); a.owner = owner; + a.executable = false; edit(&mut a.data); let at = solana_address::Address::new_unique(); env.svm.set_account(at, a).unwrap(); @@ -1771,3 +1773,74 @@ fn floor_reads_only_a_config_it_wrote_and_a_buffer_the_loader_owns() { let fake_pin = copy_under(&mut env, &p.snapshot, thief.pubkey(), |_| {}); assert_eq!(env.fails(&[f.pin_snapshot(&fake_pin)], &[]), err::NOT_LOADER_V3); } + +/// Registration takes the upgrade authority from the programdata the program +/// itself names (register.rs:63). Without that, a thief naming their own +/// programdata, of which they hold the key, would take the config address of +/// another team's program, and that team could never register it. The program +/// must also be the loader's (:57): a program account the thief wrote, at an +/// address of their own, could name the thief's programdata, and Floor would +/// hold a config for a program the loader never deployed. The team's own +/// config address is not at risk from that. The programdata half of :57 is +/// covered only jointly with :63: a program the loader owns names its own +/// programdata, which the loader owns too. And the programdata must still +/// have its header (:69): the loader's Close leaves a closed programdata +/// loader-owned until its transaction ends. +#[test] +fn registration_reads_only_the_programs_own_programdata() { + let mut env = Env::new(); + let team = Keypair::new(); + env.fund(&team); + let (program, programdata) = env.deploy(&honest_v1(), &team, 2048); + let thief = Keypair::new(); + env.fund(&thief); + let (_, thiefs_programdata) = env.deploy(&honest_v1(), &thief, 2048); + let gs = [Keypair::new().pubkey(), Keypair::new().pubkey(), Keypair::new().pubkey(), Keypair::new().pubkey()]; + let pay = env.payer.pubkey(); + + let f = Floor::new(env.floor, program); + let mut theirs = f.register(&pay, &thief.pubkey(), &thief.pubkey(), &gs, 2, 7 * DAY, 3 * DAY); + theirs.accounts[4].pubkey = thiefs_programdata; + assert_eq!(env.fails(&[theirs], &[&thief]), err::PROGRAM_MISMATCH); + + // A copy of the team's program account, under an owner that is not the + // loader, naming the thief's real programdata. + let fake_program = copy_under(&mut env, &program, thief.pubkey(), |d| { + d[4..36].copy_from_slice(thiefs_programdata.as_ref()) + }); + let g = Floor::new(env.floor, fake_program); + let mut forged = g.register(&pay, &thief.pubkey(), &thief.pubkey(), &gs, 2, 7 * DAY, 3 * DAY); + forged.accounts[4].pubkey = thiefs_programdata; + assert_eq!(env.fails(&[forged], &[&thief]), err::NOT_LOADER_V3); + + // The team closes its programdata and registers, in one transaction. + // Until the transaction ends the closed programdata is still the + // loader's and the program still names it, so :57 and :63 pass; it has + // no header left, and :69 refuses. Both forms of the close (SIMD-0432: + // the program account reclaimed or tombstoned). The failed transaction + // undoes the close. + for tombstone in [false, true] { + let close = solana_loader_v3_interface::instruction::close_any( + &programdata, + &pay, + Some(&team.pubkey()), + Some(&program), + tombstone, + ); + let reg = f.register(&pay, &team.pubkey(), &team.pubkey(), &gs, 2, 7 * DAY, 3 * DAY); + let e = env.send(&[close, reg], &[&team]).map(|_| ()).unwrap_err(); + assert_eq!( + e.err, + solana_transaction_error::TransactionError::InstructionError( + 1, + solana_instruction_error::InstructionError::Custom(err::PROGRAM_MISMATCH) + ), + "tombstone {tombstone}:\n{}", + e.meta.logs.join("\n") + ); + } + + // The team registers its program. + env.ok(&[f.register(&pay, &team.pubkey(), &team.pubkey(), &gs, 2, 7 * DAY, 3 * DAY)], &[&team]); + assert_eq!(env.upgrade_authority(&programdata), Some(f.authority.to_bytes())); +} From d514059ee5267d9d935821423e9a7dcd08ef41d3 Mon Sep 17 00:00:00 2001 From: Shuvam Pandey Date: Fri, 16 Oct 2026 17:54:30 +0545 Subject: [PATCH 3/7] Test the system-program and heartbeat-interval refusals at registration Two registration refusals had no test that saw their code (tasks/error-codes-floor/mutants.log, base 43bfa31): F05 register.rs:53, the system program account: with the check deleted the registration still fails, at the CPI ("Unknown program 1111...", MissingAccount, no custom code; STATE=c3). F34 guardians.rs:49, a heartbeat interval outside 1 to 30 days maps to InvalidInterval. No case sent one, so mapping it to InvalidGuardians left every test green. registration_rejects_weak_settings gains intervals 1 day - 1 s and 30 days + 1 s, each just past its bound (INVALID_INTERVAL), and registers two more programs at exactly 1 day and exactly 30 days, which are accepted. New test registration_names_the_system_program: slot 6 replaced -> WRONG_PROGRAM, then the same registration with the real system program succeeds. Not tested: register.rs:88 (AlreadyRegistered). Once registered, Floor's PDA holds the upgrade key, so a second registration is refused at :70 (NOT_CURRENT_AUTHORITY, seen while writing this test), and a release closes the config in the transaction that hands the key back. Evidence (STATE=c3, full program suite): F05 KILLED by registration_names_the_system_program, F34 KILLED by registration_rejects_weak_settings (7008 where 7010 is expected); both SURVIVED at base. F35, the core range made exclusive at the top (governance.rs:216, ..= to ..), is KILLED by the 30-day registration (STATE=r3c3: 7010 for an interval the spec allows). Floor hash 8ca8a608 unchanged. Counts: Floor 52 -> 53, programs 167 -> 168 (claims.py OK). Co-Authored-By: Claude Opus 5.5 --- README.md | 4 ++-- docs/04-THREAT-MODEL.md | 2 +- docs/09-VERIFICATION.md | 4 ++-- programs/tests/tests/common/mod.rs | 2 ++ programs/tests/tests/floor.rs | 33 ++++++++++++++++++++++++++++++ 5 files changed, 40 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 6324d2a..54758c0 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Bulkhead is a small Solana program that holds a protocol's token accounts on the **[The attack](#what-it-does-to-an-attack)** · **[How it works](#how-it-works)** · **[Verify it](#verify-it-yourself)** · **[Devnet](#live-on-devnet)** · **[FAQ](docs/FAQ.md)** · **[Docs](#documentation)** -[![CI](https://github.com/shuv-amp/bulkhead/actions/workflows/ci.yml/badge.svg)](https://github.com/shuv-amp/bulkhead/actions/workflows/ci.yml) [![devnet](https://img.shields.io/badge/devnet-live-57606A?style=flat-square)](#live-on-devnet) [![Kani](https://img.shields.io/badge/Kani_proofs-19%2F19-57606A?style=flat-square)](docs/09-VERIFICATION.md) [![tests](https://img.shields.io/badge/program_tests-167%2F167-57606A?style=flat-square)](docs/09-VERIFICATION.md) [![audit](https://img.shields.io/badge/audit-not_yet,_not_for_real_funds-E5481B?style=flat-square)](SECURITY.md) [![license](https://img.shields.io/badge/license-Apache--2.0-57606A?style=flat-square)](LICENSE) +[![CI](https://github.com/shuv-amp/bulkhead/actions/workflows/ci.yml/badge.svg)](https://github.com/shuv-amp/bulkhead/actions/workflows/ci.yml) [![devnet](https://img.shields.io/badge/devnet-live-57606A?style=flat-square)](#live-on-devnet) [![Kani](https://img.shields.io/badge/Kani_proofs-19%2F19-57606A?style=flat-square)](docs/09-VERIFICATION.md) [![tests](https://img.shields.io/badge/program_tests-168%2F168-57606A?style=flat-square)](docs/09-VERIFICATION.md) [![audit](https://img.shields.io/badge/audit-not_yet,_not_for_real_funds-E5481B?style=flat-square)](SECURITY.md) [![license](https://img.shields.io/badge/license-Apache--2.0-57606A?style=flat-square)](LICENSE)
@@ -165,7 +165,7 @@ These scripts install nothing. The core has zero dependencies, and Cloud and the | Check | Result (latest run of each) | |---|---| -| **Programs on the real runtime**
LiteSVM, mainnet feature set, mainnet token program | **167/167**: every scenario (S1 Drift, S4 bank run, S7, S8, S9, S10 Floor), the negative tests, measured compute, and an account-substitution sweep of every instruction (7,075 swaps refused, 16 Oct) | +| **Programs on the real runtime**
LiteSVM, mainnet feature set, mainnet token program | **168/168**: every scenario (S1 Drift, S4 bank run, S7, S8, S9, S10 Floor), the negative tests, measured compute, and an account-substitution sweep of every instruction (7,075 swaps refused, 16 Oct) | | **Bounded proofs**
Kani, and exhaustive checks | **19/19 harnesses verified** on 16 Oct (16 for every value of their types), 240 s of verification ([`09 §5`](docs/09-VERIFICATION.md#5-bounded-proofs-kani-and-exhaustive-checks)). 6 exhaustive tests over ~584M inputs | | **Differential**
an independent Python reference vs the Rust core | **6,943,561 lines identical** (6 seeds × 200k cases, 27 Sep); 33 commands now, 300k cases on every pull request and 3M weekly in CI | | **Program vs model** | Random steps on-chain, every outcome equal to the core's prediction: 12,000 (Vault), 300,000 with random limits and every brake (Vault), 200,000 (Floor) | diff --git a/docs/04-THREAT-MODEL.md b/docs/04-THREAT-MODEL.md index 74120b0..fdef58e 100644 --- a/docs/04-THREAT-MODEL.md +++ b/docs/04-THREAT-MODEL.md @@ -71,7 +71,7 @@ A security product with a bug is worse than no product. This file lists every ad | I12 | No token leaves a vault except release, settle, lifeboat | program-vs-model differential (vault balance equals the model after every step) | | I13 | Releases fail before the seal | program `nothing_can_be_released_before_the_seal…` | | I14 | `vault.queued_amount == Σ pending tickets` | program-vs-model differential, after every step | -| I15 | Floor: no new binary before 72h unless a quorum approved that exact frozen buffer during a restore, or the snapshot is restored | 52 Floor tests on the real loader (`programs/tests/tests/floor.rs`) | +| I15 | Floor: no new binary before 72h unless a quorum approved that exact frozen buffer during a restore, or the snapshot is restored | 53 Floor tests on the real loader (`programs/tests/tests/floor.rs`) | | I16 | Python reference and Rust core agree on every input | diff (6,943,561 identical lines in the final 6-seed run; 36 fixtures with expected outputs) | ## 4. The #1 risk: a bug in Bulkhead itself diff --git a/docs/09-VERIFICATION.md b/docs/09-VERIFICATION.md index 7fdbef8..379e8f9 100644 --- a/docs/09-VERIFICATION.md +++ b/docs/09-VERIFICATION.md @@ -31,7 +31,7 @@ The programs are checked against the core as a model (§7). Two implementations | **Bounded proofs (Kani)** | 19 harnesses: logic at full width, 3 at small width (§5) | **19/19 verified** (16 Oct) | | **Coverage-guided fuzzing** | 9 libFuzzer targets (`fuzz/`, cargo-fuzz, overflow checks and AddressSanitizer on): the Token-2022 mint policy, the token-account reader and the guardian-set parser Floor and the Vault share against independent statements of them; the Pyth `PriceUpdateV2` parser against the documented layout; load-store-load round trips of every Vault and Floor account; the loader-v3 parsers and snapshot identity; the limiter at full width (exact `available_now`, instant and queue rules, errors change nothing, window changes keep the used fraction); the ledger (backed ≤ requested, the same amount on a re-ask, `debit_backed` accepts it). Line coverage is measured (`cargo fuzz coverage`); seeds in `fuzz/seeds/` reach what a mutator rarely builds | 6 Oct: 10 min per target, 36M–277M executions each; one harness-oracle crash (finding 40), no program bug; every targeted parser at 100% of lines after the seeds (finding 41; but the same loader target never got past `elf_info`'s magic check in 417M runs on 17 Oct, below). That run had 8 targets; the guardian-set target came on 14 Oct. 17 Oct (`SECONDS_PER=1800 scripts/fuzz.sh`, all 9 targets at once): 30 min per target, 125M–440M executions each (the guardian-set target's 259M), no crash; the two targets changed after it (below) have run 120 s each since, no crash. Region coverage of that corpus (`llvm-cov`, measured by hand) found, among other missed regions, two parsers that their own target never fully ran. Line coverage hid one: the guardian-set target could not build an empty set (every line, 60 of 61 regions). The other is in the loader-parser target, which finding 41's change left decoding its input with `arbitrary` (that finding's cause) and without seeds: no input got past `elf_info`'s ELF magic check. After a fix to the guardian-set target, and the loader target moved to raw bytes with four ELF-header seeds, their corpora and seeds run `GuardianSet::parse` and `elf_info` at every line and region (`llvm-cov` after 120 s runs, 17 Oct); the loader target now catches a mutant (`elf_info` reading past a short header) within seconds, even unseeded, that 45M runs of the old one missed. It checks only `snapshot_matches`' result and runs the other parsers for panics only (`elf_info`'s values are checked by golden G-13 and the property and unit tests). The other regions the targets miss in the functions they call are not listed here in full: some are unreachable, and some are refusals no harness asks for, which the fuzzing does not test (a closed limiter lane: the target makes every capacity at least 1; a full ledger: the ledger target uses at most 4 distinct mints). No target calls `elf_extent`, `snapshot_restorable` (finding 88's length rule) or `is_canonical_abort`: unit tests and the core's mutation testing (§6) check them (`is_canonical_abort` also the differential's `FC` command), the fuzzer does not. CI: 60 s per target (25 min weekly, §8) | | **Mutation testing** | `cargo-mutants` on the core: 797 mutants (run 10, §6), and in CI on every pull request's changed lines | Every non-equivalent mutant killed; 22 equivalents, each explained and excluded by exact pattern | -| **Program tests** | Floor (52) and Vault (115) on the real agave runtime: LiteSVM, mainnet feature set, the mainnet token program | 167/167 | +| **Program tests** | Floor (53) and Vault (115) on the real agave runtime: LiteSVM, mainnet feature set, the mainnet token program | 168/168 | | **Account substitution** (`programs/tests/tests/common/sweep.rs`) | For every Vault and Floor instruction (all 30 of the Vault's, tags 0–29, including the read-only views `attest` and `quote_release` and both scopes of `unfreeze`; registration both by the caller PDA and by the upgrade authority; the Floor lifecycle end to end): a transaction that succeeds, then each account swapped in turn for a fresh address, every other account of the transaction, a second market's or a second protected program's accounts, a stranger's token accounts and buffers, other tickets, programs and sysvars, and for a signer every other known key; then each key that signs at any slot (a free one included) and stands at a checked slot: unsigned at every checked slot (a free slot where it signed gets the payer, once a control shows the payer is accepted there; not for the fee payer, which signs anyway), since signing is per key and unsigning one slot of a key that signs at another proves nothing. A key at several slots is otherwise swapped one slot at a time, so a check that only compares those slots with each other is not tested by a consistent attacker key at all of them. Every swap must fail, except at the positions each program leaves free on purpose, each listed with its reason (a rent payer, a ticket account only used when part of a release queues, another guardian of the same set). The first version missed two of four bugs planted to test it (a settle that pays anyone, a cancel of another vault's ticket): it had no look-alike token account or ticket to offer. With them, all four are caught | 16 Oct, with four guardians in the test sets (finding 107; an eject's signers may now be any two of the three others, so each of those slots is free for the third, never for the target or the other signer again; with a guardian listed twice counted as two, the sweep fails): 5,365 Vault and 1,710 Floor substitutions (37 and 18 transactions), refused. 16 Oct, with `attest`, `quote_release` (read-only accounts, quoting an owner's own deposit; as in every release here, the price slot is left free) and the vault-scope `unfreeze`: 5,308 Vault and 1,683 Floor substitutions (37 and 18 transactions), refused. Each of three one-site mutants fails the sweep and passes without those three runs: `attest` not checking its token account, a quote skipping the vault-account check a release makes, and the vault-scope `unfreeze` loading a vault without checking its protocol. 16 Oct, with signing keys tried per key (before, a key that signs at two slots was never tried unsigned: the user of Harbor's deposit and withdraw; with the withdraw's signer check deleted, the sweep now fails): 4,887 Vault and 1,683 Floor substitutions (34 and 18 transactions; one of the 34, "withdraw (signed at the free slot only)", repeats Harbor's withdrawal with the user signing only at a free slot, which adds no program coverage; the test checks that the user was tried unsigned there, so it fails if the sweep stops picking such a key), refused. 10 Oct, with a release to none signed by the owner (finding 95; with that check deleted, the sweep accepts the owner unsigned and fails): 4,499 Vault and 1,683 Floor substitutions (33 and 18 transactions), refused (9 Oct, with `close_buffer`, the signing release and the exit's account 6: 4,508 and 1,549; 8 Oct: 4,474 and 1,472). Found finding 53. Accepted and explained: a veto of a lifeboat exit where none is pending changes nothing (the next proposal clears it) | | **Program ↔ model differential** | Random operation sequences on-chain vs a host model built only from the core; invariants after every step (§7) | 12,000 steps across 24 seeds, identical; 24,000 steps across 24 seeds after the A1 fix (29 Sep), identical | | **Wide program differential** | The same, with a limit configuration drawn per seed (floors and caps far above the balance, a closed lane, a queue delay past the horizon) and every instruction that changes what can leave: protocol and vault freezes, quorum unfreezes, ticket extensions, backlog resets, lifeboat moves both ways, limit changes; `quote_release` against the release, every `attest` field against the core (§7) | 5 Oct: 200,000 steps across 400 configurations, then 100,000 with limit changes after finding 30, identical | @@ -84,7 +84,7 @@ scripts/mutants.sh # mutation testing, release profile (~45 scripts/fuzz.sh # libFuzzer, every target 60 s in parallel (SECONDS_PER=600 for longer) (cd fuzz && cargo clippy --all-targets -- -D warnings) # lint the fuzz crate (its own workspace; CI's fuzz job) scripts/build-programs.sh # Floor, Vault, Harbor for sBPF v3; checks e_flags == 3 -(cd programs/tests && cargo test --release) # 167 program tests + the program-vs-model differentials +(cd programs/tests && cargo test --release) # 168 program tests + the program-vs-model differentials (cd programs/tests && BULKHEAD_PROGRAM_SEEDS=24 BULKHEAD_PROGRAM_STEPS=500 cargo test --release --test differential) cloud/e2e/run.sh # validator + guardian + attacker node --test cloud/test/*.test.mjs # client, policy, JS vs Python vs Rust differential (needs the worker) diff --git a/programs/tests/tests/common/mod.rs b/programs/tests/tests/common/mod.rs index a2ebc3e..1acfe20 100644 --- a/programs/tests/tests/common/mod.rs +++ b/programs/tests/tests/common/mod.rs @@ -38,6 +38,7 @@ pub mod err { pub const NOT_CURRENT_AUTHORITY: u32 = 7007; pub const INVALID_GUARDIANS: u32 = 7008; pub const INVALID_THRESHOLD: u32 = 7009; + pub const INVALID_INTERVAL: u32 = 7010; pub const INVALID_DELAY: u32 = 7011; pub const MISSING_SIGNATURE: u32 = 7012; pub const NOT_OWNER: u32 = 7013; @@ -58,6 +59,7 @@ pub mod err { pub const VETOED: u32 = 7029; pub const EXPIRED: u32 = 7030; pub const CANNOT_EJECT: u32 = 7031; + pub const WRONG_PROGRAM: u32 = 7033; pub const ABORT_DOES_NOT_FIT: u32 = 7035; pub const BUFFER_IN_USE: u32 = 7036; pub const WRONG_ACCOUNT: u32 = 7037; diff --git a/programs/tests/tests/floor.rs b/programs/tests/tests/floor.rs index 9b2f605..97ed64c 100644 --- a/programs/tests/tests/floor.rs +++ b/programs/tests/tests/floor.rs @@ -440,10 +440,25 @@ fn registration_rejects_weak_settings() { f.register(&pay, &team.pubkey(), &owner, &[a], 1, 7 * DAY, 3 * DAY), err::INVALID_GUARDIANS, ), + // Heartbeats every 1 to 30 days. + ( + f.register(&pay, &team.pubkey(), &owner, &[a, b, c, d], 2, DAY - 1, 3 * DAY), + err::INVALID_INTERVAL, + ), + ( + f.register(&pay, &team.pubkey(), &owner, &[a, b, c, d], 2, 30 * DAY + 1, 3 * DAY), + err::INVALID_INTERVAL, + ), ]; for (ix, code) in cases { assert_eq!(env.fails(&[ix], &[&team]), code); } + // Each heartbeat bound itself is accepted. + for interval in [DAY, 30 * DAY] { + let (program, _) = env.deploy(&honest_v1(), &team, 1024); + let ix = Floor::new(env.floor, program).register(&pay, &team.pubkey(), &owner, &[a, b, c, d], 2, interval, 3 * DAY); + env.ok(&[ix], &[&team]); + } } #[test] @@ -1844,3 +1859,21 @@ fn registration_reads_only_the_programs_own_programdata() { env.ok(&[f.register(&pay, &team.pubkey(), &team.pubkey(), &gs, 2, 7 * DAY, 3 * DAY)], &[&team]); assert_eq!(env.upgrade_authority(&programdata), Some(f.authority.to_bytes())); } + +/// A registration names the real system program, and is refused with Floor's +/// own code if it does not. Without the check the CPI to the system program +/// would still fail, with no code saying why. +#[test] +fn registration_names_the_system_program() { + let mut env = Env::new(); + let team = Keypair::new(); + env.fund(&team); + let (program, _) = env.deploy(&honest_v1(), &team, 2048); + let f = Floor::new(env.floor, program); + let gs = [Keypair::new().pubkey(), Keypair::new().pubkey(), Keypair::new().pubkey(), Keypair::new().pubkey()]; + let reg = f.register(&env.payer.pubkey(), &team.pubkey(), &team.pubkey(), &gs, 2, 7 * DAY, 3 * DAY); + let mut no_system = reg.clone(); + no_system.accounts[6].pubkey = solana_address::Address::new_unique(); + assert_eq!(env.fails(&[no_system], &[&team]), err::WRONG_PROGRAM); + env.ok(&[reg], &[&team]); +} From 55428eca35b8f6d647db082a0b60c53babf932d9 Mon Sep 17 00:00:00 2001 From: Shuvam Pandey Date: Fri, 16 Oct 2026 17:37:15 +0545 Subject: [PATCH 4/7] Pin seven Floor refusals another check backstops Seven checks survived deletion (tasks/error-codes-floor/mutants.log, base 43bfa31) because something later still refused the case: the loader, or another Floor check with its own code. Each now has a test that sees Floor's own code, and each was seen to fail with the check deleted (STATE=c4, full program suite): F15 loader.rs:141, a stop naming another program's programdata, or its program, each on its own -> PROGRAM_MISMATCH. Gone: the loader refuses (IncorrectAuthority, no custom code). Each clause of :140 dropped alone (F15a, F15b) is also killed. F12 lib.rs:200, a stop naming another program's Floor authority -> WRONG_AUTHORITY_ADDRESS. Gone: PrivilegeEscalation. F14 loader.rs:72, a stop with the clock in the rent slot, or the rent in the clock slot -> WRONG_SYSVAR. Gone: InvalidArgument from the loader. Each clause of :71 dropped alone (F14a, F14b) is killed. F21 stop.rs:205, a quorum restore while live -> NOT_ABORTED. Gone: 7024 NoValidSnapshot (snapshot_valid is 1 only between a stop and the next return to live). F20 stop.rs:122, a stop after a restore, with no abort buffer staged, naming the all-zero address or the used-up buffer -> NO_ABORT_BUFFER. Gone: the all-zero address equals the empty slot, so the stop reaches the loader (PrivilegeEscalation); the used-up buffer gets 7021 WrongBuffer. F25 proposals.rs:104, a proposal of unknown kind 99 -> WRONG_PROPOSAL_KIND, and the slot stays empty. Gone: the proposal SUCCEEDS; from the code it then holds the slot until cancelled, and execute refuses it (:245). F31 proposals.rs:337, a release naming another program's programdata -> PROGRAM_MISMATCH, and that programdata keeps its Floor authority. Gone: IncorrectAuthority from the loader. New tests: a_stop_names_its_own_program_sysvars_and_authority (then the real stop succeeds, and the other program still runs), a_restore_needs_a_stop_and_a_stop_needs_an_abort_buffer, a_proposal_has_a_known_kind_and_a_release_its_own_programdata (then the real release hands the key over). Evidence: all seven, and F14a F14b F15a F15b, KILLED by the tests named above (STATE=r2c4); all seven SURVIVED at base. Floor hash 8ca8a608 unchanged (tests only). Counts: Floor 53 -> 56, programs 168 -> 171 (claims.py OK). Co-Authored-By: Claude Opus 5.5 --- README.md | 4 +- docs/04-THREAT-MODEL.md | 2 +- docs/09-VERIFICATION.md | 4 +- programs/tests/tests/common/mod.rs | 3 ++ programs/tests/tests/floor.rs | 83 ++++++++++++++++++++++++++++++ 5 files changed, 91 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 54758c0..1846bdc 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Bulkhead is a small Solana program that holds a protocol's token accounts on the **[The attack](#what-it-does-to-an-attack)** · **[How it works](#how-it-works)** · **[Verify it](#verify-it-yourself)** · **[Devnet](#live-on-devnet)** · **[FAQ](docs/FAQ.md)** · **[Docs](#documentation)** -[![CI](https://github.com/shuv-amp/bulkhead/actions/workflows/ci.yml/badge.svg)](https://github.com/shuv-amp/bulkhead/actions/workflows/ci.yml) [![devnet](https://img.shields.io/badge/devnet-live-57606A?style=flat-square)](#live-on-devnet) [![Kani](https://img.shields.io/badge/Kani_proofs-19%2F19-57606A?style=flat-square)](docs/09-VERIFICATION.md) [![tests](https://img.shields.io/badge/program_tests-168%2F168-57606A?style=flat-square)](docs/09-VERIFICATION.md) [![audit](https://img.shields.io/badge/audit-not_yet,_not_for_real_funds-E5481B?style=flat-square)](SECURITY.md) [![license](https://img.shields.io/badge/license-Apache--2.0-57606A?style=flat-square)](LICENSE) +[![CI](https://github.com/shuv-amp/bulkhead/actions/workflows/ci.yml/badge.svg)](https://github.com/shuv-amp/bulkhead/actions/workflows/ci.yml) [![devnet](https://img.shields.io/badge/devnet-live-57606A?style=flat-square)](#live-on-devnet) [![Kani](https://img.shields.io/badge/Kani_proofs-19%2F19-57606A?style=flat-square)](docs/09-VERIFICATION.md) [![tests](https://img.shields.io/badge/program_tests-171%2F171-57606A?style=flat-square)](docs/09-VERIFICATION.md) [![audit](https://img.shields.io/badge/audit-not_yet,_not_for_real_funds-E5481B?style=flat-square)](SECURITY.md) [![license](https://img.shields.io/badge/license-Apache--2.0-57606A?style=flat-square)](LICENSE)
@@ -165,7 +165,7 @@ These scripts install nothing. The core has zero dependencies, and Cloud and the | Check | Result (latest run of each) | |---|---| -| **Programs on the real runtime**
LiteSVM, mainnet feature set, mainnet token program | **168/168**: every scenario (S1 Drift, S4 bank run, S7, S8, S9, S10 Floor), the negative tests, measured compute, and an account-substitution sweep of every instruction (7,075 swaps refused, 16 Oct) | +| **Programs on the real runtime**
LiteSVM, mainnet feature set, mainnet token program | **171/171**: every scenario (S1 Drift, S4 bank run, S7, S8, S9, S10 Floor), the negative tests, measured compute, and an account-substitution sweep of every instruction (7,075 swaps refused, 16 Oct) | | **Bounded proofs**
Kani, and exhaustive checks | **19/19 harnesses verified** on 16 Oct (16 for every value of their types), 240 s of verification ([`09 §5`](docs/09-VERIFICATION.md#5-bounded-proofs-kani-and-exhaustive-checks)). 6 exhaustive tests over ~584M inputs | | **Differential**
an independent Python reference vs the Rust core | **6,943,561 lines identical** (6 seeds × 200k cases, 27 Sep); 33 commands now, 300k cases on every pull request and 3M weekly in CI | | **Program vs model** | Random steps on-chain, every outcome equal to the core's prediction: 12,000 (Vault), 300,000 with random limits and every brake (Vault), 200,000 (Floor) | diff --git a/docs/04-THREAT-MODEL.md b/docs/04-THREAT-MODEL.md index fdef58e..ab09d71 100644 --- a/docs/04-THREAT-MODEL.md +++ b/docs/04-THREAT-MODEL.md @@ -71,7 +71,7 @@ A security product with a bug is worse than no product. This file lists every ad | I12 | No token leaves a vault except release, settle, lifeboat | program-vs-model differential (vault balance equals the model after every step) | | I13 | Releases fail before the seal | program `nothing_can_be_released_before_the_seal…` | | I14 | `vault.queued_amount == Σ pending tickets` | program-vs-model differential, after every step | -| I15 | Floor: no new binary before 72h unless a quorum approved that exact frozen buffer during a restore, or the snapshot is restored | 53 Floor tests on the real loader (`programs/tests/tests/floor.rs`) | +| I15 | Floor: no new binary before 72h unless a quorum approved that exact frozen buffer during a restore, or the snapshot is restored | 56 Floor tests on the real loader (`programs/tests/tests/floor.rs`) | | I16 | Python reference and Rust core agree on every input | diff (6,943,561 identical lines in the final 6-seed run; 36 fixtures with expected outputs) | ## 4. The #1 risk: a bug in Bulkhead itself diff --git a/docs/09-VERIFICATION.md b/docs/09-VERIFICATION.md index 379e8f9..51bdb18 100644 --- a/docs/09-VERIFICATION.md +++ b/docs/09-VERIFICATION.md @@ -31,7 +31,7 @@ The programs are checked against the core as a model (§7). Two implementations | **Bounded proofs (Kani)** | 19 harnesses: logic at full width, 3 at small width (§5) | **19/19 verified** (16 Oct) | | **Coverage-guided fuzzing** | 9 libFuzzer targets (`fuzz/`, cargo-fuzz, overflow checks and AddressSanitizer on): the Token-2022 mint policy, the token-account reader and the guardian-set parser Floor and the Vault share against independent statements of them; the Pyth `PriceUpdateV2` parser against the documented layout; load-store-load round trips of every Vault and Floor account; the loader-v3 parsers and snapshot identity; the limiter at full width (exact `available_now`, instant and queue rules, errors change nothing, window changes keep the used fraction); the ledger (backed ≤ requested, the same amount on a re-ask, `debit_backed` accepts it). Line coverage is measured (`cargo fuzz coverage`); seeds in `fuzz/seeds/` reach what a mutator rarely builds | 6 Oct: 10 min per target, 36M–277M executions each; one harness-oracle crash (finding 40), no program bug; every targeted parser at 100% of lines after the seeds (finding 41; but the same loader target never got past `elf_info`'s magic check in 417M runs on 17 Oct, below). That run had 8 targets; the guardian-set target came on 14 Oct. 17 Oct (`SECONDS_PER=1800 scripts/fuzz.sh`, all 9 targets at once): 30 min per target, 125M–440M executions each (the guardian-set target's 259M), no crash; the two targets changed after it (below) have run 120 s each since, no crash. Region coverage of that corpus (`llvm-cov`, measured by hand) found, among other missed regions, two parsers that their own target never fully ran. Line coverage hid one: the guardian-set target could not build an empty set (every line, 60 of 61 regions). The other is in the loader-parser target, which finding 41's change left decoding its input with `arbitrary` (that finding's cause) and without seeds: no input got past `elf_info`'s ELF magic check. After a fix to the guardian-set target, and the loader target moved to raw bytes with four ELF-header seeds, their corpora and seeds run `GuardianSet::parse` and `elf_info` at every line and region (`llvm-cov` after 120 s runs, 17 Oct); the loader target now catches a mutant (`elf_info` reading past a short header) within seconds, even unseeded, that 45M runs of the old one missed. It checks only `snapshot_matches`' result and runs the other parsers for panics only (`elf_info`'s values are checked by golden G-13 and the property and unit tests). The other regions the targets miss in the functions they call are not listed here in full: some are unreachable, and some are refusals no harness asks for, which the fuzzing does not test (a closed limiter lane: the target makes every capacity at least 1; a full ledger: the ledger target uses at most 4 distinct mints). No target calls `elf_extent`, `snapshot_restorable` (finding 88's length rule) or `is_canonical_abort`: unit tests and the core's mutation testing (§6) check them (`is_canonical_abort` also the differential's `FC` command), the fuzzer does not. CI: 60 s per target (25 min weekly, §8) | | **Mutation testing** | `cargo-mutants` on the core: 797 mutants (run 10, §6), and in CI on every pull request's changed lines | Every non-equivalent mutant killed; 22 equivalents, each explained and excluded by exact pattern | -| **Program tests** | Floor (53) and Vault (115) on the real agave runtime: LiteSVM, mainnet feature set, the mainnet token program | 168/168 | +| **Program tests** | Floor (56) and Vault (115) on the real agave runtime: LiteSVM, mainnet feature set, the mainnet token program | 171/171 | | **Account substitution** (`programs/tests/tests/common/sweep.rs`) | For every Vault and Floor instruction (all 30 of the Vault's, tags 0–29, including the read-only views `attest` and `quote_release` and both scopes of `unfreeze`; registration both by the caller PDA and by the upgrade authority; the Floor lifecycle end to end): a transaction that succeeds, then each account swapped in turn for a fresh address, every other account of the transaction, a second market's or a second protected program's accounts, a stranger's token accounts and buffers, other tickets, programs and sysvars, and for a signer every other known key; then each key that signs at any slot (a free one included) and stands at a checked slot: unsigned at every checked slot (a free slot where it signed gets the payer, once a control shows the payer is accepted there; not for the fee payer, which signs anyway), since signing is per key and unsigning one slot of a key that signs at another proves nothing. A key at several slots is otherwise swapped one slot at a time, so a check that only compares those slots with each other is not tested by a consistent attacker key at all of them. Every swap must fail, except at the positions each program leaves free on purpose, each listed with its reason (a rent payer, a ticket account only used when part of a release queues, another guardian of the same set). The first version missed two of four bugs planted to test it (a settle that pays anyone, a cancel of another vault's ticket): it had no look-alike token account or ticket to offer. With them, all four are caught | 16 Oct, with four guardians in the test sets (finding 107; an eject's signers may now be any two of the three others, so each of those slots is free for the third, never for the target or the other signer again; with a guardian listed twice counted as two, the sweep fails): 5,365 Vault and 1,710 Floor substitutions (37 and 18 transactions), refused. 16 Oct, with `attest`, `quote_release` (read-only accounts, quoting an owner's own deposit; as in every release here, the price slot is left free) and the vault-scope `unfreeze`: 5,308 Vault and 1,683 Floor substitutions (37 and 18 transactions), refused. Each of three one-site mutants fails the sweep and passes without those three runs: `attest` not checking its token account, a quote skipping the vault-account check a release makes, and the vault-scope `unfreeze` loading a vault without checking its protocol. 16 Oct, with signing keys tried per key (before, a key that signs at two slots was never tried unsigned: the user of Harbor's deposit and withdraw; with the withdraw's signer check deleted, the sweep now fails): 4,887 Vault and 1,683 Floor substitutions (34 and 18 transactions; one of the 34, "withdraw (signed at the free slot only)", repeats Harbor's withdrawal with the user signing only at a free slot, which adds no program coverage; the test checks that the user was tried unsigned there, so it fails if the sweep stops picking such a key), refused. 10 Oct, with a release to none signed by the owner (finding 95; with that check deleted, the sweep accepts the owner unsigned and fails): 4,499 Vault and 1,683 Floor substitutions (33 and 18 transactions), refused (9 Oct, with `close_buffer`, the signing release and the exit's account 6: 4,508 and 1,549; 8 Oct: 4,474 and 1,472). Found finding 53. Accepted and explained: a veto of a lifeboat exit where none is pending changes nothing (the next proposal clears it) | | **Program ↔ model differential** | Random operation sequences on-chain vs a host model built only from the core; invariants after every step (§7) | 12,000 steps across 24 seeds, identical; 24,000 steps across 24 seeds after the A1 fix (29 Sep), identical | | **Wide program differential** | The same, with a limit configuration drawn per seed (floors and caps far above the balance, a closed lane, a queue delay past the horizon) and every instruction that changes what can leave: protocol and vault freezes, quorum unfreezes, ticket extensions, backlog resets, lifeboat moves both ways, limit changes; `quote_release` against the release, every `attest` field against the core (§7) | 5 Oct: 200,000 steps across 400 configurations, then 100,000 with limit changes after finding 30, identical | @@ -84,7 +84,7 @@ scripts/mutants.sh # mutation testing, release profile (~45 scripts/fuzz.sh # libFuzzer, every target 60 s in parallel (SECONDS_PER=600 for longer) (cd fuzz && cargo clippy --all-targets -- -D warnings) # lint the fuzz crate (its own workspace; CI's fuzz job) scripts/build-programs.sh # Floor, Vault, Harbor for sBPF v3; checks e_flags == 3 -(cd programs/tests && cargo test --release) # 168 program tests + the program-vs-model differentials +(cd programs/tests && cargo test --release) # 171 program tests + the program-vs-model differentials (cd programs/tests && BULKHEAD_PROGRAM_SEEDS=24 BULKHEAD_PROGRAM_STEPS=500 cargo test --release --test differential) cloud/e2e/run.sh # validator + guardian + attacker node --test cloud/test/*.test.mjs # client, policy, JS vs Python vs Rust differential (needs the worker) diff --git a/programs/tests/tests/common/mod.rs b/programs/tests/tests/common/mod.rs index 1acfe20..035d621 100644 --- a/programs/tests/tests/common/mod.rs +++ b/programs/tests/tests/common/mod.rs @@ -33,6 +33,7 @@ pub const T0: i64 = 1_790_000_000; // a fixed start time (Sep 2026) pub mod err { pub const INVALID_INSTRUCTION: u32 = 7000; pub const NOT_A_FLOOR_CONFIG: u32 = 7001; + pub const WRONG_AUTHORITY_ADDRESS: u32 = 7003; pub const NOT_LOADER_V3: u32 = 7005; pub const PROGRAM_MISMATCH: u32 = 7006; pub const NOT_CURRENT_AUTHORITY: u32 = 7007; @@ -55,10 +56,12 @@ pub mod err { pub const NO_VALID_SNAPSHOT: u32 = 7024; pub const PROPOSAL_PENDING: u32 = 7025; pub const NO_PROPOSAL: u32 = 7026; + pub const WRONG_PROPOSAL_KIND: u32 = 7027; pub const NOT_EXECUTABLE: u32 = 7028; pub const VETOED: u32 = 7029; pub const EXPIRED: u32 = 7030; pub const CANNOT_EJECT: u32 = 7031; + pub const WRONG_SYSVAR: u32 = 7032; pub const WRONG_PROGRAM: u32 = 7033; pub const ABORT_DOES_NOT_FIT: u32 = 7035; pub const BUFFER_IN_USE: u32 = 7036; diff --git a/programs/tests/tests/floor.rs b/programs/tests/tests/floor.rs index 97ed64c..16884ec 100644 --- a/programs/tests/tests/floor.rs +++ b/programs/tests/tests/floor.rs @@ -1877,3 +1877,86 @@ fn registration_names_the_system_program() { assert_eq!(env.fails(&[no_system], &[&team]), err::WRONG_PROGRAM); env.ok(&[reg], &[&team]); } + +/// A stop names its own program, the real sysvars and its own Floor +/// authority, and each is refused with Floor's code. Without these checks +/// the loader would still refuse the upgrade, with no code saying which +/// account was wrong. +#[test] +fn a_stop_names_its_own_program_sysvars_and_authority() { + let mut env = Env::new(); + let p = protect(&mut env, &honest_v1()); + let q = protect(&mut env, &honest_fix()); + let (f, g0) = (&p.f, p.g[0].pubkey()); + // Accounts: 2 programdata, 3 program, 6 rent, 7 clock, 8 authority. + let stop = || f.abort(&g0, &p.abort_buffer, Some(&p.snapshot)); + // Each of the pair on its own (loader.rs:140 checks both). + for at in [2, 3] { + let mut other_program = stop(); + other_program.accounts[at].pubkey = [q.f.programdata, q.f.program][at - 2]; + assert_eq!(env.fails(&[other_program], &[&p.g[0]]), err::PROGRAM_MISMATCH); + } + let mut other_authority = stop(); + other_authority.accounts[8].pubkey = q.f.authority; + assert_eq!(env.fails(&[other_authority], &[&p.g[0]]), err::WRONG_AUTHORITY_ADDRESS); + for (at, other) in [(6, CLOCK), (7, RENT)] { + let mut wrong_sysvar = stop(); + wrong_sysvar.accounts[at].pubkey = other; + assert_eq!(env.fails(&[wrong_sysvar], &[&p.g[0]]), err::WRONG_SYSVAR); + } + env.ok(&[stop()], &[&p.g[0]]); + stopped_with_floor_code(&mut env, &f.program); + assert_eq!(env.call(&q.f.program).map(|_| ()), Ok(()), "the other program still runs"); +} + +/// A quorum restore needs a stop, and a stop needs a staged abort buffer, +/// each refused with its own code. Without the first, a restore while live +/// is still refused (no snapshot is valid while live). Without the second, a +/// stop naming a used-up buffer is still refused (it is not the staged one), +/// but one naming the all-zero address, which equals the empty slot, gets as +/// far as the loader. +#[test] +fn a_restore_needs_a_stop_and_a_stop_needs_an_abort_buffer() { + let mut env = Env::new(); + let p = protect(&mut env, &honest_v1()); + let (f, gs) = (&p.f, p.guardians()); + let restore = f.restore_snapshot(&p.snapshot, &p.owner.pubkey(), &gs[0..2]); + assert_eq!(env.fails(std::slice::from_ref(&restore), &[&p.g[0], &p.g[1]]), err::NOT_ABORTED); + env.ok(&[f.abort(&gs[0], &p.abort_buffer, Some(&p.snapshot))], &[&p.g[0]]); + env.next_slot(); + env.ok(&[restore], &[&p.g[0], &p.g[1]]); + env.next_slot(); + // The stop used the abort buffer up, and nobody has staged another. + assert_eq!(read_config(&env, f).abort_buffer, [0; 32]); + let empty_slot = solana_address::Address::default(); + for buffer in [empty_slot, p.abort_buffer] { + assert_eq!(env.fails(&[f.abort(&gs[0], &buffer, None)], &[&p.g[0]]), err::NO_ABORT_BUFFER); + } +} + +/// A proposal is of a kind Floor knows, and a release names its own +/// programdata. Without the first check an unknown kind would hold the +/// proposal slot until cancelled; without the second the loader would +/// still refuse the release, with no code saying why. +#[test] +fn a_proposal_has_a_known_kind_and_a_release_its_own_programdata() { + let mut env = Env::new(); + let p = protect(&mut env, &honest_v1()); + let q = protect(&mut env, &honest_fix()); + let f = &p.f; + let owner = p.owner.pubkey(); + let zero = solana_address::Address::default(); + assert_eq!(env.fails(&[f.propose(&owner, 99, &zero, &[], None)], &[&p.owner]), err::WRONG_PROPOSAL_KIND); + assert_eq!(read_config(&env, f).pending_kind, 0); + + let new_key = Keypair::new(); + env.ok(&[f.propose(&owner, RELEASE_AUTHORITY, &new_key.pubkey(), &[], None)], &[&p.owner]); + env.advance(3 * DAY); + let release = f.execute_release(&owner, Some(&new_key.pubkey()), &[p.abort_buffer, p.snapshot]); + let mut other = release.clone(); + other.accounts[1].pubkey = q.f.programdata; + assert_eq!(env.fails(&[other], &[&new_key]), err::PROGRAM_MISMATCH); + assert_eq!(env.upgrade_authority(&q.f.programdata), Some(q.f.authority.to_bytes())); + env.ok(&[release], &[&new_key]); + assert_eq!(env.upgrade_authority(&f.programdata), Some(new_key.pubkey().to_bytes())); +} From a1c545afffad481a772dab1ff1e421bf733e92dd Mon Sep 17 00:00:00 2001 From: Shuvam Pandey Date: Fri, 16 Oct 2026 18:13:15 +0545 Subject: [PATCH 5/7] Assert the Floor codes only the sweep and the differential saw Ten of the 34 places the deletion run covers (tasks/error-codes-floor/ mutants.log, base 43bfa31) were killed at base, but only by tests that check that something fails, not with which code: the substitution sweep (every_floor_account_substitution_is_refused) or the random differential (floor_matches_the_core_model_on_random_sequences). So the code each returns was asserted nowhere: 7002 and 7016 not at all, and 7006, 7003, 7017, 7027 not at these sites. New test each_instruction_names_its_own_accounts_and_state. Each case names what the check would otherwise let through, and with the check deleted, the five marked * SUCCEED (STATE=r4c5, "got success"): F09 register.rs:82 config not at Floor's PDA -> WRONG_CONFIG_ADDRESS F10 register.rs:85 authority not at Floor's PDA -> WRONG_AUTHORITY_ADDRESS F16*stop.rs:35 a replacement abort buffer, checked against another program's programdata -> PROGRAM_MISMATCH F18*stop.rs:68 a pin of the other program's code, naming its programdata -> PROGRAM_MISMATCH F22*stop.rs:296 a close of a copy of the live code (which a stop may name, finding 85), naming another programdata -> PROGRAM_MISMATCH, and the copy keeps its rent F24 proposals.rs:73 a restore proposal while live -> NOT_ABORTED F27 proposals.rs:181 an approval of a pending upgrade, by its own id -> WRONG_PROPOSAL_KIND; no approval is recorded F23 proposals.rs:68 an upgrade proposal while stopped -> NOT_LIVE F17*stop.rs:65 a pin while stopped of a copy of what now runs (the abort binary) -> NOT_LIVE F19*stop.rs:117 a second stop, naming the pin, through an abort buffer anyone may stage while stopped -> NOT_LIVE; aborted_at, the pin and its validity are unchanged Found by code review of this branch: pass 1 (NOT_LIVE never asserted by value), passes 2 and 3 (approve a pending UPGRADE, not nothing; each case must reach the path its check guards, not a later refusal). Evidence (tasks/error-codes-floor/mutants.log, STATE=r4c5, full program suite): all ten KILLED by the new test (each also by the sweep or the differential, as at base), and F27b (approve's kind check narrowed to "nothing pending") KILLED: that approval then succeeds. Floor hash 8ca8a608 unchanged. Counts: Floor 56 -> 57, programs 171 -> 172 (claims.py OK). Co-Authored-By: Claude Opus 5.5 --- README.md | 4 +- docs/04-THREAT-MODEL.md | 2 +- docs/09-VERIFICATION.md | 4 +- programs/tests/tests/common/mod.rs | 1 + programs/tests/tests/floor.rs | 73 ++++++++++++++++++++++++++++++ 5 files changed, 79 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 1846bdc..2103c2b 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Bulkhead is a small Solana program that holds a protocol's token accounts on the **[The attack](#what-it-does-to-an-attack)** · **[How it works](#how-it-works)** · **[Verify it](#verify-it-yourself)** · **[Devnet](#live-on-devnet)** · **[FAQ](docs/FAQ.md)** · **[Docs](#documentation)** -[![CI](https://github.com/shuv-amp/bulkhead/actions/workflows/ci.yml/badge.svg)](https://github.com/shuv-amp/bulkhead/actions/workflows/ci.yml) [![devnet](https://img.shields.io/badge/devnet-live-57606A?style=flat-square)](#live-on-devnet) [![Kani](https://img.shields.io/badge/Kani_proofs-19%2F19-57606A?style=flat-square)](docs/09-VERIFICATION.md) [![tests](https://img.shields.io/badge/program_tests-171%2F171-57606A?style=flat-square)](docs/09-VERIFICATION.md) [![audit](https://img.shields.io/badge/audit-not_yet,_not_for_real_funds-E5481B?style=flat-square)](SECURITY.md) [![license](https://img.shields.io/badge/license-Apache--2.0-57606A?style=flat-square)](LICENSE) +[![CI](https://github.com/shuv-amp/bulkhead/actions/workflows/ci.yml/badge.svg)](https://github.com/shuv-amp/bulkhead/actions/workflows/ci.yml) [![devnet](https://img.shields.io/badge/devnet-live-57606A?style=flat-square)](#live-on-devnet) [![Kani](https://img.shields.io/badge/Kani_proofs-19%2F19-57606A?style=flat-square)](docs/09-VERIFICATION.md) [![tests](https://img.shields.io/badge/program_tests-172%2F172-57606A?style=flat-square)](docs/09-VERIFICATION.md) [![audit](https://img.shields.io/badge/audit-not_yet,_not_for_real_funds-E5481B?style=flat-square)](SECURITY.md) [![license](https://img.shields.io/badge/license-Apache--2.0-57606A?style=flat-square)](LICENSE)
@@ -165,7 +165,7 @@ These scripts install nothing. The core has zero dependencies, and Cloud and the | Check | Result (latest run of each) | |---|---| -| **Programs on the real runtime**
LiteSVM, mainnet feature set, mainnet token program | **171/171**: every scenario (S1 Drift, S4 bank run, S7, S8, S9, S10 Floor), the negative tests, measured compute, and an account-substitution sweep of every instruction (7,075 swaps refused, 16 Oct) | +| **Programs on the real runtime**
LiteSVM, mainnet feature set, mainnet token program | **172/172**: every scenario (S1 Drift, S4 bank run, S7, S8, S9, S10 Floor), the negative tests, measured compute, and an account-substitution sweep of every instruction (7,075 swaps refused, 16 Oct) | | **Bounded proofs**
Kani, and exhaustive checks | **19/19 harnesses verified** on 16 Oct (16 for every value of their types), 240 s of verification ([`09 §5`](docs/09-VERIFICATION.md#5-bounded-proofs-kani-and-exhaustive-checks)). 6 exhaustive tests over ~584M inputs | | **Differential**
an independent Python reference vs the Rust core | **6,943,561 lines identical** (6 seeds × 200k cases, 27 Sep); 33 commands now, 300k cases on every pull request and 3M weekly in CI | | **Program vs model** | Random steps on-chain, every outcome equal to the core's prediction: 12,000 (Vault), 300,000 with random limits and every brake (Vault), 200,000 (Floor) | diff --git a/docs/04-THREAT-MODEL.md b/docs/04-THREAT-MODEL.md index ab09d71..47915d8 100644 --- a/docs/04-THREAT-MODEL.md +++ b/docs/04-THREAT-MODEL.md @@ -71,7 +71,7 @@ A security product with a bug is worse than no product. This file lists every ad | I12 | No token leaves a vault except release, settle, lifeboat | program-vs-model differential (vault balance equals the model after every step) | | I13 | Releases fail before the seal | program `nothing_can_be_released_before_the_seal…` | | I14 | `vault.queued_amount == Σ pending tickets` | program-vs-model differential, after every step | -| I15 | Floor: no new binary before 72h unless a quorum approved that exact frozen buffer during a restore, or the snapshot is restored | 56 Floor tests on the real loader (`programs/tests/tests/floor.rs`) | +| I15 | Floor: no new binary before 72h unless a quorum approved that exact frozen buffer during a restore, or the snapshot is restored | 57 Floor tests on the real loader (`programs/tests/tests/floor.rs`) | | I16 | Python reference and Rust core agree on every input | diff (6,943,561 identical lines in the final 6-seed run; 36 fixtures with expected outputs) | ## 4. The #1 risk: a bug in Bulkhead itself diff --git a/docs/09-VERIFICATION.md b/docs/09-VERIFICATION.md index 51bdb18..c817de8 100644 --- a/docs/09-VERIFICATION.md +++ b/docs/09-VERIFICATION.md @@ -31,7 +31,7 @@ The programs are checked against the core as a model (§7). Two implementations | **Bounded proofs (Kani)** | 19 harnesses: logic at full width, 3 at small width (§5) | **19/19 verified** (16 Oct) | | **Coverage-guided fuzzing** | 9 libFuzzer targets (`fuzz/`, cargo-fuzz, overflow checks and AddressSanitizer on): the Token-2022 mint policy, the token-account reader and the guardian-set parser Floor and the Vault share against independent statements of them; the Pyth `PriceUpdateV2` parser against the documented layout; load-store-load round trips of every Vault and Floor account; the loader-v3 parsers and snapshot identity; the limiter at full width (exact `available_now`, instant and queue rules, errors change nothing, window changes keep the used fraction); the ledger (backed ≤ requested, the same amount on a re-ask, `debit_backed` accepts it). Line coverage is measured (`cargo fuzz coverage`); seeds in `fuzz/seeds/` reach what a mutator rarely builds | 6 Oct: 10 min per target, 36M–277M executions each; one harness-oracle crash (finding 40), no program bug; every targeted parser at 100% of lines after the seeds (finding 41; but the same loader target never got past `elf_info`'s magic check in 417M runs on 17 Oct, below). That run had 8 targets; the guardian-set target came on 14 Oct. 17 Oct (`SECONDS_PER=1800 scripts/fuzz.sh`, all 9 targets at once): 30 min per target, 125M–440M executions each (the guardian-set target's 259M), no crash; the two targets changed after it (below) have run 120 s each since, no crash. Region coverage of that corpus (`llvm-cov`, measured by hand) found, among other missed regions, two parsers that their own target never fully ran. Line coverage hid one: the guardian-set target could not build an empty set (every line, 60 of 61 regions). The other is in the loader-parser target, which finding 41's change left decoding its input with `arbitrary` (that finding's cause) and without seeds: no input got past `elf_info`'s ELF magic check. After a fix to the guardian-set target, and the loader target moved to raw bytes with four ELF-header seeds, their corpora and seeds run `GuardianSet::parse` and `elf_info` at every line and region (`llvm-cov` after 120 s runs, 17 Oct); the loader target now catches a mutant (`elf_info` reading past a short header) within seconds, even unseeded, that 45M runs of the old one missed. It checks only `snapshot_matches`' result and runs the other parsers for panics only (`elf_info`'s values are checked by golden G-13 and the property and unit tests). The other regions the targets miss in the functions they call are not listed here in full: some are unreachable, and some are refusals no harness asks for, which the fuzzing does not test (a closed limiter lane: the target makes every capacity at least 1; a full ledger: the ledger target uses at most 4 distinct mints). No target calls `elf_extent`, `snapshot_restorable` (finding 88's length rule) or `is_canonical_abort`: unit tests and the core's mutation testing (§6) check them (`is_canonical_abort` also the differential's `FC` command), the fuzzer does not. CI: 60 s per target (25 min weekly, §8) | | **Mutation testing** | `cargo-mutants` on the core: 797 mutants (run 10, §6), and in CI on every pull request's changed lines | Every non-equivalent mutant killed; 22 equivalents, each explained and excluded by exact pattern | -| **Program tests** | Floor (56) and Vault (115) on the real agave runtime: LiteSVM, mainnet feature set, the mainnet token program | 171/171 | +| **Program tests** | Floor (57) and Vault (115) on the real agave runtime: LiteSVM, mainnet feature set, the mainnet token program | 172/172 | | **Account substitution** (`programs/tests/tests/common/sweep.rs`) | For every Vault and Floor instruction (all 30 of the Vault's, tags 0–29, including the read-only views `attest` and `quote_release` and both scopes of `unfreeze`; registration both by the caller PDA and by the upgrade authority; the Floor lifecycle end to end): a transaction that succeeds, then each account swapped in turn for a fresh address, every other account of the transaction, a second market's or a second protected program's accounts, a stranger's token accounts and buffers, other tickets, programs and sysvars, and for a signer every other known key; then each key that signs at any slot (a free one included) and stands at a checked slot: unsigned at every checked slot (a free slot where it signed gets the payer, once a control shows the payer is accepted there; not for the fee payer, which signs anyway), since signing is per key and unsigning one slot of a key that signs at another proves nothing. A key at several slots is otherwise swapped one slot at a time, so a check that only compares those slots with each other is not tested by a consistent attacker key at all of them. Every swap must fail, except at the positions each program leaves free on purpose, each listed with its reason (a rent payer, a ticket account only used when part of a release queues, another guardian of the same set). The first version missed two of four bugs planted to test it (a settle that pays anyone, a cancel of another vault's ticket): it had no look-alike token account or ticket to offer. With them, all four are caught | 16 Oct, with four guardians in the test sets (finding 107; an eject's signers may now be any two of the three others, so each of those slots is free for the third, never for the target or the other signer again; with a guardian listed twice counted as two, the sweep fails): 5,365 Vault and 1,710 Floor substitutions (37 and 18 transactions), refused. 16 Oct, with `attest`, `quote_release` (read-only accounts, quoting an owner's own deposit; as in every release here, the price slot is left free) and the vault-scope `unfreeze`: 5,308 Vault and 1,683 Floor substitutions (37 and 18 transactions), refused. Each of three one-site mutants fails the sweep and passes without those three runs: `attest` not checking its token account, a quote skipping the vault-account check a release makes, and the vault-scope `unfreeze` loading a vault without checking its protocol. 16 Oct, with signing keys tried per key (before, a key that signs at two slots was never tried unsigned: the user of Harbor's deposit and withdraw; with the withdraw's signer check deleted, the sweep now fails): 4,887 Vault and 1,683 Floor substitutions (34 and 18 transactions; one of the 34, "withdraw (signed at the free slot only)", repeats Harbor's withdrawal with the user signing only at a free slot, which adds no program coverage; the test checks that the user was tried unsigned there, so it fails if the sweep stops picking such a key), refused. 10 Oct, with a release to none signed by the owner (finding 95; with that check deleted, the sweep accepts the owner unsigned and fails): 4,499 Vault and 1,683 Floor substitutions (33 and 18 transactions), refused (9 Oct, with `close_buffer`, the signing release and the exit's account 6: 4,508 and 1,549; 8 Oct: 4,474 and 1,472). Found finding 53. Accepted and explained: a veto of a lifeboat exit where none is pending changes nothing (the next proposal clears it) | | **Program ↔ model differential** | Random operation sequences on-chain vs a host model built only from the core; invariants after every step (§7) | 12,000 steps across 24 seeds, identical; 24,000 steps across 24 seeds after the A1 fix (29 Sep), identical | | **Wide program differential** | The same, with a limit configuration drawn per seed (floors and caps far above the balance, a closed lane, a queue delay past the horizon) and every instruction that changes what can leave: protocol and vault freezes, quorum unfreezes, ticket extensions, backlog resets, lifeboat moves both ways, limit changes; `quote_release` against the release, every `attest` field against the core (§7) | 5 Oct: 200,000 steps across 400 configurations, then 100,000 with limit changes after finding 30, identical | @@ -84,7 +84,7 @@ scripts/mutants.sh # mutation testing, release profile (~45 scripts/fuzz.sh # libFuzzer, every target 60 s in parallel (SECONDS_PER=600 for longer) (cd fuzz && cargo clippy --all-targets -- -D warnings) # lint the fuzz crate (its own workspace; CI's fuzz job) scripts/build-programs.sh # Floor, Vault, Harbor for sBPF v3; checks e_flags == 3 -(cd programs/tests && cargo test --release) # 171 program tests + the program-vs-model differentials +(cd programs/tests && cargo test --release) # 172 program tests + the program-vs-model differentials (cd programs/tests && BULKHEAD_PROGRAM_SEEDS=24 BULKHEAD_PROGRAM_STEPS=500 cargo test --release --test differential) cloud/e2e/run.sh # validator + guardian + attacker node --test cloud/test/*.test.mjs # client, policy, JS vs Python vs Rust differential (needs the worker) diff --git a/programs/tests/tests/common/mod.rs b/programs/tests/tests/common/mod.rs index 035d621..51daff9 100644 --- a/programs/tests/tests/common/mod.rs +++ b/programs/tests/tests/common/mod.rs @@ -33,6 +33,7 @@ pub const T0: i64 = 1_790_000_000; // a fixed start time (Sep 2026) pub mod err { pub const INVALID_INSTRUCTION: u32 = 7000; pub const NOT_A_FLOOR_CONFIG: u32 = 7001; + pub const WRONG_CONFIG_ADDRESS: u32 = 7002; pub const WRONG_AUTHORITY_ADDRESS: u32 = 7003; pub const NOT_LOADER_V3: u32 = 7005; pub const PROGRAM_MISMATCH: u32 = 7006; diff --git a/programs/tests/tests/floor.rs b/programs/tests/tests/floor.rs index 16884ec..d6f0b7c 100644 --- a/programs/tests/tests/floor.rs +++ b/programs/tests/tests/floor.rs @@ -1960,3 +1960,76 @@ fn a_proposal_has_a_known_kind_and_a_release_its_own_programdata() { env.ok(&[release], &[&new_key]); assert_eq!(env.upgrade_authority(&f.programdata), Some(new_key.pubkey().to_bytes())); } + +/// Refusals the substitution sweep or the random differential already see +/// fail, here asserted by their own code: Floor's PDAs at registration, each +/// instruction's own programdata, and what needs the program live or stopped. +#[test] +fn each_instruction_names_its_own_accounts_and_state() { + let mut env = Env::new(); + let p = protect(&mut env, &honest_v1()); + let q = protect(&mut env, &honest_fix()); + let (f, gs) = (&p.f, p.guardians()); + let owner = p.owner.pubkey(); + let elsewhere = solana_address::Address::new_unique(); + + // Registration: Floor's config and authority PDAs (accounts 1 and 2). + let team = Keypair::new(); + env.fund(&team); + let (program, _) = env.deploy(&honest_v1(), &team, 2048); + let reg = Floor::new(env.floor, program).register(&env.payer.pubkey(), &team.pubkey(), &team.pubkey(), &gs, 2, 7 * DAY, 3 * DAY); + for (at, code) in [(1, err::WRONG_CONFIG_ADDRESS), (2, err::WRONG_AUTHORITY_ADDRESS)] { + let mut ix = reg.clone(); + ix.accounts[at].pubkey = elsewhere; + assert_eq!(env.fails(&[ix], &[&team]), code); + } + + // Another program's programdata, each checked against what the named + // programdata would pass: a replacement abort buffer (account 2), a pin + // of the other program's code (1), and a close (5) of a copy of this + // program's live code, which a stop may name (finding 85). + let frozen = |env: &mut Env, elf: &[u8]| { + let b = env.write_buffer(elf, &p.owner); + env.set_buffer_authority(&b, &p.owner, &f.authority); + b + }; + let (new_abort, copy_of_q, copy_of_live) = (frozen(&mut env, &ABORT_ELF), frozen(&mut env, &honest_fix()), frozen(&mut env, &honest_v1())); + let mut stage = f.stage_abort_by(&new_abort, &gs[0..2]); + stage.accounts[2].pubkey = q.f.programdata; + assert_eq!(env.fails(&[stage], &[&p.g[0], &p.g[1]]), err::PROGRAM_MISMATCH); + let mut pin = f.pin_snapshot(©_of_q); + pin.accounts[1].pubkey = q.f.programdata; + assert_eq!(env.fails(&[pin], &[]), err::PROGRAM_MISMATCH); + let mut close = f.close_buffer(&owner, ©_of_live); + close.accounts[5].pubkey = q.f.programdata; + assert_eq!(env.fails(&[close], &[&p.owner]), err::PROGRAM_MISMATCH); + let c = read_config(&env, f); + assert_eq!((c.abort_buffer, c.snapshot_buffer), (p.abort_buffer.to_bytes(), p.snapshot.to_bytes())); + assert!(env.account(©_of_live).lamports > 0); + + // Live: no restore proposal, and only a restore is approved: not a + // pending upgrade, even by its own id. + let fix = frozen(&mut env, &honest_fix()); + assert_eq!(env.fails(&[f.propose(&owner, RESTORE, &fix, &[], Some(&fix))], &[&p.owner]), err::NOT_ABORTED); + env.ok(&[f.propose(&owner, UPGRADE, &fix, &[], Some(&fix))], &[&p.owner]); + let pid = read_config(&env, f).pending_id; + assert_eq!(env.fails(&[f.approve(pid, &gs[0..2])], &[&p.g[0], &p.g[1]]), err::WRONG_PROPOSAL_KIND); + assert_eq!(read_config(&env, f).pending_approvals, 0); + env.ok(&[f.cancel(&owner)], &[&p.owner]); + + // Stopped: no upgrade proposal, no new pin, and no second stop, even + // through an abort buffer anyone may stage while stopped. + env.ok(&[f.abort(&gs[0], &p.abort_buffer, Some(&p.snapshot))], &[&p.g[0]]); + env.next_slot(); + assert_eq!(env.fails(&[f.propose(&owner, UPGRADE, &fix, &[], Some(&fix))], &[&p.owner]), err::NOT_LIVE); + // A copy of what now runs, the abort binary, would replace the pin. + let copy_of_abort = frozen(&mut env, &ABORT_ELF); + assert_eq!(env.fails(&[f.pin_snapshot(©_of_abort)], &[]), err::NOT_LIVE); + let abort2 = frozen(&mut env, &ABORT_ELF); + env.ok(&[f.stage_abort(&abort2)], &[]); + let aborted_at = read_config(&env, f).aborted_at; + env.advance(DAY); + assert_eq!(env.fails(&[f.abort(&gs[1], &abort2, Some(&p.snapshot))], &[&p.g[1]]), err::NOT_LIVE); + let c = read_config(&env, f); + assert_eq!((c.aborted_at, c.snapshot_buffer, c.snapshot_valid), (aborted_at, p.snapshot.to_bytes(), 1)); +} From 4acfa1bc0204aea30bef0e4d0f61c73914693ac2 Mon Sep 17 00:00:00 2001 From: Shuvam Pandey Date: Fri, 16 Oct 2026 17:56:45 +0545 Subject: [PATCH 6/7] Record the Floor refusal deletions and what each became MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit docs/09 §3 gains a row beside the Vault one, for the Floor deletion run this branch answers (tasks/error-codes-floor/mutants.log): every place that returns one of the 14 Floor codes no test asserted by value (7001-7006, 7010, 7016, 7017, 7019, 7027, 7032-7034), 34 in all, each removed on its own with the whole program suite run against it, on the AUD-2 build: a `return Err` dropped, a checked value's `?` replaced by a default (proposals.rs:120, :443), a match arm's error made a success (:245). register.rs:69 and the interval mapping guardians.rs:49 return a value that cannot be dropped, so they were changed to another code. At base: 10 KILLED, all by the sweep or the differential, which do not check the code ("Assert the Floor codes only the sweep and the differential saw" asserts each), and 24 SURVIVED. (The first run reported F30 KILLED with no test named: that run died partway. Run alone, F30 survives with every suite green; the runner now reports such a run as ABORTED.) The first four Floor commits on this branch kill 15 of the 24 (F01 F02 F13, F06 F07 F08, F05 F34, F12 F14 F15 F20 F21 F25 F31). The row says how register.rs:69 is reached (one transaction: the loader's Close of the programdata, then the registration; found by B's review of r5, which called it unreachable). It names the 9 that still survive and why no transaction is known to reach them: - state.rs:174 (stored bounds), :181 (length at store): Floor creates an account only in register (register.rs:105-145), at the config's length, and stores only checked values (payload proposals.rs:62, guardian sets parsed). - register.rs:88: :70 refuses a second registration first (NOT_CURRENT_AUTHORITY, seen while writing the system-program test). B's review tried a same-transaction release then register: the release closes the config, and with Floor holding the key nobody can sign as the current authority. - proposals.rs:120, :443: u64 proposal id; lamport sum. - proposals.rs:245, :496: propose refuses an unknown kind (:104). - proposals.rs:273, :278: an UPGRADE is proposed only while live (:68), a RESTORE only while stopped (:73); a stop and each return to live clear the owner's proposal (stop.rs:176, :252, proposals.rs:317); the recovery key proposes only SET_OWNER or SET_RECOVERY (:28). Re-run on 17 Oct at this branch's tip, all 43 mutants of tasks/error-codes-floor/mutants.txt plus F08o (:69 mapped to Overflow, B's form of F08), with the whole program suite (tasks/floor-error-tests-r6/mutants.log, STATE=r6tip): 34 KILLED, 10 SURVIVED (the 9 above and F06b), each the same as in the 16 Oct tip run (tasks/error-codes-floor/run-tip.out) except F02 and F08, now KILLED. The programs did not change: git diff --stat 43bfa31 HEAD -- programs/floor programs/vault/src crates/bulkhead-core/src is empty, and the Floor hash is 8ca8a608 before and after. The row also says that the programdata clause of register.rs:57 is covered only jointly with :63 (F06b survives alone). It ends with the two codes still asserted by no test, AlreadyRegistered (register.rs:88) and Overflow (proposals.rs:120, :443), each returned only by one of the 9. And it says what was not deleted: the calls of the shared checks check_program_accounts and check_authority, only their returns (loader.rs:141, lib.rs:200). With each of the eight calls replaced by `let _ = ...` (tasks/floor-check-calls/mutants.log, 17 Oct), the two in a stop are KILLED, and the six in restore_snapshot, close_buffer, execute_code and execute_release SURVIVE with every test green, the sweep included: the loader still refuses, with no Floor code. Those are a follow-up of their own. Docs only: no count change (claims.py OK: Floor 57, programs 172). Co-Authored-By: Claude Opus 5.5 --- docs/09-VERIFICATION.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/09-VERIFICATION.md b/docs/09-VERIFICATION.md index c817de8..882926f 100644 --- a/docs/09-VERIFICATION.md +++ b/docs/09-VERIFICATION.md @@ -367,6 +367,7 @@ The overflow guards stay in the code as defense in depth; the tests document why | **Scenarios** | S1 (G-1 second-for-second, including the EMA reference), S4 (a 20-depositor bank run during a freeze, 100% instant, no prices), S7, S8 (ten payouts in one transaction), S9 (backed exactly as the core computes), S10 (Floor lifecycle) | Pass | | **Negative tests** | Wrong caller, missing or foreign asset account, wrong feed, frozen settlement, early settlement, wrong recipient, tickets pending, not sealed, import exceeding balance, seal veto, permanent-delegate mint, delay below 72h, abdicated kind, freeze too long, no quorum, admin unfreeze, eject below threshold, and Floor's full set (`06 §6`) | Pass | | **Vault refusals deleted one at a time** | 16 Oct, on the AUD-2 build: 38 refusals, across 14 of the 18 Vault codes no test asserted by value, deleted one at a time with the whole program suite run against each. Not deleted: the two places that map a core error to `ChangeExecuted` and `ZeroAmount`, `token.rs:233`, and two of the codes, `Overflow` and `LedgerCorrupt` (checked arithmetic, decoding). The other two, `ExtensionTooLong` and `LaneClosed`, the run missed; the review deleted one check of each: the 7-day total on a ticket's extensions (`brakes.rs:86`) and the mapping of a closed lane (`custody.rs:240`) | 13 failed a test, 25 survived. 18 of the 25 survivors now fail a test that asserts the Vault's own code. Among them: another protocol's guardian extending a ticket, a seal that leaves a vault out, invalid limits and assets in a proposed change, an import into a ninth mint, and a quote to an account no token program owns. The review's two also survived, and both now fail such a test: the 7-day total (docs/05 row 11), which the wide differential modelled but whose default run never extended one ticket that far (later the same day the default run was changed to push tickets to the total and 1 s past it), and a closed lane's code; the same tests pin an extension that moves the ETA earlier, one over 24h, and a lane closed by either bucket. Of the 25's other 7, six are guards no transaction is known to reach: the vault PDA address (`lib.rs:324`; `create_vault` creates a vault only at its PDA), the seal's checks of a lifeboat's owner, mint and authority (`genesis.rs:519`, `:523`; at the seal no lifeboat holds data: only `lifeboat_move` creates one, `move_in` requires the seal (`lifeboat.rs:53`), and the seal happens once), a pending-ticket count below zero (`brakes.rs:50`, `custody.rs:541`; each ticket adds one when created and is closed once), and `GetAccountDataSize`'s return data from an already-checked token program (`token.rs:235`). The seventh, `custody.rs:399` (`debit_backed` of what `backed_amount` allowed, or less after the consent and freeze caps), is **not shown unreachable**: the core property test debits `backed_amount` itself and one more on random ledgers; less is debited only on a one-mint ledger with no liability (`crates/bulkhead-core/tests/units.rs:375`). `backed_amount_is_monotone_in_request` (`properties.rs:606`) asserts `backed(a) == min(a, backed(MAX))` on random ledgers and requests below 2^52 (`:613`), so any amount up to what `backed_amount` allowed is itself backed, and `debit_backed(b)` refuses only when `backed_amount(b) != b` (`ledger.rs:289`) or a new slot would be needed on a full ledger, which `backed_amount` refuses first (`ledger.rs:237`). That is an argument from a property test, not a proof. The one known exception is a collateral value that overflows u128 (`ledger.rs:262`): there the valid amounts need not form an interval, so the consent or freeze cap (`custody.rs:337`, `:347`) can lower the amount to one that is not valid, and `:399` refuses the release (fail closed). The search's own result is always valid: it keeps only amounts it has checked. Five codes no test asserts by value remain: `NotRegistrar` (its one check fails another test), `TicketNotPending` and `LedgerUnsound` (the survivors above), `Overflow` and `LedgerCorrupt` | +| **Floor refusals deleted one at a time** | 16 Oct, on the AUD-2 build: every place that returns one of the 14 Floor codes no test asserted by value, 34 in all, each removed on its own with the whole program suite run against it: a `return Err` dropped, a checked value's `?` replaced by a default (`proposals.rs:120`, `:443`), a match arm's error made a success (`:245`), and where the code is a value that cannot be dropped (`register.rs:69`, the interval mapping `guardians.rs:49`), changed to another code. Not deleted: the calls of the two shared checks, `check_program_accounts` and `check_authority`; only their returns were (`loader.rs:141`, `lib.rs:200`) | 10 failed a test, but only the substitution sweep or the random differential, which check that a step fails and not with which code; each now also fails a test that asserts it. 24 survived, and 15 of those now fail a test that asserts Floor's own code. Among them: a copy of a config under another owner, which would let a stranger close the real abort buffer (`lib.rs:179`), an account Floor owns but never wrote, which anyone can create (`state.rs:132`), a pin of a buffer the loader does not own (`loader.rs:14`), and a registration of another team's program with the registrant's own programdata, which would take that program's config address (`register.rs:63`). A programdata without a header (`register.rs:69`) is reached in one transaction by the program's upgrade authority: a loader Close of the programdata, then the registration, while the closed programdata is still the loader's and the program still names it. Of `register.rs:57`, only the program clause is pinned alone: the programdata clause is covered jointly with `:63`, since a program the loader owns names its own programdata. The other 9 are guards no transaction is known to reach: a config's stored bounds (`state.rs:174`) and its length when stored (`:181`; Floor creates an account only at registration, at the config's length, and stores only checked values), a second registration (`register.rs:88`; Floor holds the upgrade key, so `:70` refuses it first, and a release closes the config as it hands the key back), the proposal id and a lamport sum overflowing (`proposals.rs:120`, `:443`), an unknown kind at execution (`:245`, `:496`; `propose` refuses it, `:104`), and an upgrade executed while stopped or a restore while live (`:273`, `:278`; each is proposed only in the other state, `:68`, `:73`, and every change of state clears the owner's proposal, `stop.rs:176`, `:252`, `proposals.rs:317`; the recovery key proposes only a new owner or recovery key, `proposals.rs:28`). Two codes no test asserts by value remain, each returned only by one of these 9: `AlreadyRegistered` (`register.rs:88`) and `Overflow` (`proposals.rs:120`, `:443`) | | **Floor on a real program** | `scripts/floor-demo.sh `: a mainnet program's bytes on a local validator with mainnet's feature set; register, stop with one guardian, restore with two | SPL Stake Pool (1.08 MB, v0): stopped with Floor's code, restored byte-identical (`06 §7`) | | **Our own SIMD-0500 check** | `scripts/build-programs.sh` reads each built `.so` with the reference's `elf_info` and fails unless `e_flags == 3` | Floor, Vault, Harbor: v3 | | **Compute** | Measured through Harbor's CPI (`05 §10`) and for Floor (`06 §7`) | Within targets | From c90d85ad4af082a107aefe2fc1997c72a225940e Mon Sep 17 00:00:00 2001 From: Shuvam Pandey Date: Sat, 17 Oct 2026 14:07:50 +0545 Subject: [PATCH 7/7] Record finding 110: 24 of 34 Floor refusals survived deletion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Floor deletion run of 16 Oct (09 §3, "Floor refusals deleted one at a time", recorded in the previous commit) is finding 108's sibling: every place that returns one of the 14 Floor codes no program test asserted by value, deleted on its own with the whole program suite run against it. 24 of 34 survived; the other 10 failed only the sweep or the random differential. That is finding 106's class, enforced but untested rules, so it is a finding of its own (reserved 17 Oct 08:08Z, FINDINGS-RESERVED). The row restates the §3 row and adds nothing to it: what survived (the config copy that lets a stranger close the real abort buffer, an account Floor owns but never wrote, a pin of a buffer the loader does not own, another team's program registered with the registrant's programdata), the 15 now pinned plus the 10 the sweep and differential saw, and the 9 left (no transaction known to reach them) with register.rs:57's joint clause. The two test names cited each exist once in programs/tests/tests/floor.rs (git grep -c). The programs did not change on this branch (see the previous commit). README:194 and docs/12:22 count 110 findings, 96-110 recorded 13-17 Oct. tools/claims.py: claims OK (26 files), findings 110. Co-Authored-By: Claude Opus 5.5 --- README.md | 2 +- docs/09-VERIFICATION.md | 1 + docs/12-SUBMISSION.md | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2103c2b..437fb76 100644 --- a/README.md +++ b/README.md @@ -175,7 +175,7 @@ These scripts install nothing. The core has zero dependencies, and Cloud and the | **Golden vectors**
every worked example in the docs, exact boundaries, the abort binaries' bytes, loader layouts | 119/119 identical, Rust = Python | | **End to end** | [Above](#what-it-does-to-an-attack) | | **On devnet** | All three programs run the build of PR #85 (15 Oct; this tree's Floor and Vault add finding 107, not deployed yet), matched byte for byte against CI's build of that commit, upgrade authority checked. **S1 ran there on 1 Oct**: the admin key ordered 1.2M, 100,000 left, the guardian froze and cancelled the other 11. Floor S10 with real transactions: one guardian stops, two restore byte-identical, 17/17 forbidden actions refused ([below](#live-on-devnet)) | -| **What this process found**
in our own code and docs | **109 findings**: real bugs, two overclaimed guarantees, test gaps, deploy-tooling hazards, and the attacks of adversarial reviews and audits. Each is fixed or stated ([`09 §4`](docs/09-VERIFICATION.md#4-what-this-process-found-every-item-fixed-or-stated)); 96–109 were recorded after the submission (107 is the engagement's AUD-2, decided 16 Oct): 96–99, 101 and 103 are fixed and run on devnet since 15 Oct; 105 (CI tooling), 106 and 108 (Vault tests), 107 (the guardian margin, not yet on devnet) and 109 (fuzz targets) are fixed; 100, 102 and 104 are stated. The Rust core and the Python reference shared one bug; only a third, independent statement of the rule caught it. | +| **What this process found**
in our own code and docs | **110 findings**: real bugs, two overclaimed guarantees, test gaps, deploy-tooling hazards, and the attacks of adversarial reviews and audits. Each is fixed or stated ([`09 §4`](docs/09-VERIFICATION.md#4-what-this-process-found-every-item-fixed-or-stated)); 96–110 were recorded after the submission (107 is the engagement's AUD-2, decided 16 Oct): 96–99, 101 and 103 are fixed and run on devnet since 15 Oct; 105 (CI tooling), 106 and 108 (Vault tests), 107 (the guardian margin, not yet on devnet), 109 (fuzz targets) and 110 (Floor tests) are fixed; 100, 102 and 104 are stated. The Rust core and the Python reference shared one bug; only a third, independent statement of the rule caught it. | ## Live on devnet diff --git a/docs/09-VERIFICATION.md b/docs/09-VERIFICATION.md index 882926f..e4d56c5 100644 --- a/docs/09-VERIFICATION.md +++ b/docs/09-VERIFICATION.md @@ -213,6 +213,7 @@ cloud/e2e/s1.sh # S1 with the guardian on any | 107 | 9 Oct | `16` AUD-2 (the pre-audit engagement; stated in finding 89 as a decision left to the team), researched on 15 Oct with an exhaustive model of the eject and veto rules and LiteSVM runs of the lock (scratch, not kept), decided by the owner on 16 Oct (`16` §4.4) | **One lost key and one rogue guardian locked a 2-of-3 set for good.** A set is live while its honest live guardians reach the threshold: they then eject every rogue in turn, and the owner's new set passes, since dead guardians cannot veto. Finding 96 required one key beyond the threshold, so a 2-of-3 (or 3-of-4) set survived one fault but not a lost key plus a rogue: the honest guardian left was no quorum, nobody could be ejected, and the rogue kept Floor stopped (or the Vault frozen, renewed daily) and vetoed every RESTORE, SetGuardians and release as it was proposed. Own deposits still left (G2). The same held after an ejection had used up the one spare key. No rule that lets the owner override a veto avoids this without also handing a stolen owner key plus one rogue guardian the set (`16` §4.4). | Fixed (on-chain, Floor and Vault; not yet on devnet). `guardian_set_ok` now needs `count ≥ threshold + GUARDIAN_MARGIN` with a margin of 2: at least 4 keys, 2 ≤ threshold ≤ count − 2. Both programs check every new set with it, at registration and when a SetGuardians is proposed and again when it executes; a stored set is never checked again, so existing 2-of-3 sets keep working (and keep their exposure) until their owner replaces them, and an ejection may still shrink a set. Ejection is unchanged. Kani: `accepted_sets_survive_any_two_faults` (any two faulty keys in any slots leave a live honest quorum, which ejects each rogue, and the rogues alone eject no honest guardian; short of a rogue quorum, since two rogues in a 2-of-n set are one, out of scope by `04` T7, and without that assumption the harness fails), `an_honest_live_quorum_ejects_any_rogue` (such a quorum ejects every rogue, wherever the slots sit), and `accepted_sets_can_eject_anyone` restated (ejection reachable exactly when count > threshold, so a shrunk set still ejects; the margin is at least 2, and 2 is accepted). Mutants of the rule (margin 1 or 3, `>`, threshold ≥ 1, count ≤ 9, and refusing an eject that leaves count ≤ threshold + 1, an option `16` §4.4 rejects) and an eject one vote short each fail a harness; an eject that ignores liveness fails none of these three. Tests: `a_guardian_set_without_two_spare_keys_is_refused` (Floor and Vault; the execution check on a stored proposal), `registration_rejects_weak_settings` (Floor); the recovery on 2-of-4: `a_lost_key_and_a_rogue_do_not_lock_a_two_of_four_set`, `two_rogues_in_turn_are_both_ejected_from_a_two_of_four_set`, `a_lost_key_and_a_rogue_do_not_lock_a_two_of_four_vault`. The Python model and the `guardian_set` fuzz target state the new rule; with the model's margin put back to 1, the `GP` differential diverges on each of seeds 11–13 (20,000 cases). | | 108 | 16 Oct | Finding 106's follow-up: 38 Vault refusals, across 14 of the 18 codes no program test asserted by value, deleted one at a time with the whole program suite run against each, on the AUD-2 build (§3, "Vault refusals deleted one at a time"; `Overflow` and `LedgerCorrupt` not deleted) | **25 of 38 Vault refusals survived deletion.** Finding 106's class: rules enforced but untested. Among them: another protocol's guardian extending a ticket, a seal that leaves a vault out, invalid limits and assets in a proposed change, an import into a ninth mint, and a quote to an account no token program owns. The run missed two codes; the review deleted one check of each, and both also survived: the 7-day total on a ticket's extensions (`brakes.rs:86`, `05` row 11) and a closed lane's code (`custody.rs:240`). | Fixed (tests; the programs are unchanged). 18 of the 25 and the review's two now fail a test that asserts the Vault's own code (among them `an_import_into_a_ninth_mint_is_refused`, `invalid_limits_and_assets_are_refused_wherever_they_enter`, `a_ticket_is_extended_later_by_at_most_a_day_a_call_and_seven_in_total`, `a_closed_lane_refuses_an_unbacked_payout`). Stated: six of the other 7 guard states no transaction is known to reach; the seventh (`custody.rs:399`) is not shown unreachable, only argued from a property test. Each is in the §3 row. | | 109 | 17 Oct | Region coverage (`cargo fuzz coverage`, `llvm-cov`) of the corpus of a 30-minute run of every fuzz target, measured by hand (§2) | **Two fuzz targets never fully ran the parser they exist for.** The guardian-set target skipped inputs under 66 bytes, so it never parsed an empty set: `GuardianSet::parse` ran at every line but 60 of 61 regions, and a mutant of its empty-set error (`governance.rs:192`) passed 23M runs. The loader-parser target, which finding 41's change left decoding its input with `arbitrary` (that finding's cause) and without seeds, never got past `elf_info`'s ELF magic check in 417M runs, and missed a mutant reading past a short header in 45M. Line coverage hid the first; the second sits under §2's 6 Oct "every targeted parser at 100% of lines" (that corpus is not kept, so whether the 6 Oct run got past the check is not known). No target calls `elf_extent`, `snapshot_restorable` or `is_canonical_abort`. | Fixed (fuzz targets; the core and programs are unchanged). The guardian-set target accepts a 65-byte input, the flags and two forbidden keys with an empty set after them (and has a seed of one); the loader target takes raw bytes with four ELF-header seeds. Both parsers now run at every line and region, and each mutant fails within seconds (the short-header one unseeded too). Stated: `elf_extent`, `snapshot_restorable` and `is_canonical_abort` stay unfuzzed; unit tests and the core's mutation testing check them (§2). | +| 110 | 16 Oct | Finding 108's sibling for Floor: every place that returns one of the 14 Floor codes no program test asserted by value, 34 in all, deleted one at a time with the whole program suite run against each, on the AUD-2 build (§3, "Floor refusals deleted one at a time") | **24 of 34 Floor refusals survived deletion.** Finding 106's class: rules enforced but untested. Among them: a copy of a program's config under another owner, which would let a stranger close the real abort buffer and take its rent, so that every stop fails until a live quorum stages another (`lib.rs:179`); an account Floor owns but never wrote, which anyone can create (`state.rs:132`); a pin of a buffer the loader does not own (`loader.rs:14`); and a registration of another team's program with the registrant's own programdata (`register.rs:63`). The other 10 failed only the substitution sweep or the random differential, which do not check the code. | Fixed (tests; the programs are unchanged). 15 of the 24 now fail a test that asserts Floor's own code (among them `floor_reads_only_a_config_it_wrote_and_a_buffer_the_loader_owns` and `registration_reads_only_the_programs_own_programdata`), and so do the 10 that failed only the sweep or the differential. Stated: the other 9 of the 24 guard states no transaction is known to reach, and the programdata clause of `register.rs:57` is covered only jointly with `:63`. Each is in the §3 row. | Same review, not changed then: the guardian-set checks were written once in each program. Since PR #83 (finding 103), both use one `GuardianSet` in the core, covered by the `guardian_set` fuzz target, the `GP` differential and unit tests (its bitmaps are Kani-proved; a Kani proof of the parser did not finish, §5.3). `Change` payloads are now copied in one slice instead of byte by byte (fewer compute units), and the Ticket layout comment names the real seeds. diff --git a/docs/12-SUBMISSION.md b/docs/12-SUBMISSION.md index c1c4f89..a3f6e00 100644 --- a/docs/12-SUBMISSION.md +++ b/docs/12-SUBMISSION.md @@ -19,7 +19,7 @@ Bulkhead was submitted to the Colosseum Crypto World's Fair (Solana track) on 12 | Floor on a real 1 MB mainnet program's bytes | `scripts/floor-demo.sh ` (`06 §7`) | | The attacker-vs-guardian run, end to end | `E2E=1 scripts/check-programs.sh` | | Every test, proof and differential result | `09`; `scripts/check.sh`, `scripts/check-programs.sh`, `scripts/prove.sh` | -| Every bug the process found in our own code | `09 §4` (95 findings at submission; 96–109 recorded 13–17 Oct: 96–99, 101 and 103 fixed and on devnet since 15 Oct, 105 fixed (CI tooling), 106 and 108 fixed (Vault tests), 107 fixed (AUD-2, the guardian margin; not yet on devnet), 109 fixed (fuzz targets), 100, 102 and 104 stated); `16` | +| Every bug the process found in our own code | `09 §4` (95 findings at submission; 96–110 recorded 13–17 Oct: 96–99, 101 and 103 fixed and on devnet since 15 Oct, 105 fixed (CI tooling), 106 and 108 fixed (Vault tests), 107 fixed (AUD-2, the guardian margin; not yet on devnet), 109 fixed (fuzz targets), 110 fixed (Floor tests), 100, 102 and 104 stated); `16` | | Every number's source and label (measured, reported, model, assumption) | `01`, `13` | ## 3. Go-to-market