Total reward shares for token can reach zero after unlocking, causing GTELaunchpadV2Pair to be bricked
The Distributor contract reverts when adding rewards if the total shares for a token are zero, but the rewards program only ends when shares reach zero before unlocking. After unlocking, if all stakers transfer out, the pair contract still tries to distribute fees and reverts, bricking swaps and liquidity operations.
Submitted by hgrano, also found by 0rpse, 0x_DyDx, 0xIconart, 0xnija, 0xPhantom, 0xsai, 0xShitgem, 0xvd, AasifUsmani, agadzhalov, anchabadze, ARMoh, AvantGard, bigbear1229, c0pp3rscr3w3r, ChainSentry, chaos304, codegpt, dhank, dimulski, dray, Egbe, Ekene, eth_11, FalseGenius, hashbug, hezze, IvanAlexandur, jerry0422, joe23joe, johnyfwesh, lodelux, MadSisyphus, magiccentaur, mahdifa, max10afternoon, mightyraj2605, mrMorningstar, mustapha, nem0TheFinder, nuthan2x, prk0, random1106, RanjanSharma, ret2basic, Rhaydden, roccomania, romans, saikumar279, saraswati, serial-coder, Stormy, taticuvostru, udogodwin, v2110, VAD37, VinciGearHead, Web3Vikings, Wolf_Kalp, won, ZeroEx, and zzebra83
launchpad/Distributor.sol #L119
The totalShares variable stored for each launch token on the Distributor will eventually reach zero once all of the original stakers transfer out their tokens. If this happens once the token has been unlocked, then the rewards program which distributes rewards from the GTELaunchpadV2Pair to the Distributor continues regardless. We can see this is the case as the rewards program only ends if the total shares reaches zero prior to unlocking on LaunchToken.sol:147:
if (totalFeeShare == 0 && !unlocked) _endRewards();
Consider the case where totalShares goes to zero and any function which calls _update on the pair is executed. If there is any non-zero amount of accumulated launch pad fees (and some time has elapsed since the previous call), then the GTELaunchpadV2Pair will attempt to distribute the fees by calling Distributor::addRewards. Distributor.sol:119 will cause a revert as totalShares is zero:
if (rs.totalShares == 0) revert NoSharesToIncentivize();
Now the pair contract is bricked and cannot be used for swaps or adding/removing liquidity.
Recommended mitigation steps
It appears the condition on LaunchToken.sol:147 may have been coded accidentally with the wrong condition. It would make sense to change it to:
if (totalFeeShare == 0 && unlocked) _endRewards();
This way the rewards program will end post-unlocking if all stakers transfer their tokens out, preventing Distributor::addRewards being called by the pair.
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 condition that ends the rewards program checks that the token is not yet unlocked, so after unlocking the program continues even when total shares are zero, causing the distributor to revert on addRewards.
What the attacker needed
Token is unlocked; all stakers transfer out their tokens; accumulated fees and time elapsed
The fix
The condition should be changed to end rewards after unlocking when total shares reach zero, preventing the pair from calling addRewards with zero shares.
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 launchpad token has a rewards program that pays stakers. The program is supposed to stop when no one is staking, but a condition checks the wrong timing. After the token unlocks, if everyone sells or transfers their tokens, the reward distributor refuses to accept new rewards, and the trading pair that sends those rewards gets stuck and cannot process trades.
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.