The threshold check for adding of new tiers is skipped when _nextNumberOfTiers is at the maximum amount
The tier expansion logic in the prize pool contract skips the required threshold check when the next number of tiers would reach the maximum, allowing a new tier to be added with only a single canary claim instead of the normal threshold. An attacker could add a new tier prematurely, potentially affecting prize distribution.
Submitted by yixxas
The wrong implementation allows a new tier to be added as the threshold check is not done when we currently have 14 tiers. This means, that with just a single canary claim, a new tier will be added when number of tiers = 14.
Proof of Concept
In order for the prize pool to add new tiers, the normal prize claim count and canary tier claim count must pass a certain threshold. This check is done by the below code snippet:
if (
_nextNumberOfTiers >= _numTiers &&
canaryClaimCount >=
fromUD60x18(
intoUD60x18(_claimExpansionThreshold).mul(_canaryPrizeCountFractional(_numTiers).floor())
) &&
claimCount >=
fromUD60x18(
intoUD60x18(_claimExpansionThreshold).mul(toUD60x18(_estimatedPrizeCount(_numTiers)))
)
) {
However, in the case where _nextNumberOfTiers >= MAXIMUM_NUMBER_OF_TIERS, MAXIMUM_NUMBER_OF_TIERS this is instantly returned, skipping this check.
uint8 _nextNumberOfTiers = largestTierClaimed + 2; // canary tier, then length
_nextNumberOfTiers = _nextNumberOfTiers > MINIMUM_NUMBER_OF_TIERS
? _nextNumberOfTiers
: MINIMUM_NUMBER_OF_TIERS;
if (_nextNumberOfTiers >= MAXIMUM_NUMBER_OF_TIERS) {
return MAXIMUM_NUMBER_OF_TIERS;
}
As seen from the above code, if we currently have 14 tiers and the canary tier is claimed in this draw, hence largestTierClaimed = 13, then we have _nextNumberOfTiers = 15. Since MAXIMUM_NUMBER_OF_TIERS == 15, we return MAXIMUM_NUMBER_OF_TIERS and the new number of tiers is going to be 15, even if the number of claims for this draw does not pass the threshold check.
Recommended Mitigation Steps
Make sure that we do the threshold check specifically, in the case where _numTiers == 14 and canaryClaimCount >= 1.
Assessed type
Invalid Validation
asselstine (PoolTogether) confirmed
Simplified tier expansion logic. PR: https://github.com/GenerationSoftware/pt-v5-prize-pool/pull/17
Status: Mitigation error. Full details in report from dirk_y and in the Mitigation Review section below.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The function returns early when the calculated next number of tiers is at or above the maximum, bypassing the threshold check that should still apply.
What the attacker needed
Prize pool at 14 tiers; canary tier claimed in a draw
The fix
The threshold check should still be performed when the next number of tiers equals the maximum, for example by ensuring the check is not skipped for the case where _numTiers == 14 and canaryClaimCount >= 1.
How it was found
- Have a prize pool with 14 tiers.
- In a draw, claim the canary tier (tier 13).
- The function calculates _nextNumberOfTiers as 15, which is >= MAXIMUM_NUMBER_OF_TIERS (15), so it returns 15 without checking thresholds.
- A new tier is added even though the claim count did not meet the threshold.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A prize pool contract has a rule that new prize tiers are only added when enough claims have been made. But when the pool is already at 14 tiers, the code skips that check and adds a 15th tier after just one claim. This means the intended safeguard is bypassed.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.