FoundrySolidityLayer 2
7.25 ETH
Submission Details
Severity: low
Valid

sweepUnclaimedBonus() can move accounted bonus during the re-flag window and underpay a corrected good-faith bounty

Author Revealed upon completion

[Medium] Pre-claim bonus sweep underpays corrected good-faith bounty

Description

flagOutcome() allows corrections before the first claim, but sweepUnclaimedBonus() can move accounted bonus to recoveryAddress in that window without setting claimsStarted.

When riskWindowStart == 0, the sweep treats tracked bonus as unreserved:

if (totalEligibleStake == 0 || riskWindowStart == 0) {
totalBonus -= amount <= totalBonus ? amount : totalBonus;
}
stakeToken.safeTransfer(recoveryAddress, amount);

A later correction to good-faith CORRUPTED snapshots the reduced totalBonus.

This creates a gap between accounting finality and outcome finality. The pool still allows the moderator to correct the result, but part of the bonus base used for the future corruption payout can already be removed before that correction happens.

Risk

Anyone can divert contributed bonus to recoveryAddress, underpaying the good-faith attacker.

Example: Alice stakes 100 and a contributor adds 50 bonus. The registry is actually CORRUPTED, but riskWindowStart == 0. The moderator first flags SURVIVED. Anyone calls sweepUnclaimedBonus(), sending the 50 tracked bonus to recoveryAddress while claimsStarted remains false. The moderator then corrects to good-faith CORRUPTED, and the attacker receives only 100 instead of 150.

The important detail is that this is not sweepable dust or a direct token donation. The missing 50 tokens came from contributeBonus() and were part of totalBonus before the premature sweep reduced it.

Proof of Concept

pool.stake(100e18);
pool.contributeBonus(50e18);
vm.prank(moderator);
pool.flagOutcome(PoolStates.Outcome.SURVIVED, false, address(0));
pool.sweepUnclaimedBonus(50e18);
assertEq(token.balanceOf(recovery), 50e18);
assertFalse(pool.claimsStarted());
vm.prank(moderator);
pool.flagOutcome(PoolStates.Outcome.CORRUPTED, true, attacker);
assertEq(pool.snapshotTotalStaked(), 100e18);
assertEq(pool.snapshotTotalBonus(), 0);
assertEq(pool.bountyEntitlement(), 100e18);

Without the sweep, the corrected bounty is 150.

PoC flow:

  1. Fund the pool with 100 stake and 50 tracked bonus.

  2. Let the moderator flag a non-final incorrect outcome such as SURVIVED.

  3. Call sweepUnclaimedBonus() before any claim starts.

  4. Confirm that the sweep transfers the 50 bonus out and leaves claimsStarted == false.

  5. Re-flag to good-faith CORRUPTED.

  6. Observe that the attacker bounty snapshots only the remaining 100 stake and no longer includes the 50 contributed bonus.

Mitigation

Do not allow tracked bonus to be swept while the outcome can still be corrected. Set claimsStarted = true when sweeping totalBonus, or separate dust sweeping from tracked-bonus sweeping.

One concrete fix is to block tracked-bonus sweeps before outcome finality:

if (!claimsStarted && amount <= totalBonus) revert OutcomeStillCorrectable();

Another valid fix is to make sweeping accounted totalBonus itself finalize the pool for correction purposes before any transfer occurs.

Updates

Lead Judging Commences

inallhonesty Lead Judge 2 days ago
Submission Judgement Published
Validated
Assigned finding tags:

sweepUnclaimedBonus() omits claimsStarted latch, letting a moderator re-flag re-snapshot a drained totalBonus and short the CORRUPTED bounty

Impact – Medium Up to the entire bonus pool can be routed to the wrong party for good, with no on-chain way to unwind it, and in a stakerless pool the effect is total since bountyEntitlement computes to zero and claimAttackerBounty reverts outright. This impact is definitely not High: the pool stays solvent throughout with no principal ever at risk, and the money ends up at the sponsor's own recoveryAddress, which in most pools means a sponsor recovering a bonus they funded themselves. The whitehat's claim on that bonus also only exists because the moderator changed their mind after the fact. Likelihood – Low Four separate things have to coincide: nobody touches the pool for the whole active-risk window (or there are no stakers to begin with), the moderator flags SURVIVED and later reverses to CORRUPTED, that reversal is good-faith with a named attacker, and a sweep lands between the two flags. The first cuts against staker self-interest, since skipping the poke costs them their entire bonus share, and the second asks the moderator to overturn a scope judgement, which is a bigger deal than the typo fix DESIGN.md #4 offers the window for. The sweep itself I'd treat as near-certain once the rest holds, given it's permissionless and the sponsor has an obvious reason to make the call, but assembling the first three in one pool lifecycle is where this stays rare.

Support

FAQs

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

Give us feedback!