Skip to content

CapacityBond: per-slashId zero-out clearing on multi-outstanding-slash operators #709

Closed

Description

@thiras

Context

Surfaced in Copilot review of #708 (escrow-on-slash refactor). Pre-existing latent issue, not introduced by #708 — the behavior is byte-identical to the old SafetyReserve.reverseAppeal → CapacityBond.clearSlashedAtEpoch path, which also cleared unconditionally.

Issue

CapacityBond._slashedAtEpoch[operator] is a single per-operator watermark (the +1-offset epoch of the most recent slash), consumed by DecdnGovernor to zero an operator's served-bytes vote weight while inside the trailing window (ADR 036 § Slashing zero-out). settleAppealGranted(slashId) clears it unconditionally via _clearSlashedAtEpoch(operator).

If an operator has two outstanding slashes within the trailing window (e.g. slashId 0 at epoch 10, slashId 1 at epoch 12 — the watermark holds 12), and the operator successfully appeals the older slashId 0, settleAppealGranted clears the watermark to 0 — restoring vote/claim eligibility even though slashId 1 still stands.

claimVestedCredit's slash gate reads the same watermark, so it is affected identically.

Why deferred from #708

  • Pre-existing (identical to the retired clearSlashedAtEpoch), not a regression.
  • A correct fix is a semantics change to a governance-critical field and an amendment to ADR 036's single-watermark model — out of scope for a SafetyReserve-removal refactor.

Possible fixes

  1. On a granted appeal, recompute the watermark as the max epoch among the operator's still-standing (Escrowed/AppealOpen/Upheld) slashes, clearing to 0 only if none remain. Requires an operator→slashIds index or iteration.
  2. Track an outstanding-slash count / max-standing-epoch per operator updated on slash and on each terminal escrow transition; clear the watermark only when the count hits zero.

Option 2 is O(1) and avoids iteration; it needs one extra mapping and updates in _mintSlashRecord / _distributeUpheld / settleAppealGranted.

Should be paired with an ADR 036 note on the multi-slash watermark semantics.

Activity

  1. added
    kind:bug
    prio:high
    kind:security
    on May 29, 2026
  2. github-actions commented on May 29, 2026

    @github-actions

    🎯 Triage report

    CapacityBond.settleAppealGranted unconditionally clears the _slashedAtEpoch watermark, which incorrectly restores vote weight and claimVestedCredit eligibility for an operator who still has other outstanding slashes within the trailing window. This is a governance-correctness bug affecting DecdnGovernor voting and vested-credit claims — a bad-faith operator could exploit partial appeals to recover influence while still penalized. Fix requires amending ADR 036's single-watermark model and touching _mintSlashRecord / _distributeUpheld / settleAppealGranted.

    📊 Assessment

    Dimension Value Reasoning
    Type Bug Incorrect state transition in governance-critical contract logic
    Labels bug, security, technical, adr-review, high Exploitable governance/claim bypass; requires ADR 036 amendment; high priority due to on-chain impact
    Coding agent Needs more info Fix approach is well-scoped (Option 2 preferred) but requires an ADR 036 amendment decision before implementation can be locked — the semantics change to the watermark model is a design choice maintainers must ratify
    💡 Notes and suggestions

    Root cause: _slashedAtEpoch[operator] is a single scalar "most-recent slash epoch + 1". It is decremented/cleared on any granted appeal, with no awareness of other concurrent slash records.

    Recommended fix (Option 2 — O(1)):

    1. Add a new mapping: mapping(address => uint256) private _outstandingSlashCount (or _maxStandingEpoch if you want to preserve the epoch semantics).
    2. Increment in _mintSlashRecord.
    3. Decrement (and recompute max epoch if needed) in _distributeUpheld and settleAppealGranted; only call _clearSlashedAtEpoch when the counter reaches zero.
    4. Update ADR 036 § Slashing zero-out to describe multi-slash watermark semantics explicitly.

    Suggested sub-tasks:

    • Amend ADR 036 to define multi-slash watermark semantics (maintainer decision gate)
    • Add _outstandingSlashCount mapping and update _mintSlashRecord
    • Update settleAppealGranted to decrement count, clear watermark only at zero
    • Update _distributeUpheld symmetrically
    • Add Foundry tests: two slashes, appeal older → watermark still set; appeal both → watermark cleared
    • Verify claimVestedCredit gate behaves correctly in both cases

    Security note: Until fixed, an operator with two overlapping slashes who successfully appeals the older one will have _slashedAtEpoch cleared — bypassing both the governance vote-weight zero-out and the claimVestedCredit slash gate for the duration of the trailing window on the second slash. This is exploitable on-chain once the contract is live.

    Generated by Agentic Triage for issue #709 · sonnet46 497.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. added a commit that references this issue on May 29, 2026
  4. thiras commented on May 29, 2026

    @thiras
    ContributorAuthor

    Partially addressed by a312cdd on #708 (review finding #2): settleAppealGranted now clears slashedAtEpoch only when the current stamp matches the reversed slash, so the cross-epoch front-run described here no longer wrongly restores vote weight. Two-slash regression test added. Remaining (kept open): the single-watermark model still cannot fully handle granting the most-recent slash while an earlier one in a different epoch still stands — that needs the max-standing-epoch re-derive (option 2 above).

  5. self-assigned this
    on May 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind:bugkind: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