Skip to content
Business logic Audit finding Intermediate

isGenesis flag is ineffective to control add liquidity flow in RouterV2.addLiquidity()

The isGenesis flag was meant to block external liquidity additions to Genesis Pool pairs before launch, but the RouterV2.addLiquidity check only blocked when totalSupply was zero, and Pair.mint had no isGenesis check at all. An attacker could add a tiny amount of liquidity directly via mint to make totalSupply non-zero, then use the router to add liquidity, disrupting the controlled launch.

maxzuvex Follow

Originally disclosed on Code4rena

Submitted by maxzuvex

https://github.com/code-423n4/2025-05-blackhole/blob/92fff849d3b266e609e6d63478c4164d9f608e91/contracts/RouterV2.sol#L384

Finding description

The check that prevents external liquidity additions to “Genesis Pool” pairs before their official launch are insufficient. The RouterV2.addLiquidity() check can be bypassed once any LP tokens exist (even dust) and Pair.mint() also has no isGenesis check at all, letting direct initial liquidity supply. This damages the controlled launch, let potential price manipulation and launch disruption and clearly stated intended behaviour.

  1. RouterV2.addLiquidity guard issue:
 // contracts/RouterV2.sol
 function addLiquidity(...) external ensure(deadline) returns ... {
     ...
     require(!(IBaseV1Factory(factory).isGenesis(pair) && IBaseV1Pair(pair).totalSupply() == 0), "NA");
     _safeTransferFrom(tokenA, msg.sender, pair, amountA);
     _safeTransferFrom(tokenB, msg.sender, pair, amountB);
     liquidity = IBaseV1Pair(pair).mint(to);
 }
  • If isGenesis(pair) is true and totalSupply() is 0, the inner condition (true && true) is true. The require(!true) fails, correctly blocking.
  • Once totalSupply > 0 (for example after official GenesisPool launch, or a prior dust minting by an attacker), this check becomes require(!(true && false)) which is require(true), allowing anyone to add liquidity using the router if the isGenesis flag hasn’t been cleared yet.
  • This means if isGenesis flag is not set to false immediately before the GenesisPool contract calls addLiquidity, then after the GenesisPool successfully adds its liquidity (making totalSupply > 0), any subsequent call to RouterV2.addLiquidity() for that pair would pass the check, letting external LPs in prematurely.
  • Pair.mint() is not restricted:
// contracts/Pair.sol:
function mint(address to) external lock returns (uint liquidity) {
     (uint _reserve0, uint _reserve1) = (reserve0, reserve1);
     uint _balance0 = IERC20(token0).balanceOf(address(this));
     uint _balance1 = IERC20(token1).balanceOf(address(this));
     uint _amount0 = _balance0 - _reserve0;
     uint _amount1 = _balance1 - _reserve1;

     uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee
     if (_totalSupply == 0) {
         liquidity = Math.sqrt(_amount0 * _amount1) - MINIMUM_LIQUIDITY;
         _mint(address(0), MINIMUM_LIQUIDITY); // permanently lock the first MINIMUM_LIQUIDITY tokens
     } else {
         liquidity = Math.min(_amount0 * _totalSupply / _reserve0, _amount1 * _totalSupply / _reserve1);
     }
     require(liquidity > 0, 'ILM'); // Pair: INSUFFICIENT_LIQUIDITY_MINTED
     _mint(to, liquidity);

     _update(_balance0, _balance1, _reserve0, _reserve1);
     emit Mint(msg.sender, _amount0, _amount1);
 }
  • Pair.sol::mint() does not have any isGenesis status check.
  • An attacker can transfer minimal token0 and token1 to a Genesis pair (where isGenesis == true and totalSupply == 0) and call mint() directly.
  • This mints LP tokens, makes totalSupply > 0, and bypasses the (already weak) RouterV2.addLiquidity guard for that pair.

Impact

The impact isn’t a direct loss of deposited funds but is a significant disruption to a core protocol mechanism, potentially leading to unfair advantages, poor launch conditions for projects, and reduced trust. This fits a Medium severity: ”Assets not at direct risk, but the function of the protocol or its availability could be impacted, or leak value with a hypothetical attack path with stated assumptions“.

This is also clearly against this statement in contract diff / Liquidity Pool / PairFactory: ”When a pair gets listed as Genesis Pool until it’s not successfully launched noone should be able to add liquidity so we’re using this isGenesis flag to control add liquidity flow”

Recommended mitigation steps

  1. In RouterV2.addLiquidity block if the pair is a Genesis Pool, regardless of totalSupply.
- require(!(IBaseV1Factory(factory).isGenesis(pair) && IBaseV1Pair(pair).totalSupply() == 0), "NA");
+ require(!IBaseV1Factory(factory).isGenesis(pair), "GENESIS_POOL_LIQUIDITY_LOCKED");
  1. Restrict Pair.mint() for genesis pairs by adding a check in Pair.sol::mint():
function mint(address to) external lock returns (uint liquidity) {
+   require(!PairFactory(factory).isGenesis(address(this)), "GENESIS_POOL_MINT_LOCKED");
    // ... existing mint logic ...
}

Blackhole mitigated

Status: Mitigation confirmed. Full details in reports from rayss and maxvzuvex.


The original report as published on Code4rena, by maxzuvex. 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 router's guard only checked totalSupply == 0 instead of the isGenesis flag alone, and the pair's mint function had no isGenesis restriction, so a dust mint could flip the router check.

Impact

The impact is not direct loss of deposited funds but significant disruption to the controlled launch, potentially enabling unfair advantages and poor launch conditions; the report rates this as Medium severity.

What the attacker needed

A Genesis Pool pair exists with isGenesis true; Attacker can transfer tokens to the pair; Attacker can call Pair.mint directly

The fix

The mitigation was confirmed: the router should block any Genesis Pool regardless of totalSupply, and Pair.mint should also check isGenesis.

How it was found

  1. Identify a Genesis Pool pair where isGenesis is true and totalSupply is zero.
  2. Transfer a minimal amount of both tokens directly to the pair contract.
  3. Call Pair.mint() directly to create LP tokens, making totalSupply greater than zero.
  4. Call RouterV2.addLiquidity() for the same pair; the guard now passes because totalSupply is no longer zero.

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 Genesis Pool is a new trading pair that the project wants to launch in a controlled way, so it uses a flag to stop outsiders from adding liquidity early. The router tried to block this, but its check only worked while the pool had zero LP tokens; an attacker could create a tiny amount of LP tokens directly through the pair contract, which made the router's check pass. After that, anyone could add liquidity through the router before the official launch.

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 maxzuvex

View all

2 more disclosed reports, best first.

More from Blackhole

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.