sherlock-audit / 2024-02-rio-network-core-protocol-judging

4 stars 4 forks source link

monrel - Epoch is not incremented when withdrawing from EigenLayer #360

Closed sherlock-admin4 closed 8 months ago

sherlock-admin4 commented 8 months ago

monrel

high

Epoch is not incremented when withdrawing from EigenLayer

Summary

The epoch is not incremented when withdrawals happen through EigenLayer, users will lose their assets since they can not complete their withdrawals.

Vulnerability Detail

When we settle through settleCurrentEpoch() we increment currentEpochsByAsset[asset].

https://github.com/sherlock-audit/2024-02-rio-network-core-protocol/blob/4f01e065c1ed346875cf5b05d2b43e0bcdb4c849/rio-sherlock-audit/contracts/restaking/RioLRTWithdrawalQueue.sol#L166

currentEpochsByAsset[asset] += 1;

But If we withdraw from EigenLayer by calling queueWithdrawalFromOperatorsForUserSettlement() we never increment the epoch.

Impact

Rebalance mechanism is broken:

When an epoch withdrawing from eigenlayer it is settled through settleEpochFromEigenLayer(), epochWithdrawals.settled is set to true

https://github.com/sherlock-audit/2024-02-rio-network-core-protocol/blob/4f01e065c1ed346875cf5b05d2b43e0bcdb4c849/rio-sherlock-audit/contracts/restaking/RioLRTWithdrawalQueue.sol#L230

Users will still be able to call requestWithdrawl() even if the current epoch has settled, they will lose their LRT tokens but the epoch is already settled so the funds are stuck.

Code Snippet

https://github.com/sherlock-audit/2024-02-rio-network-core-protocol/blob/4f01e065c1ed346875cf5b05d2b43e0bcdb4c849/rio-sherlock-audit/contracts/restaking/RioLRTWithdrawalQueue.sol#L166

https://github.com/sherlock-audit/2024-02-rio-network-core-protocol/blob/4f01e065c1ed346875cf5b05d2b43e0bcdb4c849/rio-sherlock-audit/contracts/restaking/RioLRTWithdrawalQueue.sol#L230

Tool used

Manual Review

Recommendation

The epoch has to be incremented when we queue it for settlement in _processUserWithdrawalsForCurrentEpoch()

withdrawalQueue_.queueCurrentEpochSettlement(asset, assetsSent, sharesSent, aggregateRoot);

currentEpochsByAsset[asset] += 1;

Duplicate of #4