Renzo - Tigerfrake's results

A protocol that abstracts all staking complexity from the end-user and enables easy collaboration with EigenLayer node operators and a Validated Services (AVSs).

General Information

Platform: Code4rena

Start Date: 30/04/2024

Pot Size: $112,500 USDC

Total HM: 22

Participants: 122

Period: 8 days

Judge: alcueca

Total Solo HM: 1

Id: 372

League: ETH

Renzo

Findings Distribution

Researcher Performance

Rank: 83/122

Findings: 1

Award: $1.48

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

1.479 USDC - $1.48

Labels

bug
2 (Med Risk)
satisfactory
sufficient quality report
edited-by-warden
:robot:_19_group
duplicate-484

External Links

Lines of code

https://github.com/code-423n4/2024-04-renzo/blob/main/contracts%2FRestakeManager.sol#L491-L576

Vulnerability details

Impact

Missing slippage protection on deposit() and depositETH() functions in RestakeManager contract will leave users vulnerable to sandwich attacks by MEV bots, causing loss of funds to the user on minting.

Proof of Concept

These two functions allow user to deposit ERC20 or ETH collateral respectively into the protocol and mint ezETH in return.

deposit()

function deposit(IERC20 _collateralToken, uint256 _amount) external {
    // Transfer collateral token to this contract
    _collateralToken.safeTransferFrom(msg.sender, address(this), _amount);

    // Calculate ezETH to mint based on the value of the deposit
    uint256 ezETHToMint = renzoOracle.calculateMintAmount(
        totalTVL,
        collateralTokenValue,
        ezETH.totalSupply()
    );

    // Mint ezETH to the depositor
    ezETH.mint(msg.sender, ezETHToMint);
}

depositETH()

function depositETH() external payable {
    // Calculate ezETH to mint based on the value of the ETH deposit
    uint256 ezETHToMint = renzoOracle.calculateMintAmount(
        totalTVL,
        msg.value,
        ezETH.totalSupply()
    );

    // Mint ezETH to the depositor
    ezETH.mint(msg.sender, ezETHToMint);
}

This functionality is same as a swap where users deposit foreign tokens for protocol's native tokens. Not setting a minAmountOut in functions like deposit() or depositETH() can result in losses for users due to slippage or unfavorable changes in the exchange rate between the time of transaction initiation and execution.

Scenario

  • Consider a user who deposits 100 tokens into the protocol, expecting to receive 50 ezETH based on the current exchange rate.
  • Without a minAmountOut, if the exchange rate changes unfavorably during the transaction, the user might end up receiving only 40 ezETH for the same 100 tokens.
  • This results in a 20% loss compared to the expected amount due to the absence of a safeguard against slippage.

In contrast, if a minAmountOut of 45 ezETH was set, the transaction would fail instead of executing with a lower amount, protecting the user from receiving less than the minimum expected amount of ezETH.

Tools Used

Manual Review.

It is recommended to implement slippage protection by requiring users to provide an minAmountOut parameter when calling these functions.

This parameter ensures that the transaction is executed only if the resulting amount meets the user's specified minimum threshold, protecting them from potential losses due to price manipulation.

Allow a user to provide minAmountOut parameter in deposit() and depositETH() functions.

Assessed type

Other

#0 - c4-judge

2024-05-17T13:28:49Z

alcueca marked the issue as satisfactory

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