You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CapacityBond.setUnbondingPeriod should mirror the maxEvidenceAgeUs invariant (size-deferred) #778
SlashJudge enforces maxEvidenceAgeUs < unbondingPeriod on its own setter/constructor (ADR 014), but CapacityBond.setUnbondingPeriod has no mirror check. Governance can therefore lower unbondingPeriod below the live evidence-age ceiling, after which a slash could land on bond that has already fully unbonded/withdrawn.
CapacityBond is at the EIP-170 runtime ceiling — 24,452 / 24,576 bytes, ~124 B headroom. A GOVERNANCE_ROLE-gated setSlashJudge setter + getter + the setUnbondingPeriod cross-check measured at +417 B, overflowing the limit by ~290 B. Forcing it in requires clawing back bytecode elsewhere (library extraction), which broadens the security PR and risks regressions.
Options
Move the check into a publicSlashEscrowLib/BondMath helper (separate deployed bytecode) and keep only a thin slashJudge ref + setter in CapacityBond — still needs to fit the setter.
A governance-set unbondingFloorSeconds floor (no external ref) — lighter but requires governance to keep it ≥ maxEvidenceAgeUs manually.
Reclaim CapacityBond bytecode first (extract more of the slash path to SlashEscrowLib), then add the full SlashJudge-ref mirror.
Mitigation today
SlashJudge still enforces the other half of the invariant (it rejects a maxEvidenceAgeUs raise above the current unbondingPeriod). The open gap is only the unbondingPeriodlowering direction, which is GOVERNANCE_ROLE-gated (timelock).
This is a security invariant gap split out of #777: CapacityBond.setUnbondingPeriod lacks a mirror check against SlashJudge.maxEvidenceAgeUs, meaning governance (via timelock) can lower unbondingPeriod below the evidence-age ceiling, potentially allowing a slash to target bond that has already unbonded/withdrawn. The fix is deferred solely due to CapacityBond sitting 124 B below the EIP-170 24,576-byte ceiling — the required setter + cross-check adds ~417 B, requiring bytecode reclamation before it can land.
📊 Assessment
Dimension
Value
Reasoning
Type
Bug / Security Finding
A broken cross-contract invariant with a concrete exploit path (governance-lowered unbondingPeriod → slash on unbonded bond)
Labels
security, technical, high, blocked
Security invariant gap; blocked by EIP-170 size constraint on CapacityBond
Coding agent
Needs more info
The fix is well-specified (3 concrete options), but the blocker — EIP-170 headroom — means the agent must first decide which bytecode-reclamation strategy to pursue; that architectural choice gating the fix makes it unsuitable for autonomous assignment without a maintainer decision
Severity context: The exposure is partially mitigated — SlashJudge already rejects any raise of maxEvidenceAgeUs above unbondingPeriod, so only the lowering direction via setUnbondingPeriod is unguarded. That setter is GOVERNANCE_ROLE-gated behind a timelock, which reduces urgency but does not eliminate risk (governance can be compromised or misconfigured).
Deciding which option to pursue:
Option
Pro
Con
1. Move check into SlashEscrowLib/BondMath
Keeps full invariant enforcement on-chain with a SlashJudge ref
Still needs the setSlashJudge setter + getter to fit within headroom; requires library extraction work
2. unbondingFloorSeconds governance param (no external ref)
Lightest bytecode cost; no cross-contract dependency
Invariant becomes advisory — governance must manually keep floor ≥ maxEvidenceAgeUs; no atomic enforcement
3. Reclaim CapacityBond bytecode first, then add full mirror
Cleanest long-term solution
Most work; regressions risk if slash path extraction is broad
If Option 1 or 3: profile how much bytecode can be reclaimed by extracting additional slash logic to SlashEscrowLib (target: free ≥ 420 B)
If Option 2: draft the unbondingFloorSeconds setter + NatSpec clearly documenting the manual governance dependency
Add a fuzz test: testFuzz_setUnbondingPeriod_belowEvidenceAge — should revert after fix
Note: This issue should be revisited immediately after #777 merges, as that PR changes CapacityBond bytecode (slash-path changes + pausedTotal), which may shift available headroom.
Activity
github-actions commentedon Jun 1, 2026
🎯 Triage report
This is a security invariant gap split out of #777:
CapacityBond.setUnbondingPeriodlacks a mirror check againstSlashJudge.maxEvidenceAgeUs, meaning governance (via timelock) can lowerunbondingPeriodbelow the evidence-age ceiling, potentially allowing a slash to target bond that has already unbonded/withdrawn. The fix is deferred solely due toCapacityBondsitting 124 B below the EIP-170 24,576-byte ceiling — the required setter + cross-check adds ~417 B, requiring bytecode reclamation before it can land.📊 Assessment
unbondingPeriod→ slash on unbonded bond)security,technical,high,blockedCapacityBond🔗 Similar issues
💡 Notes and suggestions
Severity context: The exposure is partially mitigated —
SlashJudgealready rejects any raise ofmaxEvidenceAgeUsaboveunbondingPeriod, so only the lowering direction viasetUnbondingPeriodis unguarded. That setter isGOVERNANCE_ROLE-gated behind a timelock, which reduces urgency but does not eliminate risk (governance can be compromised or misconfigured).Deciding which option to pursue:
SlashEscrowLib/BondMathsetSlashJudgesetter + getter to fit within headroom; requires library extraction workunbondingFloorSecondsgovernance param (no external ref)maxEvidenceAgeUs; no atomic enforcementSuggested sub-tasks:
FOUNDRY_PROFILE=ci forge build --sizesto confirm current headroom is still ~124 B (it may shift if fix(contracts): security audit pass — High + Medium findings #777 lands)SlashEscrowLib(target: free ≥ 420 B)unbondingFloorSecondssetter + NatSpec clearly documenting the manual governance dependencytestFuzz_setUnbondingPeriod_belowEvidenceAge— should revert after fixNote: This issue should be revisited immediately after #777 merges, as that PR changes
CapacityBondbytecode (slash-path changes +pausedTotal), which may shift available headroom.Add this agentic workflows to your repo
To install this agentic workflow, run
feat(contracts): add ISlashJudgeEvidenceView interface + test mock (#778
feat(contracts): add CapacityBond.setSlashJudge governance setter (#778)
feat(contracts): enforce maxEvidenceAgeUs mirror in setUnbondingPeriod (
feat(contracts): validate invariant on setSlashJudge wire-time (#778)
test(contracts): cross-contract CapacityBond/SlashJudge unbonding inv…
feat(contracts): wire CapacityBond.setSlashJudge in deploy + post-dep…
docs(contracts): mark unbonding↔evidence-age mirror as enforced (#778)
chore(contracts): regenerate gas snapshot for unbonding mirror (#778)
docs(contracts): correct active unbonding bound to [3d,30d] in commen…
feat(contracts): enforce maxEvidenceAgeUs↔unbondingPeriod mirror on C…