Skip to content
DoS Audit finding Intermediate

False “pool exists” detection via `balanceOf()` leads to broken swap paths

The pool existence check in two gateway contracts infers a UniswapV2 pair exists by reading token balances at the computed pair address, without verifying deployed code or reserves. An attacker can send small token amounts to that address so the check returns true, causing swap path selection to use a non-existent pool and transactions to revert.

0xEkko Follow with 1337, AnomX and 11 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2025-05-dodo-cross-chain-dex-judging/issues/856

This issue has been acknowledged by the team but won't be fixed at this time.

Found by

0xEkko, 1337, AnomX, Cybrid, EgisSecurity, Ob, ZeroTrust, hy, mahdiRostami, peppef, roadToWatsonN101, rsam_eth, silver_eth, the_haritz

Summary

The function _existsPairPool() in GatewayCrossChain.sol and GatewayTransferNative.sol uses ERC20.balanceOf() at a computed UniswapV2 pair address to infer pool existence. Because any address can hold tokens—even without a deployed pair contract—this check produces false positives. Consequently, getPathForTokens() may return a direct token–token path that does not actually exist, triggering downstream transaction reverts and denial of service.

Root Cause

In both contracts, _existsPairPool() is implemented as follows: https://github.com/sherlock-audit/2025-05-dodo-cross-chain-dex/blob/main/omni-chain-contracts/contracts/GatewayCrossChain.sol#L207-L220

This logic never verifies that pool has deployed contract code, nor does it read real reserves via getReserves(). It thus treats any stray token balances at that address as liquidity.

Internal Pre-conditions

  1. A call to getPathForTokens(tokenA, tokenB) is made.

  2. _existsPairPool() returns true because the computed address holds non-zero balances of both tokens.

  3. The actual UniswapV2 pair contract was never deployed at that address.

External Pre-conditions

  1. An EOA or arbitrary contract receives tokenA and tokenB transfers at the computed pool address.

  2. The true UniswapV2 factory has not created a pair for (tokenA, tokenB).

Attack Path

  1. Attacker transfers small amounts of tokenA and tokenB to the computed pair address (no contract deployed).

  2. User or protocol calls getPathForTokens(tokenA, tokenB).

3. _existsPairPool() returns true (false positive).

  1. getPathForTokens() returns [tokenA, tokenB] instead of fallback path.

  2. Downstream swap via UniswapV2 router (e.g., swapExactTokensForTokens) attempts to interact with a non-existent pool contract.

  3. Transaction reverts, causing denial of service.

Impact

  1. Denial of Service: Legitimate swaps between tokenA and tokenB cannot execute.

  2. Broken UX: Cross-chain transfers or swaps fail unexpectedly whenever a fake “liquidity” address is used.

PoC

No response

Mitigation

No response

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

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 existence check relies only on token balances at the computed pair address and never verifies that contract code is deployed there or reads actual reserves.

Impact

Legitimate swaps between the affected tokens cannot execute and cross-chain transfers or swaps fail unexpectedly, causing denial of service and broken user experience.

What the attacker needed

Attacker can transfer tokens to any address; no real UniswapV2 pair exists for the token pair; a user or protocol triggers path selection

The fix

The check should verify that the computed pair address has deployed contract code and read real reserves rather than relying on token balances; the team acknowledged the issue but stated it will not be fixed at this time.

How it was found

  1. Attacker transfers small amounts of two tokens to the computed pair address where no contract is deployed.
  2. A user or the protocol calls the path-finding function for those two tokens.
  3. The existence check returns true because the address holds token balances.
  4. The path finder returns a direct token-to-token path instead of a fallback path.
  5. A downstream swap through the UniswapV2 router tries to interact with the non-existent pool and 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 smart contract tried to guess whether a trading pool existed by checking if that pool's address held any tokens. But anyone can send tokens to any address, even one with no contract behind it, so the guess could be fooled. When fooled, the contract picked a trading route that did not really exist and the trade failed.

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.

More by 0xEkko

View all

10 more disclosed reports, best first.

More from DODO Cross-Chain DEX

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.