Asymmetry contest - shuklaayush's results

A protocol to help diversify and decentralize liquid staking derivatives.

General Information

Platform: Code4rena

Start Date: 24/03/2023

Pot Size: $49,200 USDC

Total HM: 20

Participants: 246

Period: 6 days

Judge: Picodes

Total Solo HM: 1

Id: 226

League: ETH

Asymmetry Finance

Findings Distribution

Researcher Performance

Rank: 235/246

Findings: 1

Award: $0.14

🌟 Selected for report: 0

🚀 Solo Findings: 0

Lines of code

https://github.com/code-423n4/2023-03-asymmetry/blob/44b5cd94ebedc187a08884a7f685e950e987261c/contracts/SafEth/derivatives/Reth.sol#L215

Vulnerability details

Impact

RETH derivative uses uniswap v3 spot price which can be manipulated to steal from the pool

Proof of Concept

The ethPerDerivative call in the underlyingValue calculation uses the total amount currently deposited in the liquid staking derivative. https://github.com/code-423n4/2023-03-asymmetry/blob/44b5cd94ebedc187a08884a7f685e950e987261c/contracts/SafEth/SafEth.sol#L73

This means that for RETH, when deposits are high, this would return poolPrice() which is the uniswap v3 spot price. This price can be manipulated https://github.com/code-423n4/2023-03-asymmetry/blob/44b5cd94ebedc187a08884a7f685e950e987261c/contracts/SafEth/derivatives/Reth.sol#L211-L216 https://github.com/code-423n4/2023-03-asymmetry/blob/44b5cd94ebedc187a08884a7f685e950e987261c/contracts/SafEth/derivatives/Reth.sol#L228-L242

  1. Flashloan RETH and crash RETH/ETH uniswap v3 spot price
  2. Stake ETH to get more shares minted (since ethPerDerivative for RETH would be small)
  3. Unstake shares to get more ETH than deserved

Tools Used

Use an oracle for RETH price

#0 - c4-pre-sort

2023-04-04T11:23:28Z

0xSorryNotSorry marked the issue as duplicate of #601

#1 - c4-judge

2023-04-21T16:14:48Z

Picodes marked the issue as satisfactory

#2 - c4-judge

2023-04-21T16:15:28Z

Picodes marked the issue as duplicate of #1125

Lines of code

https://github.com/code-423n4/2023-03-asymmetry/blob/44b5cd94ebedc187a08884a7f685e950e987261c/contracts/SafEth/derivatives/SfrxEth.sol#L74-L75

Vulnerability details

Impact

The frxETH derivative uses price_oracle of the curve pool which can be used to manipulate the slippage limits

Proof of Concept

Background

The price_oracle() in the Curve pool is an exponential moving average that exponentially converges from an old value to the last trade value. This is manipulatable in certain conditions. Someone can write a contract that flash-loans a large amount of token A (comparable to the amount of token A in a pool), swaps it for token B in the pool, swap the token B back to token A and repay the flash-loan. This would mean that the last price would significantly differ from the actual price. If there are no transactions on the pool for a while after this, then the pool's price_oracle() would converge to a value close to this last price and hence, very different from the actual tokenA/tokenB price.

One key point here is that this kind of price manipulation doesn't require too many funds at risk (since the flashloan is paid up). The maximum loss for the exploiter would just be the fee on the flashloan and the two swaps.

An example of this manipulation for Curve v2 pools can be found in this repo https://github.com/shuklaayush/brownie-curve-v2

Vulnerability

  • Do a huge flashloan trade for frxETH/ETH pool to crash the frxETH price. Wait for some time for the price_oracle to converge to the crashed value
  • Any subsequent withdrawal tx will have a low slippage limit for the frxETH -> ETH conversion and can be sandwiched

Tools Used

Use a proper oracle

#0 - c4-pre-sort

2023-04-02T10:31:58Z

0xSorryNotSorry marked the issue as low quality report

#1 - toshiSat

2023-04-10T14:20:37Z

Duplicate

#2 - c4-sponsor

2023-04-10T14:20:39Z

toshiSat marked the issue as sponsor confirmed

#3 - c4-judge

2023-04-20T09:53:54Z

Picodes marked the issue as satisfactory

#4 - c4-judge

2023-04-22T09:39:57Z

Picodes marked the issue as duplicate of #142

#5 - c4-judge

2023-04-24T21:37:58Z

Picodes changed the severity to 3 (High Risk)

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter