Skip to content
Business logic Audit finding Beginner

Accumulated ETH in the LamboVEthRouter will be irretrievable

The LamboVEthRouter contract accumulates small amounts of ETH from user transactions because it refunds excess ETH minus one wei and has no way to withdraw the leftover funds. Over time, these tiny amounts add up and become permanently stuck in the contract, causing a loss of funds.

inh3l Follow with 0xLasadie, aua_oo7 and 17 others

Originally disclosed on Code4rena

Submitted by inh3l, also found by 0xLasadie, aua_oo7, bareli, bumbleb33, Daniel526, Daniel526, eta, Evo, gajiknownnothing, inh3l, Ryonen, Le_Rems, m4k2, mansa11, MrMatrix, phenom80, saikumar279, Shubham, and Vagabond

https://github.com/code-423n4/2024-12-lambowin/blob/874fafc7b27042c59bdd765073f5e412a3b79192/src/LamboVEthRouter.sol#L179-L183

https://github.com/code-423n4/2024-12-lambowin/blob/874fafc7b27042c59bdd765073f5e412a3b79192/src/LamboVEthRouter.sol#L188

Over time, ETH will be accumulated in the LamboVEthRouter and it will be irretrievable leading to loss of funds.

Proof of Concept

First, LamboVEthRouter.sol has a receive function that allows users to send ETH to the contract.

>>      receive() external payable {}

Also, in the _buyQuote function, there is a check for if the msg.value is greater than the amountXIn + fee + 1. If it is, it will refund the user the excess ETH minus 1 wei.

    function _buyQuote(address quoteToken, uint256 amountXIn, uint256 minReturn) internal returns (uint256 amountYOut) {
        require(msg.value >= amountXIn, "Insufficient msg.value");
//...

>>       if (msg.value > (amountXIn + fee + 1)) {
            (bool success, ) = payable(msg.sender).call{value: msg.value - amountXIn - fee - 1}("");
            require(success, "ETH transfer failed");
        }

        emit BuyQuote(quoteToken, amountXIn, amountYOut);
    }

Over time, with the amount of transactions that will be processed, the accumulated 1 weis including any other excess ETH will all add up to a significant amount. Also, as ETH price increases, these small costs can eventually become quite substantial. But there’s no way to sweep the tokens out of the contract. Hence loss of funds for both users and the protocol.

Recommended mitigation steps

Include a sweep function in the contract, or refund actual excess amount to the users.

Shaneson (Lambo.win) acknowledged


The original report as published on Code4rena, by inh3l. 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 contract refunds excess ETH minus one wei and lacks a function to withdraw accumulated ETH, so small amounts become permanently locked.

Impact

Over time, the accumulated wei and any excess ETH sent directly to the contract could add up to a significant amount, and since there is no way to retrieve them, both users and the protocol lose funds.

What the attacker needed

Users send ETH to the contract; contract processes buy transactions

The fix

The contract should include a sweep function to withdraw accumulated ETH, or refund the exact excess amount to users.

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 you send more money (ETH) to a contract than needed, the contract usually sends back the extra. Here, the contract keeps one tiny unit (a wei) each time and also holds any ETH sent directly to it. Since there is no function to withdraw these leftovers, the money is stuck forever.

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 inh3l

View all

2 more disclosed reports, best first.

More from Lambo.win

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.