No deadline parameter in sellAllAmount() and buyAllAmount() functions:
The sellAllAmount() and buyAllAmount() functions lack a deadline parameter, so a transaction can remain pending and be executed later at an outdated price. An attacker could exploit this by sandwiching the stale transaction, causing the user to receive a worse trade.
Submitted by nirlin, also found by sayan.
There is no deadline parameter in these two functions. This missing feature enables pending transactions to be maliciously executed at a later point.
Proof of Concept
Consider following scnerio:
- Alice wants to create order of 1000DAI for 1 ETH . She signs the transaction with
minOutputAmount = 0.99 ETHto allow for some slippage. - The transaction is submitted to the mempool; however, Alice chose a transaction fee that is too low for miners to be interested in including her transaction in a block. The transaction stays pending in the mempool for extended periods, which could be hours, days, weeks, or even longer.
- The average gas fee dropped far enough for Alice’s transaction to become interesting again for miners to include it. In the meantime, the price of ETH could have drastically changed. She will still at least get 0.99 ETH due to
minOutputAmount, but the DAI value of that output might be significantly lower. She has unknowingly performed a bad trade due to the pending transaction she forgot about.
An even worse way this issue can be maliciously exploited is through MEV:
- The swap transaction is still pending in the mempool. Average fees are still too high for miners to be interested in it. The price of
___has gone up significantly since the transaction was signed (lets say its not dai now and some other token), meaning Alice would receive a lot more ETH when the swap is executed. But that also means that herminOutputAmountvalue is outdated and would allow for significant slippage. - A MEV bot detects the pending transaction. Since the outdated
minOutputAmountnow allows for high slippage, the bot sandwiches Alice, resulting in significant profit for the bot and significant loss for Alice.
Recommended Mitigation Steps
Add deadline param
bghughes (Rubicon) disputed, disagreed with severity and commented:
In my opinion, this is a good recommendation but is OOS. Due to MEV argument - seems network-level to me - nice enhancement idea though.
Ignoring the MEV argument since we’re dealing with L2s.
I think the first portion has some merit. Reference here.
Because front-running is a key aspect of AMM design, deadline is a useful tool to ensure that your tx cannot be “saved for later”.
While both Arbitrum & Optimism has minimum gas prices, network congestion could mean that the tx doesn’t get mined until they go back down (eg. trading during Arb airdrop).
It’s again a user-conditional error, which, following the reasoning in #1298, would be medium severity.
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 functions do not include a deadline parameter, allowing transactions to be executed at any later time.
Impact
A user could unknowingly perform a bad trade due to a pending transaction, and a MEV bot could sandwich the transaction for profit, though the judge noted the MEV argument is less relevant on L2s.
What the attacker needed
User submits a transaction with low fee; transaction remains pending; price changes significantly
The fix
Add a deadline parameter to the functions.
How it was found
- Alice creates an order with a minimum output amount to allow for slippage.
- The transaction stays pending in the mempool due to low fees.
- The gas fee drops and the transaction becomes interesting to miners.
- The price changes, and Alice's transaction executes at an outdated minimum output, resulting in a bad trade.
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 a cryptocurrency trade, it waits in a queue called the mempool before being processed. If it waits too long, the price can change, and someone else can take advantage of your old price to make a profit at your expense. A deadline parameter would cancel the trade if it is not processed in time.
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.