Accumulated rewards per share can round to zero
The accumulated rewards per share calculation can round down to zero when the precision factor is too small relative to total shares, so a claim adds nothing to the accumulator. Users then miss out on rewards and the funds remain stuck in the Distributor contract.
Submitted by hgrano, also found by AvantGard, BenRai, HalfBloodPrince, KuwaTakushi, kwad, makarov, mbuba666, nuthan2x, prk0, ZeroEx, and zzebra83
launchpad/libraries/RewardsTracker.sol #L225
The accumulated rewards per share variables stored on the Distributor may round to zero, particularly for quote tokens with few decimals. The project has not specified the quote token, but it seems reasonable to expect USDC would be an option. Consider a scenario where USDC is the quote token and pendingQuoteRewards for the launched token is 1000 USDC. If a user calls Distributor::claim then the accumulated rewards per share will be calculated on RewardsTracker.sol:225:
accQuoteRewardsPerShare += ((self.pendingQuoteRewards * PRECISION_FACTOR) / uint128(totalShares));
The issue is that the PRECISION_FACTOR is only 1e12 so the numerator above is 1000e6 * 1e12 = 1000e18. Therefore if totalShares > 1000e18, zero will be added to accQuoteRewardsPerShare.
This scenario is not unlikely if using USDC because (1) totalShares is likely to be in the hundreds of millions of ether (based on the BONDING_SUPPLY which is hard coded as 800_000_000 ether) and (2) USDC earnings from the uniswap pair which add to the rewards will be small per each token swap (i.e. pendingQuoteRewards may be quite small).
Impact: users miss out on rewards and the funds are stuck in the Distributor contract.
Recommended mitigation steps
Consider increasing the PRECISION_FACTOR appropriately to handle this scenario.
View detailed Proof of Concept
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
Likely the precision factor used when dividing pending rewards by total shares is too small, so the integer division truncates to zero for low-decimal tokens and large share totals.
What the attacker needed
Quote token with few decimals, e.g. USDC; total shares above 1000e18; small pending quote rewards
The fix
The precision factor should be increased appropriately to handle this scenario.
How it was found
- Assume USDC is the quote token and pending quote rewards for the launched token are 1000 USDC.
- A user calls Distributor::claim, which recalculates accumulated quote rewards per share.
- The numerator is pending rewards multiplied by the precision factor, giving 1000e18.
- If total shares exceed 1000e18, the division yields zero and nothing is added to the accumulator.
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.
Rewards are shared out by tracking how much each unit of stake has earned so far. That per-unit figure is stored as a whole number, so if the reward is small compared with the total stake, the division rounds down to zero and nothing is recorded. The result is that people claiming rewards receive nothing and the money stays in the contract.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.