`requestWithdrawal` doesn't estimate accurately the available shares for withdrawals
The requestWithdrawal function incorrectly calculates available shares by including deposit pool funds that have not yet been deposited into EigenLayer, using the current share price. This can lead to over- or under-estimation, potentially blocking withdrawals or causing users to receive fewer funds for their shares.
Source: https://github.com/sherlock-audit/2024-02-rio-network-core-protocol-judging/issues/361
Found by
Audinarey, Aymen0909, Bauer, Bony, Drynooo, cats, deepplus, hash, kennedy1030, monrel, sakshamguruji, zzykxx
Summary
The requestWithdrawal function inaccurately estimates the available shares for withdrawals by including funds stored in the deposit pool into the already deposited EigenLayer shares. This can potentially lead to blocking withdrawals or users receiving less funds for their shares.
Vulnerability Detail
For a user to withdraw funds from the protocol, they must first request a withdrawal using the requestWithdrawal function, which queues the withdrawal in the current epoch by calling withdrawalQueue().queueWithdrawal.
To evaluate the available shares for withdrawal, the function converts the protocol asset balance into shares:
uint256 availableShares = assetRegistry().convertToSharesFromAsset(asset, assetRegistry().getTotalBalanceForAsset(asset));
The issue arises from the getTotalBalanceForAsset function, which returns the sum of the protocol asset funds held, including assets already deposited into EigenLayer and assets still in the deposit pool:
function getTotalBalanceForAsset(
address asset
) public view returns (uint256) {
if (!isSupportedAsset(asset)) revert ASSET_NOT_SUPPORTED(asset);
address depositPool_ = address(depositPool());
if (asset == ETH_ADDRESS) {
return depositPool_.balance + getETHBalanceInEigenLayer();
}
uint256 sharesHeld = getAssetSharesHeld(asset);
uint256 tokensInRio = IERC20(asset).balanceOf(depositPool_);
uint256 tokensInEigenLayer = convertFromSharesToAsset(
getAssetStrategy(asset),
sharesHeld
);
return tokensInRio + tokensInEigenLayer;
}
This causes the calculated availableShares to differ from the actual shares held by the protocol because the assets still in the deposit pool shouldn't be converted to shares with the current share price (shares/asset) as they were not deposited into EigenLayer yet.
Depending on the current shares price, the function might over or under-estimate the available shares in the protocol. This can potentially result in allowing more queued withdrawals than the available shares in the protocol, leading to blocking withdrawals later on or users receiving less funds for their shares.
Impact
The requestWithdrawal function inaccurately estimates the available shares for withdrawals, potentially resulting in blocking withdrawals or users receiving less funds for their shares.
Code Snippet
Tool used
Manual Review
Recommendation
There is no straightforward way to handle this issue as the asset held by the deposit pool can't be converted into shares while they were not deposited into EigenLayer. The code should be reviewed to address this issue.
Discussion
solimander
Duplicate of https://github.com/sherlock-audit/2024-02-rio-network-core-protocol-judging/issues/109
sherlock-admin4
The protocol team fixed this issue in the following PRs/commits: https://github.com/rio-org/rio-sherlock-audit/pull/13
10xhash
The protocol team fixed this issue in the following PRs/commits: rio-org/rio-sherlock-audit#13
Fixed Deposit pool funds are now converted using the share price at the time of rebalance. Fixes duplicates that mention lack of removal of (queued shares of previous epochs) from available shares. Not removing operator exit shares from available shares is considered acceptable for now.
sherlock-admin4
The Lead Senior Watson signed off on the fix.
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 getTotalBalanceForAsset function includes deposit pool assets that have not been deposited into EigenLayer, and these are converted to shares using the current share price, which does not reflect their actual share value.
Impact
This could block withdrawals or cause users to receive less funds for their shares, depending on the current share price.
What the attacker needed
None
The fix
The protocol team fixed this issue by converting deposit pool funds using the share price at the time of rebalance.
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 ask to withdraw from this protocol, it checks how many shares are available. It mistakenly counts money that is sitting in a deposit pool but not yet invested, and converts it to shares at the current rate. This can make the available shares look different from reality, so later withdrawals might get stuck or pay out less.
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.