FoundrySolidityLayer 2
7.25 ETH
Submission Details
Impact: medium
Likelihood: medium

Bonus sweep can redirect value during the moderator reflag window

Author Revealed upon completion

Root + Impact

Description

flagOutcome() allows the moderator to correct a previously flagged outcome until a claim starts. The design document describes claimsStarted as the value-movement finality latch: once value has left under an outcome, later correction can break accounting.

sweepUnclaimedBonus() is intended to recover bonus or excess tokens that are not owed to stakers. In the no-risk-window case, _bonusShare() returns zero, so accounted bonus can become sweepable to recoveryAddress.

Issue: sweepUnclaimedBonus() can transfer accounted totalBonus to recoveryAddress and decrement totalBonus without setting claimsStarted. This allows value to leave during the moderator reflag window while still allowing a later reflag that snapshots depleted bonus accounting.

When an outcome is first flagged as SURVIVED and later corrected to good-faith CORRUPTED, a prior sweepUnclaimedBonus() can reduce the named attacker's bounty from snapshotTotalStaked + original snapshotTotalBonus to only the remaining post-sweep balance.

function flagOutcome(PoolStates.Outcome newOutcome, bool goodFaith_, address attacker_) external onlyModerator {
// Re-flag allowed pre-claim so the moderator can fix a typo'd outcome/attacker before
// any participant locks in the wrong distribution.
if (outcome != PoolStates.Outcome.UNRESOLVED && claimsStarted) revert OutcomeAlreadySet();
...
snapshotTotalStaked = totalEligibleStake;
snapshotTotalBonus = totalBonus;
corruptedReserve = newOutcome == PoolStates.Outcome.CORRUPTED ? snapshotTotalStaked + snapshotTotalBonus : 0;
bountyEntitlement = willBeGoodFaithCorrupted ? snapshotTotalStaked + snapshotTotalBonus : 0;
}
function sweepUnclaimedBonus() external nonReentrant {
if (outcome != PoolStates.Outcome.SURVIVED && outcome != PoolStates.Outcome.EXPIRED) {
revert OutcomeNotEligibleForSweep();
}
...
uint256 amount = freeBalance > reserved ? freeBalance - reserved : 0;
if (amount == 0) revert NothingToSweep();
if (totalEligibleStake == 0 || riskWindowStart == 0) {
// @> Accounted bonus can be decremented and swept while the outcome is still reflaggable.
totalBonus -= amount <= totalBonus ? amount : totalBonus;
}
// @> Value leaves the contract, but claimsStarted is intentionally not set.
stakeToken.safeTransfer(recoveryAddress, amount);
}

Risk

Likelihood:

  • A moderator flags SURVIVED while the registry is terminal CORRUPTED, then later corrects the outcome to good-faith CORRUPTED.

  • A no-risk-window pool has riskWindowStart == 0, causing _bonusShare() to return zero and making accounted bonus sweepable before the moderator correction occurs.

  • Any caller can execute sweepUnclaimedBonus() between the first flag and the moderator's corrective reflag.

Impact:

  • The named good-faith attacker receives a smaller bounty than the pool accounting promised for CORRUPTED resolution.

  • Accounted bonus is redirected to recoveryAddress before the final corrected outcome is established.

  • The reflag window no longer preserves value-distribution correctness, despite claimsStarted being treated as the finality latch.

Proof of Concept

// Initial state:
// - totalEligibleStake = 100
// - totalBonus = 50
// - stakeToken.balanceOf(pool) = 150
// - riskWindowStart = 0
// - registry state = CORRUPTED
// - outcome = UNRESOLVED
// 1. Moderator initially flags SURVIVED.
pool.flagOutcome(PoolStates.Outcome.SURVIVED, false, address(0));
// 2. Because riskWindowStart == 0, no staker is owed bonus.
// sweepUnclaimedBonus() treats the 50 bonus as free balance.
pool.sweepUnclaimedBonus();
// State after sweep:
// - recoveryAddress received 50
// - stakeToken.balanceOf(pool) = 100
// - totalBonus = 0
// - claimsStarted = false
// 3. Moderator corrects to good-faith CORRUPTED.
pool.flagOutcome(PoolStates.Outcome.CORRUPTED, true, attacker);
// 4. Bounty is snapshotted from depleted accounting.
// bountyEntitlement = snapshotTotalStaked + snapshotTotalBonus
// = 100 + 0
// = 100
// Expected without the intermediate sweep:
// bountyEntitlement = 100 + 50 = 150
// Result:
// - attacker receives only 100 instead of 150
// - 50 was redirected to recoveryAddress during the reflag window

Recommended Mitigation

function sweepUnclaimedBonus() external nonReentrant {
+ if (outcome != PoolStates.Outcome.UNRESOLVED && !claimsStarted) {
+ revert OutcomeStillReflaggable();
+ }
+
if (outcome != PoolStates.Outcome.SURVIVED && outcome != PoolStates.Outcome.EXPIRED) {
revert OutcomeNotEligibleForSweep();
}

An alternative mitigation is to keep sweepUnclaimedBonus() callable before claimsStarted, but reserve accounted totalBonus while the outcome remains reflaggable and allow only unaccounted donations or dust to be swept.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!