Users are susceptible to back-running when depositing ETH to TridenRouter
The router's deposit functions accept ETH but do not use the actual amount deposited, so users must pre-calculate and send extra ETH. If the exchange rate changes before execution, leftover ETH remains in the router and anyone can back-run to claim it via refundETH.
Submitted by broccoli
Impact
The _depositToBentoBox and _depositFromUserToBentoBox allow users to provide ETH to the router, which is later deposited to the bento contract for swapping other assets or providing liquidity. However, in these two functions, the input parameter does not represent the actual amount of ETH to deposit, and users have to calculate the actual amount and send it to the router, causing a back-run vulnerability if there are ETH left after the operation.
Proof of Concept
- A user wants to swap ETH to DAI. He calls
exactInputSingleWithNativeTokenon the router with the corresponding parameters andparams.amountInbeing 10. Before calling the function, he calculatesbento.toAmount(wETH, 10, true) = 15and thus send 15 ETH to the router. - However, at the time when his transaction is executed,
bento.toAmount(wETH, amount, true)becomes to14, which could happen if someone callsharvestonbentoto update theelasticvalue of thewETHtoken. - As a result, only 14 ETH is transferred to the pool, and 1 ETH is left in the router. Anyone could back-run the user’s transaction to retrieve the remaining 1 ETH from the router by calling the
refundETHfunction.
Referenced code: TridentRouter.sol#L318-L351
Recommended Mitigation Steps
Directly push the remaining ETH to the sender to prevent any ETH left in the router.
I think it’s low risk because it’s basically arbitrage and we have protection for the user in terms of “minOutputAmount”. I will be reworking ETH handling to avoid this issue completely.
It’s a loss of funds, not arbitrage. It should be prevented or documented. Sustained.
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 deposit functions do not use the actual ETH amount received and do not refund excess ETH to the sender, leaving funds in the router.
Impact
Users could lose the excess ETH they sent, which an attacker could take; the report notes this is a loss of funds, not arbitrage.
What the attacker needed
User sends extra ETH to the router; exchange rate changes before execution; attacker can back-run the transaction
The fix
The remaining ETH should be directly pushed to the sender to prevent any ETH left in the router.
How it was found
- User calculates the required ETH amount using bento.toAmount and sends that amount to the router.
- Before the user's transaction executes, the exchange rate changes (e.g., due to a harvest call), so less ETH is needed.
- The router deposits only the needed ETH, leaving the excess in the contract.
- An attacker back-runs the user's transaction and calls refundETH to take the leftover ETH.
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 cryptocurrency to a smart contract, you often have to send a bit extra to cover fees or price changes. Here, the contract doesn't automatically return the extra, so it sits in the contract. An attacker can watch for such leftovers and quickly take them for themselves.
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.