Skip to content
Business logic Audit finding Intermediate

Lack of deadline for uniswap AMM

The Uniswap swap call in the Reth derivative lacks a deadline parameter, so a transaction can be held by a validator and executed later when market conditions cause maximum slippage. An attacker could front-run or delay the swap to profit at the user's expense.

brgltd Follow with rbserver, 0xepley and 11 others

Originally disclosed on Code4rena

Submitted by brgltd, also found by rbserver, 0xepley, Breeje, BPZ, eyexploit, SadBase, peanuts, 0xbepresent, ladboy233, Polaris_tow, SaeedAlipoor01988, latt1ce, and 0xnev

https://github.com/code-423n4/2023-03-asymmetry/blob/main/contracts/SafEth/derivatives/Reth.sol#L83-L102

Proof of Concept

The ISwapRouter.exactInputSingle params (used in the rocketpool derivative) does not include a deadline currently.

ISwapRouter.ExactInputSingleParams memory params = ISwapRouter
    .ExactInputSingleParams({
        tokenIn: _tokenIn,
        tokenOut: _tokenOut,
        fee: _poolFee,
        recipient: address(this),
        amountIn: _amountIn,
        amountOutMinimum: _minOut,
        sqrtPriceLimitX96: 0
    });

https://github.com/code-423n4/2023-03-asymmetry/blob/main/contracts/SafEth/derivatives/Reth.sol#L83-L102

The following scenario can happen:

  1. User is staking and some/all the weight is in Reth.
  2. The pool can’t deposit eth, so uniswap will be used to convert eth to weth.
  3. A validator holds the tx until it becomes advantageous due to some market condition (e.g. slippage or running his tx before and frontrun the original user stake).
  4. This could potentially happen to a large amount of stakes, due to widespread usage of bots and MEV.

Impact

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

Due to the removal of the check, it may be more profitable for a validator to deny the transaction from being added until the transaction incurs the maximum amount of slippage.

Recommended Mitigation Steps

The Reth.deposit() function should accept a user-input deadline param that should be passed along to Reth.swapExactInputSingleHop() and ISwapRouter.exactInputSingle().

Asymmetry mitigated:

Using swapTo/swapFrom directly from rocketpool.

Status: Not mitigated. Full details in reports from d3e4, adriro, and 0x52 - and also shared below in the Mitigation Review section.


The original report as published on Code4rena, by brgltd. 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

Impact

A validator could delay the swap until it incurs maximum slippage, potentially affecting a large amount of stakes due to widespread bots and MEV.

What the attacker needed

User stakes with Reth weight; pool cannot deposit ETH; validator can delay transactions

The fix

The deposit function should accept a user-supplied deadline and pass it to the swap call; the mitigation was not accepted.

How it was found

  1. A user stakes and some or all weight is in Reth.
  2. The pool cannot deposit ETH, so Uniswap is used to convert ETH to WETH.
  3. A validator holds the transaction until it becomes advantageous due to market conditions.
  4. The validator front-runs the original user stake or delays it to incur maximum slippage.

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 swap tokens on a decentralised exchange, you can set a deadline so the trade fails if it is not processed in time. Here that deadline is missing, so a miner or validator can keep the trade pending and execute it later when the price is worse for you, making a profit 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.

More from Asymmetry Finance afETH Invitational

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.