Less rsETH minted than intended in volatile conditions. due to zero slippage when staking ETH to mint rsETH
The RsETHAdapter contract calls the rsETH deposit pool with a minimum expected amount of zero, so the transaction does not revert if the oracle price moves and fewer rsETH are minted than intended. An attacker could exploit this during volatile conditions to cause the protocol to receive less rsETH, potentially through MEV or sandwich attacks.
Bauchibred Follow with BiasedMerc, Ironsidesec and 2 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2024-05-napier-update-judging/issues/26
The protocol has acknowledged this issue.
Found by
Bauchibred, BiasedMerc, Ironsidesec, merlin, zzykxx
Summary
This issue is not at all related to external admin, but the slippage parameter being zero is the issue. Read the issue flow after below images
Vulnerability Detail
There is a slippage parameter called minRSETHAmountExpected in RSETH_DEPOSIT_POOL.depositETH.
And RsETHAdapter._stake is setting it to 0 when it calls RSETH_DEPOSIT_POOL.depositETH.
Its an issue, look at the sudden waves / bumps of rsETH within seconds, and LRT oracle admin will update the price according to the markets in dexes, or else free arbitrage mints will further cause spiral moves.Or explore the ezETH depeg recently (https://x.com/SudipanSinha/status/1783473266515931284) and LRT x money market impact (https://x.com/SudipanSinha/status/1784107059744792715)
Click yellow button on https://www.dextools.io/app/en/ether/pair-explorer/0x059615ebf32c946aaab3d44491f78e4f8e97e1d3
https://app.uniswap.org/explore/pools/ethereum/0x059615EBf32C946aaab3D44491f78e4F8e97e1D3
Issue flow:
- Rebalancer notices ETH to deposit in Kelp DAO's rsETH.
- call flows to
RsETHAdapter._stake-->RSETH_DEPOSIT_POOL.depositETHwhich will deposit eth to mint rsETH at current price. - Its a volatile time, and many transactions are pending, kelp lrt oracle is updated according to latest dex price which has pumped a lot.
- Then the napier's
_staketransaction goes through, which will mint less rsETH because the price of rsETH went so high - but after few blocks, the price of rsETH again balanced and it dipped to normal, so lrt oracle is updated.
Now, it is a loss to Napier because we minted less tokens at peak price instead of normal current price and they are worth very low in terms of USD or WETH. If we used slippage, then it would have reverted in these cases.
Due to the below reason of price fluctuations, depegs, the slippage should not be set to 0.
And it is under the admin control. But during the times of rebalancing, if depeg happens or in a very volatile sessions, the slippage is necessary. Because the admin might update the latest rsETH/WETH price and we might receive less rsETH as intended.
This can be resulted to MEV or sandwich attacks to 0 slippage. Although rebalancers use private mempool, the price of rsETH will be volatile in big steps wise jumps as shown in images below. And the latest Renzo depeg of ezETH shows that slippage should be implemented, or else its a loss to Napier vaults.
File: 2024-05-napier-update\napier-uups-adapters\src\adapters\kelp\RsETHAdapter.sol
67: function _stake(uint256 stakeAmount) internal override returns (uint256) {
...
81: // Interact
82: IWETH9(Constants.WETH).withdraw(stakeAmount);
83: uint256 _rsETHAmt = RSETH.balanceOf(address(this));
84: >>> RSETH_DEPOSIT_POOL.depositETH{value: stakeAmount}(0, REFERRAL_ID);
85: _rsETHAmt = RSETH.balanceOf(address(this)) - _rsETHAmt;
86:
...
90: }
https://etherscan.io/address/0x13576cd2b61e601d3e98b5c06ef81896c9bbb369#code#F1#L206 Line 206 on https://etherscan.deth.net/address/0x13576cd2b61e601d3e98b5c06ef81896c9bbb369
function depositETH(
>>> uint256 minRSETHAmountExpected,
string calldata referralId
)
external payable whenNotPaused nonReentrant
{
// checks
>>> uint256 rsethAmountToMint = _beforeDeposit(LRTConstants.ETH_TOKEN, msg.value, minRSETHAmountExpected);
// interactions
_mintRsETH(rsethAmountToMint);
emit ETHDeposit(msg.sender, msg.value, rsethAmountToMint, referralId);
}
function _beforeDeposit(
address asset,
uint256 depositAmount,
>>> uint256 minRSETHAmountExpected
)
private view returns (uint256 rsethAmountToMint)
{
... SKIP ...
rsethAmountToMint = getRsETHAmountToMint(asset, depositAmount);
>>> if (rsethAmountToMint < minRSETHAmountExpected) {
revert MinimumAmountToReceiveNotMet();
}
}
function getRsETHAmountToMint(
address asset,
uint256 amount
)
public view override returns (uint256 rsethAmountToMint)
{
// setup oracle contract
address lrtOracleAddress = lrtConfig.getContract(LRTConstants.LRT_ORACLE);
ILRTOracle lrtOracle = ILRTOracle(lrtOracleAddress);
// calculate rseth amount to mint based on asset amount and asset exchange rate
>>> rsethAmountToMint = (amount * lrtOracle.getAssetPrice(asset)) / lrtOracle.rsETHPrice();
}
Impact
Less rsETH was minted than intended in volatile conditions.
Code Snippet
Tool used
Manual Review
Recommendation
- function _stake(uint256 stakeAmount) internal override returns (uint256) {
+ function _stake(uint256 stakeAmount, uint256 minRSETHAmountExpected) internal override returns (uint256) {
... SKIP ...
// Interact
IWETH9(Constants.WETH).withdraw(stakeAmount);
uint256 _rsETHAmt = RSETH.balanceOf(address(this));
- RSETH_DEPOSIT_POOL.depositETH{value: stakeAmount}(0, REFERRAL_ID);
+ RSETH_DEPOSIT_POOL.depositETH{value: stakeAmount}(minRSETHAmountExpected, REFERRAL_ID);
_rsETHAmt = RSETH.balanceOf(address(this)) - _rsETHAmt;
if (_rsETHAmt == 0) revert InvariantViolation();
return stakeAmount;
}
Discussion
sherlock-admin2
1 comment(s) were left on this issue during the judging contest.
PNS commented:
slippage control is (will be) at the Tranche.issue level and not at the adapter level (following issue #84 in the previous contest)
massun-onibakuchi
It makes sense but depegging upward is economically unlikely. some protocols seems to set zero slippage.
TrancheRouter (TrancheRouter calls Tranche) checks how many PT a user should receive
amount of PT issued indirectly depends on rsETH price. so, I think TrancheRouter prevents such unexpected slippage. https://github.com/sherlock-audit/2024-05-napier-update/blob/c31af59c6399182fd04b40530d79d98632d2bfa7/napier-uups-adapters/src/adapters/kelp/RsETHAdapter.sol#L107-L109 https://github.com/sherlock-audit/2024-05-napier-update/blob/c31af59c6399182fd04b40530d79d98632d2bfa7/napier-uups-adapters/src/adapters/BaseLSTAdapterUpgradeable.sol#L87
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
Likely the adapter hardcodes the slippage parameter to zero when calling the deposit function, removing any protection against price changes.
Impact
Less rsETH was minted than intended in volatile conditions, resulting in a loss to Napier vaults; the text notes that rebalancers use a private mempool, which may limit but does not eliminate the risk.
What the attacker needed
Volatile market conditions; rebalancer deposits ETH to mint rsETH
The fix
The adapter should accept a minimum expected rsETH amount and pass it to the deposit function instead of zero.
How it was found
- Rebalancer notices ETH to deposit in Kelp DAO's rsETH.
- Call flows to RsETHAdapter._stake, which calls RSETH_DEPOSIT_POOL.depositETH with zero minimum.
- During a volatile time, the Kelp LRT oracle price is updated to a high value.
- The stake transaction goes through and mints less rsETH because the price is high.
- After a few blocks, the price returns to normal, but the protocol has already received less rsETH.
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 deposit ETH to get rsETH, the amount you receive depends on the current price. The code can set a minimum amount you expect to get back, and if the actual amount is lower, the transaction fails. Here that minimum was set to zero, so the transaction would succeed even if you got much less rsETH than expected.
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.