Repository navigation
fix(contracts)!: security review fixes (24 findings) - #2833
Conversation
The escape hatch settled a slash as upheld but left the appeal bond in SlashAppeal with no way out. An open appeal resolves through SlashAppeal. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ve its floor isActive no longer has a no-unbonding-request conjunct. requestUnbond moves the released amount out of activeBond at once, so the floor check alone decides: an unbond that retains the floor keeps the node active, one that drops below it deactivates the node immediately. The unbond CLI discloses which case applies. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…egistration A floor left by an earlier bond() crossing could sit above a since-lowered minBond, so an operator that met the registration gate stayed inactive. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e region registerNode overwrote regionHint without a snapshot, so a deregister and re-register into another region dropped the old region's blacklist scope at once instead of after the stability window. updateRegion and registration now share one region-change path. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A 1-wei bond stamped firstBondedAt, so an address could be pre-aged for the age_ramp at negligible cost. The stamp now lands with the first crossing of minBond, alongside the grandfathered entry floor. Co-Authored-By: Claude Opus 5.5 <[email protected]>
declareMbps(0) from an inactive operator is the step that lowers the requestUnbond floor, so a pause could freeze that operator's exit even though requestUnbond and deregisterNode stay open. Only the release branch skips the pause. Co-Authored-By: Claude Opus 5.5 <[email protected]>
An offender could call reclaimNodeId on its own NodeId, clear its binding, and make every challenge revert NodeNotRegistered. SlashJudge now accepts an unbound operator that still holds active or unbonding bond. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…vercharged stream The evidence hash now carries challengedNode, so an offender cannot have a zero-bond address sign the same response and spend the evidence first. The rate-manipulation hash drops the probe: one overcharged stream paired with several probes is one offense, not a ladder of escalating slashes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
SignatureChecker consulted ERC-1271 code at the operator's address, so an operator with an EIP-7702 delegate could reject every slash proof against itself. Evidence is re-verified after the paid action, which ADR 024 places outside ERC-1271; SlashJudge now recovers the signer directly. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The frequency cap was checked only at open, against granted appeals, so an operator could open appeals on several slashes before any grant and have all of them granted inside one 365-day window. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A SlashAppeal pause blocked openSlashAppeal, but finalizeUnappealedSlash on CapacityBond stayed callable, and the open pause was not yet in pausedTotal, so a challenger could finalize a slash the operator was locked out of appealing. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A re-add or governance ratification restamped addedAt and effectiveAt, which moved effectiveAt later and voided slash evidence for serves made after the entry first took effect. A live entry now keeps its stamps; only the reason, the emergency flag and an escalated category move. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A pool owner could register a capability that pays nothing for a live signer before any node redeemed, voiding every voucher that signer had already given and letting the owner reclaim the deposit. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…1271 SignatureChecker consulted code at the owner's address first, so an EOA owner that added an EIP-7702 delegate after nodes served could reject its own capability at registration and reclaim the deposit. A smart-account owner still verifies through ERC-1271. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The floor ceiling read the lifetime cumulative, so a signer could pay early with zero bytes and later release the whole banked byte credit with a one-unit payment, just before a governance snapshot. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tive ones redeemMany paid any caller, so a capability holder could sign vouchers to its own address and draw the spending cap as USDC, and any address could pump the governance byte window with self-paid bytes. A paying call now requires a NodeId binding for the payee and routes bytes only while the payee isActive; a bound but inactive operator is still paid. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rt and snapshot The Governor read one per-operator epoch watermark, so a second slash (even a zero-bond self-slash) could move it out of the window and restore full votes, and a slash in the in-progress epoch left the operator at full weight for later snapshots in that epoch, including on its own appeal. The Governor now walks the operator's slash records and zeroes the vote for any standing slash with slashedAt in [window start, timepoint]. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…bytes The cap was 10% of the window total, which includes the operator's own bytes, so an operator paying itself raised its own cap and could outvote every other operator together. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A direct delegate() left the nonce untouched, so a former delegatee holding a signed but unredeemed delegateBySig could replay it after the operator revoked and cast the operator's vote. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ROLE During the bootstrap-multisig phase an attacker could pass a proposal with the thin early electorate; an unqueued Succeeded proposal never expires, so it became executable once the roles moved to the Governor. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A permissionless poke let anyone move the pool spot, sample it into the TWAP accumulator and move it back in one transaction, so the floor kept that false spot until the next sample and could stall buybacks. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…eed mint An attacker could initialize the TOKEN/USDC pool first at a low price, or move it between the create and mint transactions, and the zero-minimum seed mint deposited the TOKEN leg at that price. The deploy now refuses a pool whose price differs from the seed price, and the mint requires 99% of each leg on-chain. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…admit The defaults seeded 100 USDC against a 10% per-epoch cap but required a 100 USDC minimum buyback, so every keeper buyback reverted and nothing burned. The deploy now reverts when the first epoch's cap is below the minimum buyback, and the default seed is 1,000 USDC. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The deploy checked the emergency multisig only for zero, so a mainnet deploy could seat the deployer key in every PAUSER_ROLE and emergency role. On chain 42161 it now refuses the deployer and an address with no code; testnet and e2e deploys keep seating the deployer. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The per-operator vote cap is sized from the other operators' bytes, so the voting operator needs a second operator's bytes in the window; a lone serving operator has a zero cap. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Code coverage overviewLanguages: Rust, Solidity Rust / code-coverage/cargo-llvm-cov
View coverage of the 5 most impacted files.
Solidity / code-coverage/forge
View coverage of the 8 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. Updated |
Gas snapshotNo gas changes vs base. |
… for slither Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Note
Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.
🟡 Changes recommended
Approval is blocked because there are unresolved correctness issues where the CLI’s active/inactive messaging and help text rely on the current minBond instead of the operator’s stored bondFloorAtActivation, which can misreport whether an operator stays active after governance changes.
2 open issues
What changed in this PR
This pull request implements a broad set of security-review remediations across the Solidity protocol contracts (notably CapacityBond, SlashJudge, SlashAppeal, PaymentPool, DecdnGovernor) with corresponding updates to tests, Rust e2e mirroring (evidence hash changes), CLI/operator messaging, and ADR documentation. Several contract-surface and behavioral changes are explicitly breaking and are accompanied by updated on-chain/off-chain integration expectations.
Changes:
- Harden slashing/evidence and appeal flows (evidence-hash binding changes, ECDSA-only evidence verification, slashability/appeal lifecycle tightening).
- Refine CapacityBond lifecycle semantics (floor-based activity rules, registration floor snapshotting, tenure stamping, region bookkeeping, removal of stuck-appeal escape hatch).
- Tighten governance/payment invariants (vote-weight/slash zeroing changes, PaymentPool redemption gating + per-call credit bounding, buyback/deploy safety checks) with expanded tests and refreshed gas snapshots.
Unresolved review comments to address before approval:
decdn node unbonddisclosure should be keyed tobondFloorAtActivation(not liveminBond) and may require adding a binding forbondFloorAtActivation(address)in the CLI alloy binding.- CLI help text should describe floor-based inactivity (not “below minBond”) to match on-chain
isActive. - DHT registry watcher should handle NodeId-binding mutation events (
NodeIdBound/NodeIdReclaimed) to avoid up-to-REGISTRY_RESYNC_INTERVALstaleness after rotate/reclaim. - NodeId↔address binding documentation should reflect the current event coverage and the potential staleness until resync.
Assessment: This pull request requires changes.
| File | Reviewed |
|---|---|
crates/node/src/dht/node_address.rs |
Yes |
crates/node/src/dht/capacity_bond_registry.rs |
Yes |
crates/incentive/src/capacity_bond.rs |
Yes |
crates/e2e/tests/slash_appeal.rs |
Yes |
crates/e2e/tests/g_node_06_unbond.rs |
Yes |
crates/e2e/tests/g_node_04_blacklist_compliance.rs |
Yes |
crates/e2e/src/chain.rs |
Yes |
crates/common/src/cli/node.rs |
Yes |
crates/client/src/discovery/tests.rs |
Yes |
crates/cli/src/commands/unbond.rs |
Yes |
crates/cli/src/commands/node/tests.rs |
Yes |
crates/cli/src/commands/deregister.rs |
Yes |
contracts/test/SlashJudge.t.sol |
Yes |
contracts/test/SlashAppeal.t.sol |
Yes |
contracts/test/PaymentPool.t.sol |
Yes |
contracts/test/OriginAssignment.t.sol |
Yes |
contracts/test/mocks/MockCapacityBond.sol |
Yes |
contracts/test/GenesisBuybackActivation.t.sol |
Yes |
contracts/test/GenesisBuybackActivation.fork.t.sol |
Yes |
contracts/test/E2EProtocol.t.sol |
Yes |
contracts/test/DeployProtocol.t.sol |
Yes |
contracts/test/DecdnGovernorDelegation.t.sol |
Yes |
contracts/test/DecdnGovernor.t.sol |
Yes |
contracts/test/ContentBlacklist.t.sol |
Yes |
contracts/test/CapacityBondRegionE2E.t.sol |
Yes |
contracts/test/CapacityBond.t.sol |
Yes |
contracts/test/BuybackBurnerUniswapV3.t.sol |
Yes |
contracts/src/SlashJudge.sol |
Yes |
contracts/src/SlashAppeal.sol |
Yes |
contracts/src/PaymentPool.sol |
Yes |
contracts/src/interfaces/ICapacityBondSlasher.sol |
Yes |
contracts/src/interfaces/ICapacityBondActivity.sol |
Yes |
contracts/src/interfaces/ICapacityBond.sol |
Yes |
contracts/src/GuardedBuybackBurner.sol |
Yes |
contracts/src/DecdnGovernor.sol |
Yes |
contracts/src/ContentBlacklist.sol |
Yes |
contracts/src/CapacityBond.sol |
Yes |
contracts/src/BuybackBurnerUniswapV3.sol |
Yes |
contracts/script/DeployProtocol.s.sol |
Yes |
contracts/script/BaseProtocolDeploy.s.sol |
Yes |
adr/036-served-bytes-voting-weight.md |
Yes |
adr/028-slashing-appeals.md |
Yes |
adr/026-tokenomics.md |
Yes |
adr/024-account-abstraction.md |
Yes |
adr/018-liquidity-strategy.md |
Yes |
adr/016-contract-interactions.md |
Yes |
adr/014-on-chain-verification.md |
Yes |
adr/011-content-takedown.md |
Yes |
adr/009-governance.md |
Yes |
adr/003-payments.md |
Yes |
Review effort: Balanced
isActive tests bondFloorAtActivation, which a minBond change since activation leaves in place, so keying the disclosure on the live minBond could misreport whether the node stays active. The plan reads the recorded floor (the live minBond for an operator that never activated) and reports it as below_floor. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…curity-audit-bfede0 # Conflicts: # contracts/.gas-snapshot


Summary
Fixes from a security review of
contracts/: a pashovsolidity-auditorrun (3 passes, all agents), an x-ray pre-audit report, and a Medusa fuzz campaign (fizz). There is one small commit per finding, and each commit carries its tests and the ADR text that describes the behavior.Pre-mainnet rules apply: wire-breaking changes go in with every side updated in the same PR. Rust touches are limited to the e2e evidence-hash mirror, doc comments, and the
decdn node unbonddisclosure.Fixes
CapacityBond
forceResolveStuckAppeal. It settled a slash as upheld but stranded the appeal bond inSlashAppeal.isActivenow checks only the floor, andrequestUnbondalready moves the released amount out ofactiveBond. Thedecdn node unbondCLI tells the operator which case applies.registerNodealways records the liveminBondas the entry floor. A stale higher floor from an earlierbond()left a registered operator inactive.regionPrev, so the old region's blacklist scope ripens out as it does forupdateRegion. Both paths share one helper (+6 B).firstBondedAtis stamped at the firstminBondcrossing, so a 1-wei bond cannot pre-age an address for the governance age ramp.declareMbps(0)tier release works during a pause, like the other exit paths.SlashJudge / SlashAppeal
reclaimNodeIdon its own NodeId made it unslashable.challengedNode, so evidence signed by a zero-bond address cannot be spent first. The rate-manipulation hash is keyed on the stream alone, so one overcharge gives one slash, not a ladder of escalating tiers. Breaking: the e2e mirror is updated.openSlashAppealstays open whileSlashAppealis paused. OtherwisefinalizeUnappealedSlashcould close the window while the operator was locked out.ContentBlacklist
addedAtandeffectiveAt. It updates only the reason, clears the emergency flag, or escalates the category.PaymentPool
redeemManypays only a payee with a NodeId binding, and routes bytes only while that payeeisActive. A capability holder can no longer draw its cap to itself, and an unbonded address can no longer pump the quorum total. The cost is about 9k gas per call; the pinned gas figures and.gas-snapshotare updated.DecdnGovernor
slashedAtin[window start, timepoint], read from the slash records. A later slash can no longer hide an earlier one, and a slash early in the current epoch zeroes later snapshots.slashedAtEpochremains as an indexer read and is dropped fromICapacityBond.slash_appeale2e now has both operators serve. Accepted: the bootstrap multisig covers the thin-network phase.delegate()consumes the delegation nonce, so an unredeemeddelegateBySigcannot override a later revocation.proposereverts until the Governor holds the Timelock'sPROPOSER_ROLE, so no bootstrap-phase proposal becomes executable after the hand-off.Buyback / deploy
GuardedBuybackBurner.pokeis keeper-only.BUYBACK_USDC_SEEDis now 1,000 USDC.Not fixed in this PR
reclaimduring aFeeRouterpause): accepted, because a pause is a collective operator action.PAYMENT_DELIVERY_FLOOR = 1means self-dealt vote bytes cost the delivery floor, not the market rate. This is an economics decision; governance raises the floor once the market rate is known.isActivefalse while auto-eject keeps it._getVoteszeroes weight only for a slash, so a blacklisted or fully exited operator keeps its window bytes for up to 13 epochs. This PR stops new bytes from inactive operators.SlashJudgereads the liveregionStabilityWindow, so a later increase can reopen serves that were out of scope._checkStalenessdoes not extend evidence age by pause time.lifetimeOffenseCount.Test plan
forge fmt --check,FOUNDRY_PROFILE=ci forge build --sizes --deny warnings(CapacityBond 23,648 B, 928 B margin)forge test: all suites pass, with new tests per fixFOUNDRY_PROFILE=ci forge snapshot --snap .gas-snapshotregeneratedcargo test --no-run -p decdn-e2e --features anvil-e2eg_node_06_unbond,g_gov_03_real_evidence,slash_appeal,g_node_04_blacklist_compliance,anvil_pool_redeem,cli_fetch_delegatedslash_appealupdatecargo clippy --all-targets --all-featuresandcargo doc(deny warnings) on the touched cratesmainlines.🤖 Generated with Claude Code