Skip to content

CapacityBond.setUnbondingPeriod should mirror the maxEvidenceAgeUs invariant (size-deferred) #778

Closed

Description

@thiras

Split out of the security audit pass (#777).

Finding

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.

Why it's deferred (not in #777)

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

  1. Move the check into a public SlashEscrowLib/BondMath helper (separate deployed bytecode) and keep only a thin slashJudge ref + setter in CapacityBond — still needs to fit the setter.
  2. A governance-set unbondingFloorSeconds floor (no external ref) — lighter but requires governance to keep it ≥ maxEvidenceAgeUs manually.
  3. 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 unbondingPeriod lowering direction, which is GOVERNANCE_ROLE-gated (timelock).

Activity

  1. added
    status:blocked
    prio:high
    kind:security
    on Jun 1, 2026
  2. github-actions commented on Jun 1, 2026

    @github-actions

    🎯 Triage report

    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

    🔗 Similar issues

    💡 Notes and suggestions

    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

    Suggested sub-tasks:

    • Run FOUNDRY_PROFILE=ci forge build --sizes to confirm current headroom is still ~124 B (it may shift if fix(contracts): security audit pass — High + Medium findings #777 lands)
    • Decide between options 1/2/3 (maintainer call)
    • 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.

    Generated by Agentic Triage for issue #778 · sonnet46 561.8K · ◷

    Add this agentic workflows to your repo

    To install this agentic workflow, run

    gh aw add githubnext/agentics/workflows/issue-triage.md@94ec5db57374c5b04a4b8eef8b4413f9af44d63f
    
  3. removed
    status:blocked
    on Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind:securityprio:high

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions