Skip to content
Business logic Audit finding Intermediate

_depositToBentoBox sometimes uses both ETH and WETH

The TridentRouter contract's deposit function only uses the contract's ETH balance if it is at least the required underlying amount; otherwise it ignores the ETH and pulls WETH from the user. If the required amount increases between transaction submission and inclusion, the user's ETH is ignored and WETH is also taken, causing loss of the ETH deposit.

cmichel Follow

Originally disclosed on Code4rena

Submitted by cmichel, also found by 0xRajeev

The TridentRouter._depositToBentoBox function only uses the ETH in the contract if it’s higher then the desired underlyingAmount (address(this).balance >= underlyingAmount)).

Otherwise, the ETH is ignored and the function uses WETH from the user.

Impact

Note that the underlyingAmount = bento.toAmount(wETH, amount, true) is computed from the Bento share price and it might happen that it increases from the time the transaction was submitted to the time the transaction is included in a block. In that case, it might completely ignore the sent ETH balance from the user and in addition transfer the same amount of WETH from the user.

The user can lose their ETH deposit in the contract.

Recommended Mitigation Steps

Each batch must use refundETH at the end.

Furthermore, we recommend still depositing address(this).balance ETH into Bento and if it’s less than underlyingAmount use WETH only for the remaining token difference.

maxsam4 (Sushi) acknowledged

The original report as published on Code4rena, by cmichel. 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 function only uses the contract's ETH balance if it is greater than or equal to the required amount, otherwise it ignores the ETH and uses WETH from the user, without accounting for the ETH already sent.

Impact

A user could lose their ETH deposit because it is ignored and WETH is also taken, especially if the required amount increases before the transaction is included.

What the attacker needed

User sends ETH with transaction; required amount increases before inclusion

The fix

Each batch should call `refundETH` at the end, and the function should deposit the contract's ETH balance and only use WETH for any remaining difference.

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.

This is a smart contract bug where a function that is supposed to use the ETH you send with a transaction sometimes ignores that ETH and instead takes WETH (a token version of ETH) from your wallet. If the amount needed changes before your transaction is processed, you could lose the ETH you sent and also have WETH taken, effectively paying twice.

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 cmichel

View all

196 more disclosed reports, best first.

More from Sushi Trident contest phase 1

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.