Skip to content
Business logic Audit finding Intermediate

Zero-receiver fund burn

The RouterV2 contract's swap functions use a route struct whose receiver field defaults to the zero address when not set, so swapped tokens are sent to address(0) and burned. Every swap through these functions fails to deliver tokens to users, causing 100% loss of funds.

0x15 Follow

Originally disclosed on Code4rena

Submitted by 0x15

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

Finding description and impact

The RouterV2 implementation has a fundamental flaw where tokens are burned to the zero address instead of being sent to the intended recipient.

The route struct includes a receiver field that defaults to address(0) when not explicitly set:

struct route {
        address pair;
        address from;
        address to;
        bool stable;
        bool concentrated;
        address receiver;
    }

In the _swap function, both swap paths use routes[i].receiver as the destination.

For concentrated pools, it’s used as the recipient parameter:

recipient: routes[i].receiver

For standard pools, it’s used in the swap call:

IBaseV1Pair(pairFor(routes[i].from, routes[i].to, routes[i].stable)).swap(
                    amount0Out, amount1Out, routes[i].receiver, new bytes(0)
                );

The critical issue is in how routes are constructed.

In swapExactTokensForTokensSimple routes are created with only from, to, stable, and concentrated fields set, but the receiver field is never populated:

route[] memory routes = new route[](1);
        routes[0].from = tokenFrom;
        routes[0].to = tokenTo;
        routes[0].stable = stable;
        routes[0].concentrated = concentrated;

In swapExactTokensForTokens routes are passed directly from users who build them without setting the receiver field:

 function swapExactTokensForTokens(
        uint amountIn,
        uint amountOutMin,
        route[] calldata routes,
        address to,
        uint deadline
    ) external ensure(deadline) returns (uint[] memory amounts) {

Both functions pass the _to parameter to _swap, but it’s never used - the function only uses routes[i].receiver:

function _swap(uint[] memory amounts, route[] memory routes, address _to) internal virtual {
        for (uint i = 0; i < routes.length; i++) {
            if(routes[i].concentrated){
                if (IERC20(routes[i].from).allowance(address(this), swapRouter) < amounts[i]) {
                    IERC20(routes[i].from).approve(swapRouter, amounts[i]);
                }
                ISwapRouter.ExactInputSingleParams memory inputParams;
                inputParams = ISwapRouter.ExactInputSingleParams ({
                    tokenIn: routes[i].from,
                    tokenOut: routes[i].to,
                    deployer: IAlgebraPoolAPIStorage(algebraPoolAPIStorage).pairToDeployer(routes[i].pair),
                    recipient: routes[i].receiver,
                    deadline: block.timestamp + 600,
                    amountIn: amounts[i],
                    amountOutMinimum: 0,
                    limitSqrtPrice: 0
                });

                amounts[i+1] = ISwapRouter(swapRouter).exactInputSingle(inputParams);
            }
            else{
                (address token0,) = sortTokens(routes[i].from, routes[i].to);
                uint amountOut = amounts[i + 1];
                (uint amount0Out, uint amount1Out) = routes[i].from == token0 ? (uint(0), amountOut) : (amountOut, uint(0));
                IBaseV1Pair(pairFor(routes[i].from, routes[i].to, routes[i].stable)).swap(
                    amount0Out, amount1Out, routes[i].receiver, new bytes(0)
                );
            }

            emit Swap(msg.sender, amounts[i], routes[i].from, routes[i].receiver, routes[i].stable);
        }
    }

This results in 100% loss of user funds as all swapped tokens are sent to address(0) and permanently burned. Every swap transaction through these functions will fail to deliver tokens to users.

Note: The API helper does correctly set receiver addresses in its _createRoute function:

 function _createRoute(address pair, address from, address to, bool isBasic, uint amountOut, address _receiver, uint160 sqrtPriceAfter) internal view returns (route memory) {
        return route({
            pair: pair,
            from: from,
            to: to,
            stable: isBasic ? IPair(pair).isStable() : false,
            concentrated: !isBasic,
            amountOut: amountOut,
            receiver: _receiver,
            sqrtPriceAfter: sqrtPriceAfter
        });

However, this only applies to routes created through the API layer, not direct router calls by users.

Recommended mitigation steps

The fix is to properly set receiver addresses for multi-hop routing.

Blackhole mitigated

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


The original report as published on Code4rena, by 0x15. 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 route struct's receiver field is never populated in the swap functions, and the _swap function uses that field instead of the _to parameter, so tokens are sent to address(0).

Impact

All swapped tokens are permanently burned, causing 100% loss of user funds for every swap through these functions.

What the attacker needed

Direct router call; user builds route without receiver

The fix

The receiver address should be properly set for multi-hop routing, and the mitigation was confirmed.

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 lets people swap one token for another. The code that decides where the swapped tokens go was left blank, so the tokens were sent to a special address that nobody controls, which destroys them. Anyone using the swap lost their 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 0x15

View all

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