Skip to content
Business logic Audit finding Intermediate

GTELaunchpadV2Pair permits minting LP tokens for free when there are non-zero accumulated launch pad fees

The mint function calculates the deposited token amounts as the difference between current balances and reserves, but reserves exclude accumulated launchpad fees. An attacker can call mint directly to mint LP tokens for free, then burn them to steal funds from the pair.

hgrano Follow with 0rpse, 0xNaN and 13 others

Originally disclosed on Code4rena

Submitted by hgrano, also found by 0rpse, 0xNaN, AasifUsmani, AvantGard, BowTiedOriole, codegpt, dimulski, gizzy, hezze, IvanAlexandur, nuthan2x, saraswati, serial-coder, Web3Vikings, and ZeroEx

launchpad/uniswap/GTELaunchpadV2Pair.sol #L187-L188

In GTELaunchpadV2Pair::mint, the amount0 and amount1 of tokens provided to the contract are calculated as the difference between current balances and reserves on lines 185-188:

        uint256 balance0 = IERC20(token0).balanceOf(address(this));
        uint256 balance1 = IERC20(token1).balanceOf(address(this));
        uint256 amount0 = balance0.sub(_reserve0);
        uint256 amount1 = balance1.sub(_reserve1);

The issue is that reserves are set in the _update function as the current balances subtract away any accumulated fees (lines 154-155):

        reserve0 = _reserve0 = uint112(balance0) - totalLaunchpadFee0;
        reserve1 = _reserve1 = uint112(balance1) - totalLaunchpadFee1;

Let’s assume a scenario where both totalLaunchpadFee0 and totalLaunchpadFee1 are non-zero and a user directly calls mint (without pre-transferring any tokens to the pair). In this case, mint will mistakenly calculate amount0 and amount1 to be the launchpad fees - the difference between current balances and reserves. Thereby the user will be able to mint LP tokens for free. They can repeat the call to mint an unlimited number of times - provided they make the calls within the same block as when the fees were received so that the launchpad fees don’t get cleared. They can then cash out the stolen assets using burn.

Impact: theft of user and protocol funds - this could end up draining all of the funds in the pair contract due to a large number of calls to the mint function.

Recommended mitigation steps

Subtract off the accumulated launch pad fees when calculating the amount transferred in by the minter:

--- a/contracts/launchpad/uniswap/GTELaunchpadV2Pair.sol
+++ b/contracts/launchpad/uniswap/GTELaunchpadV2Pair.sol
@@ -184,8 +184,8 @@ contract GTELaunchpadV2Pair is IUniswapV2Pair, IGTELaunchpadV2Pair, UniswapV2ERC
         (uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
         uint256 balance0 = IERC20(token0).balanceOf(address(this));
         uint256 balance1 = IERC20(token1).balanceOf(address(this));
-        uint256 amount0 = balance0.sub(_reserve0);
-        uint256 amount1 = balance1.sub(_reserve1);
+        uint256 amount0 = balance0.sub(_reserve0).sub(accruedLaunchpadFee0);
+        uint256 amount1 = balance1.sub(_reserve1).sub(accruedLaunchpadFee1);

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

The mint function computes the deposited amounts as balance minus reserve, but the reserve already excludes accumulated launchpad fees, so those fees are counted as a deposit.

Impact

This could drain all funds in the pair contract, as the attacker can mint unlimited LP tokens and burn them for assets.

What the attacker needed

Non-zero accumulated launchpad fees; calls made within the same block

The fix

The mint function should subtract the accumulated launchpad fees when calculating the deposited amounts.

How it was found

  1. Accumulate non-zero launchpad fees in the pair.
  2. Directly call mint without transferring any tokens.
  3. Repeat the mint call within the same block to mint more LP tokens.
  4. Call burn to cash out the stolen assets.

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 liquidity pool holds two tokens and tracks how much each user has deposited. The pool also collects fees, which are kept aside and not counted in the reserves. The mint function mistakenly treats those fees as a new deposit, so anyone can create pool shares without paying anything and then withdraw real tokens.

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.