|
| 1 | +# Ethereum client security checklist & test plan |
| 2 | + |
| 3 | +A working checklist for auditing or hardening an Ethereum client, built by reading |
| 4 | +the actual fixes in this corpus and keeping the ones that recur. Items are ordered |
| 5 | +by impact: the consensus and value core first (a bug there splits the chain or |
| 6 | +moves ETH), then the availability surface (a bug there drops the node). Each item |
| 7 | +names a real fix that motivates it and how to test it. |
| 8 | + |
| 9 | +Use it two ways: as a review checklist against an implementation, and as a test |
| 10 | +matrix — the *unit* column is what to fuzz or property-test in isolation, the |
| 11 | +*e2e* column is what to exercise on a multi-client devnet. |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | +The heatmap is the quick orientation: `missing_input_validation`, |
| 16 | +`resource_exhaustion`, `integer_overflow`, and `consensus_divergence` carry the |
| 17 | +most High-severity fixes, and they land hardest in the state trie, p2p, sync, |
| 18 | +fork-choice, and the beacon-chain state transition. |
| 19 | + |
| 20 | +--- |
| 21 | + |
| 22 | +## Tier 1 — Consensus & value core |
| 23 | + |
| 24 | +A wrong result here is a chain split or forged value. Read this code line by line. |
| 25 | + |
| 26 | +### EVM, opcodes & precompiles |
| 27 | + |
| 28 | +- [ ] **Every opcode handles boundary operands** (zero, max, oversized shift) with |
| 29 | + the spec's result and no native exception. *(besu: SHL/SHR/SAR native exception |
| 30 | + at key values; geth: RETURNDATA corruption via `datacopy`)* |
| 31 | +- [ ] **Gas accounting matches the spec exactly**, with no signed/unsigned or |
| 32 | + overflow slip. *(besu: Gas allocation error in CALL — Critical; geth: DoS via |
| 33 | + `MulMod`)* |
| 34 | +- [ ] **Return-data and memory buffers are bounds-checked before any copy.** |
| 35 | + *(geth: RETURNDATA corruption via `datacopy`)* |
| 36 | +- [ ] **Precompiles copy, not alias, their inputs/outputs.** *(geth: shallow copy |
| 37 | + in the 0x4 precompile)* |
| 38 | + |
| 39 | + | | test | |
| 40 | + |---|---| |
| 41 | + | **unit** | differential opcode/precompile tests vs the reference spec (EELS) over boundary operands; property-test gas math for overflow; fuzz each opcode's stack inputs | |
| 42 | + | **e2e** | official state tests + blockchain tests; execute a block of adversarial opcodes across all clients on a devnet and compare state roots | |
| 43 | + |
| 44 | +### State-transition arithmetic (gas, balance, stake, slots) |
| 45 | + |
| 46 | +- [ ] **All balance / gas / stake / slot arithmetic is overflow- and |
| 47 | + underflow-checked**, including empty-collection edge cases. *(lighthouse: Eth1 |
| 48 | + data underflow; underflow in `verify_transfer`; underflow in shuffle with an |
| 49 | + empty list)* |
| 50 | + |
| 51 | + | | test | |
| 52 | + |---|---| |
| 53 | + | **unit** | property/fuzz tests asserting no under/overflow on extreme and empty inputs | |
| 54 | + | **e2e** | process adversarial blocks and states on a devnet; assert no panic and cross-client agreement | |
| 55 | + |
| 56 | +### Fork-choice |
| 57 | + |
| 58 | +- [ ] **Graph traversals are bounded** — no O(n²) `find_head`, no unbounded |
| 59 | + recursion or stack growth. *(lighthouse: O(n²) `find_head` and stack overflow in |
| 60 | + `filter_block_tree`)* |
| 61 | +- [ ] **Zero/null block hashes and missing parents are handled, not assumed.** |
| 62 | + *(lighthouse: avoid 0x00 block hashes in `forkchoiceUpdated`)* |
| 63 | +- [ ] **Message timing cannot bias the head** (proposer boost, late/early |
| 64 | + attestations). *(lighthouse: fork-choice timing attack)* |
| 65 | + |
| 66 | + | | test | |
| 67 | + |---|---| |
| 68 | + | **unit** | fork-choice tests with crafted block trees, equivocations, zero hashes, deep chains | |
| 69 | + | **e2e** | devnet reorg scenarios; proposer-boost edge cases; delayed and duplicated messages | |
| 70 | + |
| 71 | +### State trie & snapshots |
| 72 | + |
| 73 | +- [ ] **Trie/snapshot code returns errors instead of panicking** on malformed or |
| 74 | + short nodes. *(geth: stacktrie explicit errors instead of panic; snapshot unlock |
| 75 | + before return/panic)* |
| 76 | +- [ ] **Concurrent access to layers/snapshots is race-free.** *(geth: race |
| 77 | + condition on `diffLayer`)* |
| 78 | + |
| 79 | + | | test | |
| 80 | + |---|---| |
| 81 | + | **unit** | feed malformed/truncated trie nodes; run the race detector over concurrent layer ops | |
| 82 | + | **e2e** | snap-sync from an adversarial peer serving crafted state | |
| 83 | + |
| 84 | +### Crypto & KZG |
| 85 | + |
| 86 | +- [ ] **Curve points, signatures, and proofs are validated** (on-curve, subgroup, |
| 87 | + length) before use, and parsing never panics. *(geth: invalid-curve DoS in |
| 88 | + secp256k1)* |
| 89 | +- [ ] **No `expect`/`unwrap`/assert on attacker-supplied crypto input.** |
| 90 | + *(lighthouse: remove `expect` in `kzg_utils`)* |
| 91 | + |
| 92 | + | | test | |
| 93 | + |---|---| |
| 94 | + | **unit** | fuzz signature/point/proof parsers with invalid and boundary inputs | |
| 95 | + | **e2e** | gossip invalid BLS signatures and KZG proofs on a devnet; the node must reject them, not crash | |
| 96 | + |
| 97 | +--- |
| 98 | + |
| 99 | +## Tier 2 — Availability surface |
| 100 | + |
| 101 | +A bug here is a remote denial of service. Audit for bounds on anything a peer can |
| 102 | +control. |
| 103 | + |
| 104 | +### p2p & discovery |
| 105 | + |
| 106 | +- [ ] **Every length/count field from a peer is bounded** before allocation or |
| 107 | + iteration. *(pattern P1: LES `GetProofsV2` DoS; malicious snap/1 request)* |
| 108 | +- [ ] **Decode paths never panic** on malformed messages. *(geth: p2p/discover |
| 109 | + crash in `Resolve`; les panic)* |
| 110 | + |
| 111 | + | | test | |
| 112 | + |---|---| |
| 113 | + | **unit** | fuzz every wire-message decoder; assert allocation stays bounded relative to declared sizes | |
| 114 | + | **e2e** | flood a node with malformed and oversized gossip/request messages; memory and CPU must stay bounded | |
| 115 | + |
| 116 | +### Sync |
| 117 | + |
| 118 | +- [ ] **Downloader concurrency is correct** — no nil, mutex, or timeout- |
| 119 | + resurrection panics under failure. *(geth: timeout resurrection panic; mutex |
| 120 | + regression panics; nil panic from wrong variable)* |
| 121 | + |
| 122 | + | | test | |
| 123 | + |---|---| |
| 124 | + | **unit** | race detector plus fault injection on the downloader queue | |
| 125 | + | **e2e** | sync against a peer that stalls, reorders, or withholds responses | |
| 126 | + |
| 127 | +### RPC |
| 128 | + |
| 129 | +- [ ] **Request parameters are validated and result sizes are bounded** — no |
| 130 | + unbounded proof or range queries. *(reth: trie-proof edge cases; LES |
| 131 | + `GetProofsV2` DoS)* |
| 132 | + |
| 133 | + | | test | |
| 134 | + |---|---| |
| 135 | + | **unit** | fuzz RPC param decoding; assert response-size limits | |
| 136 | + | **e2e** | hammer the RPC with expensive/oversized queries; rate and size limits must hold | |
| 137 | + |
| 138 | +### Transaction pool |
| 139 | + |
| 140 | +- [ ] **Malformed and edge-case transactions are rejected without panic** (bad |
| 141 | + signature length, bad sender). *(geth: panic on invalid signature length; panic |
| 142 | + on bad tx sender; nil statedb panic in `applyTransaction`)* |
| 143 | + |
| 144 | + | | test | |
| 145 | + |---|---| |
| 146 | + | **unit** | fuzz tx decoding and validation | |
| 147 | + | **e2e** | submit adversarial transaction streams; the pool must stay healthy | |
| 148 | + |
| 149 | +### Beacon-chain queues (attestation / block / slasher) |
| 150 | + |
| 151 | +- [ ] **Per-peer queues are memory-bounded** and cannot be grown without limit. |
| 152 | + *(lighthouse: reprocess-queue memory leak; slasher OOM)* |
| 153 | + |
| 154 | + | | test | |
| 155 | + |---|---| |
| 156 | + | **unit** | queue-bound tests under flood | |
| 157 | + | **e2e** | gossip flood of attestations and blocks; memory must stay bounded | |
| 158 | + |
| 159 | +--- |
| 160 | + |
| 161 | +## The highest-value tests: cross-client conformance |
| 162 | + |
| 163 | +The bugs unique to this ecosystem live *between* implementations, so the tests |
| 164 | +that find them run more than one client at once. |
| 165 | + |
| 166 | +- [ ] **Differential testing.** Feed identical EVM, SSZ, and epoch-processing |
| 167 | + inputs to every client and diff the output. Any disagreement is a candidate |
| 168 | + chain split. |
| 169 | +- [ ] **Adversarial devnet.** Run a mixed-client network with one malicious peer |
| 170 | + driving the P1–P6 patterns: malformed gossip, oversized requests, equivocations, |
| 171 | + crafted reorgs, boundary-value transactions. Assert liveness, bounded resources, |
| 172 | + and a single canonical head. |
| 173 | +- [ ] **Spec-divergence fuzzing.** Mutate consensus-critical inputs (opcode |
| 174 | + operands, precompile inputs, SSZ containers) and cross-check every client against |
| 175 | + the reference spec. |
| 176 | + |
| 177 | +--- |
| 178 | + |
| 179 | +*Sources: every checklist item traces to one or more fixes in |
| 180 | +`data/ethereum_vulns.parquet` (filter by `label` and `root_cause`); the patterns |
| 181 | +P1–P6 and the priority map are in [`security_report.md`](./security_report.md).* |
0 commit comments