Skip to content
Business logic Audit finding Advanced

Bypass of recipient check allows pre-seeding the real pair and manipulating initial AMM price

The Launchpad's pairFor() helper derives the Uniswap V2 pair address without the extra salt values the custom factory uses, so the donation guard compares against the wrong address. An attacker could send purchased launch tokens straight into the real pair during bonding, pre-seed reserves and set the initial AMM price before graduation.

0xMilenov Follow with 0xsagetony, Bale and 7 others

Originally disclosed on Code4rena

Submitted by 0xMilenov, also found by 0xsagetony, Bale, codegpt, dimulski, nem0TheFinder, nuthan2x, roccomania, romans, and Web3Vikings

  • launchpad/Launchpad.sol #L800-L842
  • launchpad/uniswap/GTELaunchpadV2PairFactory.sol #L43-L82

The Launchpad system bonds a new LaunchToken against a quote asset on a bonding curve. Upon graduation, the Launchpad adds initial liquidity to a Uniswap V2 pair and locks the LP to a vault so that subsequent trading can begin. To prevent attackers from donating tokens to the AMM during bonding (which would set the initial AMM price), Launchpad attempts to block buys that send base tokens directly to the AMM pair by checking the recipient against the computed pair address.

Core actors and responsibilities:

  • Launchpad.sol: runs the bonding curve lifecycle (buy(), sell()), creates pairs on graduation, and guards against donations during bonding via _assertValidRecipient(). It also calls endRewards().
  • GTELaunchpadV2PairFactory: deploys GTELaunchpadV2Pair and embeds both launchpadLp (vault) and launchpadFeeDistributor into the CREATE2 salt and into pair initialization.
  • GTELaunchpadV2Pair: the AMM pair that accrues protocol fees to the distributor, parameterized via the factory.
  • Distributor and LaunchpadLPVault: receive accrued rewards and custody of initial LP respectively.

Root cause - Launchpad.pairFor() computes a pair address using the standard Uniswap formula but only hashes (token0, token1) + initCodeHash:

pair = IUniswapV2Pair(
    address(
        uint160(
            uint256(
                keccak256(
                    abi.encodePacked(
                        hex"ff",
                        factory,
                        keccak256(abi.encodePacked(token0, token1)), // <-- here we are missing lp and distributor
                        uniV2InitCodeHash // init code hash
                    )
                )
            )
        )
    )
);

The custom factory’s CREATE2 salt additionally includes launchpadLp and launchpadFeeDistributor. The Launchpad’s computed address therefore diverges from the factory-deployed pair address:

bytes32 salt = keccak256(
    abi.encodePacked(
        token0,
        token1,
        _launchpadLp, // <-- here
        _launchpadFeeDistributor // <-- here
    )
);
assembly {
    pair := create2(0, add(bytecode, 32), mload(bytecode), salt)
}

The donation guard _assertValidRecipient() compares recipient to this wrong address, so passing the real pair as recipient will not trip the check and donations are allowed during bonding.

 function _assertValidRecipient(
    address recipient,
    address baseToken
) internal view returns (IUniswapV2Pair pair) {
    pair = pairFor(
        address(uniV2Factory),
        baseToken,
        _launches[baseToken].quote
    );

    if (address(pair) == recipient) revert InvalidRecipient();
}

[!NOTE] The previous mitigation attempted to forbid donations by checking recipient != pairFor(...) during bonding. Because pairFor() is wrong for this custom factory, the check can be bypassed by supplying the real pair address as the recipient.

Detailed consequences:

  • Root cause - pairFor function - wrong address derivation:

    • In pairFor(), the salt is computed as: keccak256(abi.encodePacked(token0, token1))
    • The custom factory actually uses: keccak256(abi.encodePacked(token0, token1, launchpadLp, launchpadFeeDistributor))
    • Result: Launchpad’s locally computed address differs from the factory’s actual pair, making any downstream logic relying on pairFor() incorrect.
  • First vulnerable place - recipient check bypass in _assertValidRecipient():

    • The donation guard compares recipient to pairFor(factory, baseToken, quote). Because pairFor() is wrong, an attacker can pass the real pair as recipient, and the equality check will be false, allowing base tokens to be sent to the real pair during bonding.
    • This enables pre-seeding reserves before graduation, setting initial AMM price arbitrarily and breaking the assumption that Launchpad controls the initial price by calling addLiquidity() after bonding.
    • buy() invokes _assertValidRecipient() to prevent donations. Due to the first vulnerable place, buy() succeeds with recipient=realPair, transferring purchased LaunchToken straight into the AMM pair during bonding.
    • With sufficient preparation, the attacker can then add quote tokens and mint LP to lock in manipulated reserves/price before launchpad’s graduation adds its intended liquidity.
    • Or with other words, the fix of the critical vulnerability from the previous audit, is not well implemented
  • Second vulnerable place - rewards finalization misdirection in endRewards():

    • endRewards() uses the same miscomputed address to target the pair when calling into the distributor/pair to end accrual. Post-graduation, this can result in a silent DoS (targeting an EOA/no-code) or acting on an unrelated pair if an address collision exists, leaving the real market’s rewards active or incorrectly affected.

      function endRewards() external onlyLaunchAsset {
      address quote = _launches[msg.sender].quote;
      IGTELaunchpadV2Pair pair = IGTELaunchpadV2Pair(
      address(pairFor(address(uniV2Factory), msg.sender, quote))
      );
      

    distributor.endRewards(pair); }

  • Third vulnerable place - post-graduation skim path and ops on wrong address:

    • In _createPairAndSwapRemaining(), Launchpad may call pair.skim(owner()). If the pair already exists and Launchpad’s pairFor() is wrong, it will operate on the wrong address.

      IUniswapV2Pair pair = _assertValidRecipient(
      buyData.recipient,
      buyData.token
      );
      ...
      ...
      function _graduate(
      BuyData calldata buyData,
      IUniswapV2Pair pair,
      LaunchData memory data,
      uint256 amountOutBaseActual,
      uint256 amountInQuote
      )
      internal
      returns (uint256 finalAmountOutBaseActual, uint256 finalAmountInQuote)
      {
      LaunchToken(buyData.token).unlock();
      _launches[buyData.token].active = false;
      emit BondingLocked(buyData.token, pair, LaunchpadEventNonce.inc());
      

    uint256 additionalQuote = _createPairAndSwapRemaining({ token: buyData.token, pair: pair, … …

function _createPairAndSwapRemaining( address token, IUniswapV2Pair pair, LaunchData memory data, uint256 remainingBase, uint256 remainingQuote, address recipient ) internal returns (uint256 additionalQuoteUsed) { … … pair.skim(owner());

Highest-impact scenario (replicates the old report’s flow with current code):
- During bonding, a user buys base and sets the `recipient` to the real Uniswap V2 pair address. Since `_assertValidRecipient()` compares against the wrong address, the buy succeeds and base tokens are transferred into the AMM pair.
- The attacker adds quote liquidity and mints LP to fix the reserves ratio and effectively set the initial AMM price.
- When bonding completes and Launchpad calls `addLiquidity()`, it will no longer be able to inject its intended liquidity ratio; instead, Uniswap’s `_addLiquidity()` uses current reserves to compute optimal amounts, preserving the attacker’s chosen price. The attacker can then immediately sell launch tokens at favorable prices to extract excess quote tokens.

### Recommended mitigation steps

Update `pairFor()` to replicate the factory salt and avoid mismatch:
  - Build salt as `keccak256(abi.encodePacked(token0, token1, address(launchpadLPVault), address(distributor)))`.
  - Keep `uniV2InitCodeHash` in sync with the actual pair bytecode in use. Prefer immutable configuration or rotate router/factory alongside the hash.
  - Still prefer `getPair()` for safety and simplicity.

[View detailed Proof of Concept](https://code4rena.com/audits/2025-08-gte-perps-and-launchpad/submissions/F-59)

***

## [[M-22] User can prevent anyone from receiving rewards](https://code4rena.com/audits/2025-08-gte-perps-and-launchpad/submissions/F-62)
*Submitted by [mrMorningstar](https://code4rena.com/audits/2025-08-gte-perps-and-launchpad/submissions/S-320), also found by [agadzhalov](https://code4rena.com/audits/2025-08-gte-perps-and-launchpad/submissions/S-1280), [BowTiedOriole](https://code4rena.com/audits/2025-08-gte-perps-and-launchpad/submissions/S-1402), [gesha17](https://code4rena.com/audits/2025-08-gte-perps-and-launchpad/submissions/S-745), [IvanAlexandur](https://code4rena.com/audits/2025-08-gte-perps-and-launchpad/submissions/S-872), [kimnoic](https://code4rena.com/audits/2025-08-gte-perps-and-launchpad/submissions/S-937), [mahdifa](https://code4rena.com/audits/2025-08-gte-perps-and-launchpad/submissions/S-265), and [Neon2835](https://code4rena.com/audits/2025-08-gte-perps-and-launchpad/submissions/S-1363)*

`launchpad/LaunchToken.sol` [#L134](https://github.com/code-423n4/2025-08-gte-perps/blame/f43e1eedb65e7e0327cfaf4d7608a37d85d2fae7/contracts/launchpad/LaunchToken.sol#L134)

When user buys base tokens (via [buy](https://github.com/code-423n4/2025-08-gte-perps/blob/f43e1eedb65e7e0327cfaf4d7608a37d85d2fae7/contracts/launchpad/Launchpad.sol#L272)) they become eligible to earn rewards which are distributed over time.

The trigger for ending rewards is in `LaunchToken.sol`:

```js
function _decreaseFeeShares(address account, uint256 amount) internal {
        uint256 share = bondingShare[account];
        if (share == 0 || account == address(0)) return;

        amount = amount > share ? share : amount;

        emit FeeShareDecreased(account, amount, _incEventNonce());

        unchecked {
            totalFeeShare -= amount;
            bondingShare[account] -= amount;
        }

        if (totalFeeShare == 0 && !unlocked) _endRewards();

        ILaunchpad(launchpad).decreaseStake(account, uint96(amount));
    }

    /// @dev Hook to end rewards program for this base token if no more pre-bonding shares exist
    function _endRewards() internal {
        ILaunchpad(launchpad).endRewards();

        emit FeeShareConcluded(block.timestamp, _incEventNonce());
    }

As we can see rewards would be ended in case all base tokens are sold before graduation happens.

When graduation happens, protocol creates token pair (if it is not already created) and adds remaining liquidity to it so they can be swapped via AMM where with each swap rewards are accrued.

This can be exploited and user would prevent accrual of rewards and fees.

Malicious user creates pair in GTELaunchpadV2PairFactory via createPair. As we can see function is permission less anyone can create pair. The protocol accounted that in _createPairAndSwapRemaining when graduating:

    .
    .
    .
    // Create or get the pair
        try uniV2Factory.createPair(token, data.quote) returns (address p) {
            pair = IUniswapV2Pair(p);
        } catch {
            // Do nothing, pair exists
            // @todo its more gas but lets check pair exists and create if it doest.
            // try catch in solidity is horrible and should be avoided
        }
    .
    .
    .

It will try to create pair and if pair is already created it will use that.

Then user (we can assume first buyer) buys base tokens via buy and then immediately sells them via sell.

This will trigger the end rewards in LaunchToken because total fee shares would be 0 and unlocked is still false because bonding period is not over.

So eventually endRewardsAccrual would be invoked for the pair and rewards would stop accruing before they actually begin accruing after graduation:

function endRewardsAccrual() external {
        if (msg.sender != launchpadFeeDistributor) revert("GTEUniV2: FORBIDDEN");

        // There are no more shares, so prevent distribution and accrual of any remaining rewards
        delete accruedLaunchpadFee0;
        delete accruedLaunchpadFee1;
        delete rewardsPoolActive;

        _update(
            IERC20(token0).balanceOf(address(this)),
            IERC20(token1).balanceOf(address(this)),
            reserve0,
            reserve1,
            uint112(0),
            uint112(0)
        );

        emit RewardsPoolDeactivated();
    }

As we can see rewardsPoolActive will go from 1 to 0 when reward accrual is ended.

The rewards are accrued via swap which can be done after graduation only and when rewardsPoolActive is not 0:

    .
    .
    .
    (uint112 launchpadFee0, uint112 launchpadFee1) = launchpadFeeDistributor > address(0)
                && rewardsPoolActive > 0 ? _getLaunchpadFees(amount0In, amount1In) : (uint112(0), uint112(0));
    .
    .
    .

So malicious user effectively prevented accruing rewards and with no cost basically (only gas fees).

Here are the simplified steps to recap this attack:

  1. User create pair
  2. User buys and then immediately sells base tokens
  3. End rewards is triggered in LaunchToken
  4. From distributor on pair contract endRewardsAccrual is invoked so protocol stops accruing rewards (before accrual actually begins after graduation)
  5. After some time, graduation occurs and users start swapping without protocol collecting fees for rewards as it should

Impact

Malicious user can prevent rewards accrual.

The attack is simple, repetitive and cheap to execute so the likelihood to happen is HIGH.

Recommended mitigation steps

If possible design so that ending of rewards can be done only after graduation happens as this will prevent the exploit.

Also maybe add functionality where trusted address or admin can enable and disable rewards accruing.

View detailed Proof of Concept


The original report as published on Code4rena, by 0xMilenov. 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 pair address helper hashes only the two token addresses, while the custom factory's CREATE2 salt also includes the LP vault and fee distributor, so the computed address never matches the deployed pair.

Impact

An attacker could set the initial AMM price and profit from selling at favourable rates; the same wrong address also makes endRewards() and the skim path act on the wrong address, which could silently stop reward accrual or affect an unrelated pair.

What the attacker needed

Ability to buy during bonding; real pair address known; no special role needed

The fix

pairFor() should be updated to build the salt with the LP vault and fee distributor addresses, keep the init code hash in sync, or simply use the factory's getPair().

How it was found

  1. Create the pair through the permissionless factory, or otherwise ensure the real pair exists.
  2. During bonding, buy launch tokens with the real pair address as the recipient so the guard is bypassed.
  3. Add quote tokens and mint LP to fix the reserves ratio and set the initial price.
  4. After graduation, sell launch tokens at the manipulated price to extract quote tokens.

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.

When a new token graduates, the platform creates a trading pool and adds starting liquidity, which sets the first price. The code tried to stop people from sending tokens into that pool early by comparing the recipient to a computed pool address, but the address was calculated wrongly, so the real pool slipped past the check. That let someone fill the pool early and influence the starting price.

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 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.