Skip to content

feat(contracts): burn bond on synthetic-standing TokenHolder appeals (audit I-3) (#688) #1018

Closed

Description

@alpergundogdu

Sub-issue of #688. Mechanism C2 — synthetic-standing clawback (audit I-3, continued). Complexity L. HIGHEST RISK — money-burning + flash-loan threat model. Mandatory careful human review. Depends on C1 (#1017). Do last.

Problem

Even with C1 enforcing balanceOf >= APPEAL_FILER_TOKEN_THRESHOLD at filing, a TokenHolder filer can acquire (or flash-borrow) tokens, pass the standing gate, file an appeal, then immediately divest — "synthetic standing." The standing check at filing alone is gameable. The bond should be forfeited when an adverse outcome reveals the filer never held genuine standing.

Decisions (resolved)

  • Magnitude: burn 100% of the escrowed bond on an adverse outcome where standing turns out synthetic. No extra collateral, no "multiplier" (the issue's multiplier would require a brand-new collateral-deposit surface — explicitly rejected as scope creep). The bond is already the filer's at-risk capital and the existing token.burn(bondBurned) machinery is reused.
  • Flash-loan defense — block-gate only, no time lookback:
    • Token.sol intentionally has no ERC20Votes / getPastVotes, so balanceOf-at-time is the only available tool (confirms ADR-031's simpler path).
    • Snapshot the open block number on TokenHolder appeals.
    • At adverse finality: if (block.number > openBlock && token.balanceOf(filer) < appealFilerTokenThreshold) burn the bond instead of refunding.
    • The strict block.number > openBlock gate defeats same-transaction / same-block flash-loan filing. No STANDING_LOOKBACK_SECONDS constant (block-gate only).

Solution / scope (ContentBlacklist.sol)

  • Add uint64 openBlock (or reuse a free struct slot) to the appeal record, set in openBlacklistAppeal for TokenHolder-path appeals (uint64(block.number)).
  • In the adverse finalizers (rejectBlacklistAppeal, reverseBlacklistAppeal, and the perjury path from feat(contracts): add multisig perjury denylist via rejectAppealAsPerjury (#688) #1016 if landed) add the clawback branch:
    • Only when standingPath == TokenHolder.
    • if (block.number > a.openBlock && token.balanceOf(a.filer) < appealFilerTokenThreshold) → burn full bond; else refund as today.
    • Emit a distinct SyntheticStandingClawback(appealId, filer, bond) event.
  • Note: code already anticipates this (comment near the standing check references status == Open && standingPath == TokenHolder). Align with that.
  • Confirm interaction with the existing bond-burn paths so a bond is never both refunded and burned (single decision point per finalizer).

Test plan (test/ContentBlacklist.t.sol)

  • File as TokenHolder with balance >= threshold, divest below threshold, adverse outcome → bond burned (not refunded).
  • File as TokenHolder, keep balance >= threshold, adverse outcome → bond refunded (no clawback).
  • Block-gate: a finalize in the SAME block as open does not clawback (guard correctness).
  • Favorable outcome → bond refunded regardless of balance.
  • Non-TokenHolder paths never clawback.
  • Re-entrancy / double-spend: bond is burned XOR refunded, never both.

CI / risk notes

  • --deny warnings: keep finalizers state-mutating; mind W5740.
  • This burns user funds on an adversarial-balance condition — the threat model (flash loans, partial divestment across blocks, griefing via forced adverse finality) must be reviewed by a human before merge. Spell out the threat model in the PR description.

ADR reconciliation

Document the clawback condition, the block-gate (and the explicit choice of no time lookback), and the balanceOf-only constraint imposed by Token having no ERC20Votes.

Agent-suitable: implementation yes, but flagged for MANDATORY human security review before merge. Land AFTER C1; never simultaneously with D (#1015) — shared finalizer accounting.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions