Skip to content

ContentBlacklist: relief-counter underflow clamps silently mask accounting bugs #1311

Closed

Description

@yigitdot

Informational, pre-existing, surfaced by the review of #1304.

Five sites clamp instead of asserting:

if (regionActiveReliefCount[r] != 0) regionActiveReliefCount[r] -= 1;
if (filerRegionActiveRelief[r][f] != 0) filerRegionActiveRelief[r][f] -= 1;

contracts/src/ContentBlacklist.sol:678-679, :709-710, :733-734, :751-752, :814-815 (rejectBlacklistAppeal, rejectAppealAsPerjury, ratifyBlacklistAppealRemoval, reverseBlacklistAppeal, cleanupExpiredBlacklistAppeal).

Every FastTracked appeal incremented both counters in fastTrackBlacklistAppeal, and all five decrements are gated on the appeal having been fast-tracked — so at each site the counter is provably nonzero. The clamps are unreachable by construction.

Which is exactly the problem: if one ever fires, the relief-cap accounting has already diverged, and the clamp hides it at the precise moment you would want to know. The failure is silent and permanent (the counter stays wrong, throttling future legitimate fast-tracks in that region until it drifts to zero).

Options, in rough order of preference:

  1. Revert with a custom error — the accounting invariant is real and cheap to enforce.
  2. Keep the clamps but comment them as unreachable, naming the invariant that makes them so, so a future reader does not mistake them for handling a live case.

Low priority; the invariant genuinely holds today. Worth doing whenever fastTrackBlacklistAppeal's preconditions change — notably #1307, which proposes adding one.

Found during the review of #1304.

Activity

  1. added
    prio:low
    area:contracts
    on Jul 19, 2026
  2. altanoruc commented on Jul 19, 2026

    @altanoruc
    Contributor

    Automated triage note for a later run: this is small and self-contained once the intended failure mode is pinned, but it is not decision-free yet. Please choose between the two outcomes in the issue: (a) replace all five clamp pairs with an invariant-enforcing custom-error revert, or (b) keep behavior unchanged and document the unreachable branches. If (a), please also pin the custom error's shape/arguments so an implementer is not designing a new contract ABI while fixing the accounting guard.

  3. self-assigned this
    on Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:contractsprio:low

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions