Skip to content
Business logic Audit finding Intermediate

Donations to Distributor with arbitrary quoteToken can be used to drain all quote rewards from distributor

The addRewards function in Distributor.sol does not verify that the quoteAsset parameter is a legitimate token, allowing an attacker to supply a malicious contract as token1. By doing so, the attacker can inflate the recorded quote rewards without transferring real tokens, then drain all quote tokens from the contract and brick the system for other users.

hgrano Follow with 0xNaN, anchabadze and 25 others

Originally disclosed on Code4rena

Submitted by hgrano, also found by 0xNaN, anchabadze, Bigsam, c0pp3rscr3w3r, codegpt, cu5t0mpeo, deccs, dna-thug, edantes, hezze, lodelux, max10afternoon, nem0TheFinder, newspacexyz, Nexarion, nuthan2x, osok, PotEater, random1106, saraswati, serial-coder, TobechukwuAzogu, VAD37, VinciGearHead, Web3Vikings, Wolf_Kalp, and ZeroEx

launchpad/Distributor.sol #L106-L132

Distributor::addRewards fails to validate that the provided quoteAsset is a legitimate token. Consider the case where an attacker provides a legitimate launch token as the token0 parameter, token1 is a malicious contract and amount0 is zero:

function addRewards(address token0, address token1, uint128 amount0, uint128 amount1) external {
        (address launchAsset, address quoteAsset, uint128 launchAssetAmount, uint128 quoteAssetAmount) =
            (token0, token1, amount0, amount1);
        RewardPoolData storage rs = RewardsTrackerStorage.getRewardPool(token0);

        if (rs.quoteAsset == address(0)) {
            // [...]
        }

        if (rs.totalShares == 0) revert NoSharesToIncentivize();

        if (launchAssetAmount > 0) {
            // [...]
        }

        if (quoteAssetAmount > 0) {
            rs.addQuoteRewards(launchAsset, quoteAsset, quoteAssetAmount);
            _increaseTotalPending(quoteAsset, quoteAssetAmount);
            quoteAsset.safeTransferFrom(msg.sender, address(this), uint256(quoteAssetAmount));
        }

The attacker can provide their own contract address for token1 as long as it implements a transferFrom function. The amount1 parameter they choose will cause an increase to the storage variable for the amount of quote rewards, but they will not contribute any actual reward tokens to the contract. Consequently, assuming the attacker holds some non-zero staking balance, they can then drain all the available quote tokens in the contract as the quote token rewards per share have been drastically over-inflated.

Impact: permanent loss of user funds as firstly they lose out on rewards. Secondly, the system becomes bricked for users which currently hold non-zero staking balances: they cannot transfer their tokens out due to the fact that LaunchToken triggers a reward distribution to the from account on transfers. This will fail now that there are insufficient quote tokens in the contract.

Recommended mitigation steps

Validate both the launch asset and quote asset are legitimate within addRewards.

View detailed Proof of Concept


The original report as published on Code4rena, by hgrano. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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 addRewards function fails to validate that the provided quoteAsset is a legitimate token, allowing a malicious contract to be used and inflate reward accounting without actual token transfer.

Impact

Permanent loss of user funds as users lose out on rewards, and the system becomes bricked for users with non-zero staking balances because they cannot transfer their tokens out due to failed reward distribution.

What the attacker needed

Attacker holds non-zero staking balance; attacker can deploy a malicious contract

The fix

Validate both the launch asset and quote asset are legitimate within addRewards.

How it was found

  1. Attacker provides a legitimate launch token as token0, a malicious contract as token1, and zero for amount0.
  2. The malicious contract implements a transferFrom function that does not actually transfer tokens.
  3. Attacker calls addRewards with a non-zero amount1, which increases the recorded quote rewards without contributing real tokens.
  4. Attacker, holding a non-zero staking balance, drains all quote tokens from the contract because the reward per share is over-inflated.

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.

This is a smart contract bug where a function that adds rewards does not check that the token used for rewards is real. An attacker can pretend to add rewards using a fake token, which tricks the system into thinking there are more rewards than actually exist. Then the attacker can take all the real reward tokens, and other users may be unable to move their tokens because the system tries to give them rewards it no longer has.

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.

More by hgrano

View all

10 more disclosed reports, best first.

More from GTE Perps and Launchpad

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.