Open hats-bug-reporter[bot] opened 1 year ago
I think it's better to revert any operations with the vault where totalShares > 0
, but _totalAssets == 0
. It means that the vault has shares that are worth 0. In such apocalyptic scenario where validator's full balance is slashed means that most validators in Ethereum got slashed (if not all?), so don't think it's good idea to deposit to such vault. Even if Ethereum will recover somehow, it's better to create a new vault in such case.
Github username: @milotruck Submission hash (on-chain): 0x811ea4ceb76e6ce6fb7e737e45c7488c327f4a4c16ccf0c9d5d5364b2e482d5a Severity: low
Description:
Bug Description
In
VaultState.sol
, the_convertToShares()
function will revert if_totalAssets
if 0 while there are still shares:VaultState.sol#L225-L236
As seen below,
_convertToShares()
is used to calculate the amount of shares to mint to a user when calling_deposit()
:VaultEnterExit.sol#L167-L168
As such, if the vault's total assets ever becomes 0 while its total shares is non-zero,
_deposit()
will always revert, permanently DOSing future deposits.Such a scenario could occur if a vault has exactly 32 ETH of assets and only 1 validator, and the validator gets slashed with the maximum penalty. For example:
1e9
ETH as the initial security deposit.32 ether - 1e9
ETH into the vault, making both total assets and total shares32e18
.registerValidator()
to stake the 32 ETH and register a validator.32e18
.deposit()
,_convertToShares()
will revert as the denominator is 0.While it is unlikely that a validator's entire stake will be slashed, note that it is technically possible due to the correlation penalty, as stated here:
Impact
If a vault experiences a huge loss and its total assets goes down to 0, deposits will be permanently DOSed forever.
Recommended Mitigation
In
_convertToShares()
, consider returningassets
if_totalAssets
is zero:VaultState.sol#L225-L236