Asymmetry contest - roelio'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: 157/246

Findings: 2

Award: $13.27

QA:
grade-b

🌟 Selected for report: 0

🚀 Solo Findings: 0

Lines of code

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

Vulnerability details

Impact

When ETH cannot be directly deposited into the Rocket pool according to https://github.com/code-423n4/2023-03-asymmetry/blob/main/contracts/SafEth/derivatives/Reth.sol#L120 the price will be calculated from the current state of the uniswap pool https://github.com/code-423n4/2023-03-asymmetry/blob/main/contracts/SafEth/derivatives/Reth.sol#L240.

If the balance of the RETH derivative is high enough to trigger the use of the uniswap oracle in https://github.com/code-423n4/2023-03-asymmetry/blob/main/contracts/SafEth/SafEth.sol#L73. The preDepositPrice can be manipulated by skewing the uniswap pool resulting in a higher mintAmount in https://github.com/code-423n4/2023-03-asymmetry/blob/main/contracts/SafEth/SafEth.sol#L98.

Proof of Concept

pre-conditions:

Only RETH as derivative and balance is high enough to make ethPerDerivative use the Uniswap pool in https://github.com/code-423n4/2023-03-asymmetry/blob/main/contracts/SafEth/SafEth.sol#L73

Price of 1.1 ETH per RETH in the Uniswap pool and Rocket pool.

Underlying value of stake pool is 1100 ETH and total supply is 1100.

RETH derivative contains 1000 RETH.

Attack:

Attacker flashloans bunch of RETH and swaps for ETH. Making the price in the Uniswap pool 1 ETH per RETH.

Because the price is determined via uniswap the underlyingvalue of the pool calculated in https://github.com/code-423n4/2023-03-asymmetry/blob/main/contracts/SafEth/SafEth.sol#L73 will be 1000. So the predeposit price will be ~0.909 ETH

The totalStakeValueEth in https://github.com/code-423n4/2023-03-asymmetry/blob/main/contracts/SafEth/SafEth.sol#L92 will be 100 ETH because the price used their is coming from the RocketPool (not uniswap).

The mintAmount will be 110 ETH

Now the uniswap is skewed to its original ratio.

Underlying value of stake pool is 1200 ETH and total supply is 1210.

Now the attacker can withdraw ~109.09 ETH base on the 110 shares.

Tools Used

Notepad

Calculator

Use a TWAP from the Uniswap pool or possible chainlink if available.

Another problem is when the price calculated for the Rocket derivative in https://github.com/code-423n4/2023-03-asymmetry/blob/main/contracts/SafEth/SafEth.sol#L73 could be different w.r.t. https://github.com/code-423n4/2023-03-asymmetry/blob/main/contracts/SafEth/SafEth.sol#L92. In the first calculation it should use the price based on the deposit amount and not the balance of the pool.

#0 - c4-pre-sort

2023-04-04T11:55:18Z

0xSorryNotSorry marked the issue as duplicate of #601

#1 - c4-judge

2023-04-21T16:11:07Z

Picodes marked the issue as duplicate of #1125

#2 - c4-judge

2023-04-21T16:13:41Z

Picodes marked the issue as satisfactory

#3 - c4-judge

2023-04-24T21:46:36Z

Picodes changed the severity to 3 (High Risk)

Overall code is simple and self-explanatory. The codebase is small and to the point. Modern solidity is applied.

Low severity

Wrong price of the lido derivative

Adjusting weights of non-existing derivatives

Slippage should be limited

Owner can hijack funds by adding derivative and adjusting weights.

  • Problem: function https://github.com/code-423n4/2023-03-asymmetry/blob/main/contracts/SafEth/SafEth.sol#L182 allows the owner to add a malicious derivative and could then change weights to move all eth to this contract and steal the funds.

  • Solution: In this case the owner should ideally be behind a timelock, but maybe this is not okay for pausing the staking so potentially add an additional role for immediate actions and put the rest behind timelock.

Overflow in localTotalWeight calculation

#0 - c4-sponsor

2023-04-10T19:15:30Z

elmutt marked the issue as sponsor confirmed

#1 - c4-judge

2023-04-24T18:51:50Z

Picodes marked the issue as grade-b

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