Liquid Staking

Stakelink
DeFiHardhatOracle
50,000 USDC
View results
Submission Details
Severity: medium
Invalid

Potential Underdeposit in VaultControllerStrategy

Summary

Potential Underdeposit in VaultControllerStrategy

Vulnerability Details

In the _depositToVaults function of the VaultControllerStrategy contract, there exists a potential scenario where a vault could end up with less than the minimum required deposits (_minDeposits). This occurs due to an incomplete check before depositing funds into a vault.

The issue arises when all of the following conditions are met:

  • The current deposits in the vault (deposits) are less than the minimum required (_minDeposits).

  • The amount that can be deposited (canDeposit = _maxDeposits - deposits) is less than the difference between the minimum required and current deposits (_minDeposits - deposits).

  • The amount to be deposited (toDeposit) is greater than canDeposit.

if (canDeposit != 0 && vaultIndex != group.withdrawalIndex && !vault.isRemoved()) {
if (deposits < _minDeposits && toDeposit < (_minDeposits - deposits)) {
break;
}
// ... (other code)
if (toDeposit > canDeposit) {
vault.deposit(canDeposit);
toDeposit -= canDeposit;
group.totalDepositRoom -= uint128(canDeposit);
} else {
// ... (other code)
}
}

Impact

Under these conditions, the function will deposit canDeposit amount into the vault. However, this may not be sufficient to reach _minDeposits, leaving the vault underfunded. This could potentially violate the minimum deposit requirements set by the Chainlink staking contract.

Tools Used

vscode

Recommendations

Add an additional check to ensure that the actual deposit amount will bring the vault's total deposits to at least _minDeposits:

if (canDeposit != 0 && vaultIndex != group.withdrawalIndex && !vault.isRemoved()) {
uint256 actualDeposit = MathUpgradeable.min(toDeposit, canDeposit);
if (deposits < _minDeposits && deposits + actualDeposit < _minDeposits) {
break;
}
// ... (rest of the code)
}
Updates

Lead Judging Commences

inallhonesty Lead Judge
about 1 year ago
inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.