Griefing attack on GenesisPoolManager.sol::depositNativeToken leading to Denial of Service
The depositNativeToken function checks that an existing pair has zero token balances but does not verify that the pair was created by the protocol. An attacker can create an empty pair for the target tokens and send a tiny amount of each token to it, causing the legitimate deposit transaction to revert and blocking pool creation.
FavourOkerri Follow with AvantGard
Originally disclosed on Code4rena
Submitted by FavourOkerri, also found by AvantGard
Finding description
The process of depositing native token to a Genesis Pool is vulnerable to a griefing attack, leading to a denial of service (DoS) for legitimate pool creations.
The vulnerability arises from the interaction of the following factors:
- Public information: The
nativeTokenandfundingTokenaddresses intended for a new Genesis Pool become public information when theGenesisPoolFactory.createGenesisPooltransaction enters the mempool or through theGenesisCreatedevent it emits. - Unrestricted pair creation: The
pairFactory.createPairfunction allows any external actor to create a new liquidity pair for any given tokenA, tokenB, and stable combination, provided a pair for that combination doesn’t already exist.
function createPair(address tokenA, address tokenB, bool stable) external returns (address pair) {
require(tokenA != tokenB, "IA"); // Pair: IDENTICAL_ADDRESSES
(address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
require(token0 != address(0), "ZA"); // Pair: ZERO_ADDRESS
require(getPair[token0][token1][stable] == address(0), "!ZA");
pair = IPairGenerator(pairGenerator).createPair(token0, token1, stable);
getPair[tokenA][tokenB][stable] = pair;
getPair[tokenB][tokenA][stable] = pair; // Store in reverse direction
allPairs.push(pair);
isPair[pair] = true;
emit PairCreated(token0, token1, stable, pair, allPairs.length);
}
- Vulnerable validation: In
GenesisPoolManager.depositNativeToken(), the protocol checks whether the pair already exists. If so, it requires that both token balances in the pair are zero — but does not verify whether the pair was created by the protocol itself.
function depositNativeToken(
address nativeToken,
uint256 auctionIndex,
GenesisInfo calldata genesisPoolInfo,
TokenAllocation calldata allocationInfo
) external nonReentrant returns (address genesisPool) {
//.................code
address pairAddress = pairFactory.getPair(nativeToken, _fundingToken, _stable);
if (pairAddress != address(0)) {
require(IERC20(nativeToken).balanceOf(pairAddress) == 0, "!ZV");
require(IERC20(_fundingToken).balanceOf(pairAddress) == 0, "!ZV");
}
//........................more code
Attack Scenario:
An attacker can observe a pending createGenesisPool transaction (or the GenesisCreated event). The attacker can:
- Call
pairFactory.createPair(nativeToken,fundingToken,stable) to create a new, empty LP pair for the target tokens. - Immediately after, transfer a minimal non-zero amount (e.g., 1 wei) of both
nativeTokenandfundingTokendirectly to this newly created pair contract address.
Impact
When the legitimate depositNativeToken transaction executes,pairFactory.getPairwill return the attacker's pair address. The require(IERC20(token).balanceOf(pairAddress) == 0, “!ZV”);checks will then fail because the pair now holds a non-zero balance of tokens. This causes the legitimatedepositNativeToken` transaction to revert, resulting in:
- Denial of Service (DoS): Legitimate projects are repeatedly blocked from launching their intended Genesis Pools.
- Griefing: An attacker can perform this attack with minimal gas cost, making it a highly effective and low-cost method to disrupt the protocol’s core functionality.
Recommended mitigation steps
Add pair ownership or Origin validation. Instead of just checking balance == 0, validate that your protocol created the pair, or that the pair was expected.
Status: Unmitigated. Full details in reports from rayss, lonelybones and maxvzuvex, and also included in the Mitigation Review section below.
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 protocol trusts any existing pair with zero balances without verifying that the pair was created by the protocol or is the expected one.
Impact
Legitimate projects are repeatedly blocked from launching their Genesis Pools, and the attack costs the attacker very little gas.
What the attacker needed
Ability to observe pending transactions or events; ability to call createPair on the public factory; small amount of both tokens to send to the pair
The fix
The protocol should validate that the pair was created by the protocol itself, for example by checking pair ownership or origin, instead of only checking that balances are zero.
How it was found
- Observe a pending createGenesisPool transaction or the GenesisCreated event to learn the nativeToken and fundingToken addresses.
- Call pairFactory.createPair with the nativeToken, fundingToken, and stable flag to create an empty pair.
- Transfer a minimal non-zero amount of both tokens directly to the newly created pair contract.
- When the legitimate depositNativeToken transaction executes, the balance checks fail and the transaction reverts.
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 pair is a smart contract that holds two types of tokens so people can trade between them. The protocol assumed that if a pair already existed and was empty, it must have been created by the protocol itself, but anyone can create a pair. An attacker creates the pair first and puts a tiny amount of tokens in it, so when the real project tries to set up its pool, a safety check fails and the transaction is rejected.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.