Liquid Staking

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

Missing some checks in the `VaultDepositController::_depositToVaults` function which can cause unpredictable behaviour.

Relevant GitHub Links

https://github.com/Cyfrin/2024-09-stakelink/blob/f5824f9ad67058b24a2c08494e51ddd7efdbb90b/contracts/linkStaking/base/VaultControllerStrategy.sol#L172

Summary

No verification of values entered

Vulnerability Details

In the VaultDepositController::_depositToVaults function, there is no validation for the _toDeposit, _minDeposits, and _maxDeposits values. It’s important to ensure these inputs are within reasonable ranges to prevent potentially dangerous behaviour. For example, it makes no sense if _minDeposits is greater than _maxDeposits. It would also be wise to check that _toDeposit and _maxDeposits are not zero to avoid uncontrolled reverts and certain unexpected behaviour:

function _depositToVaults(
uint256 _toDeposit,
uint256 _minDeposits,
uint256 _maxDeposits,
uint64[] memory _vaultIds
) private returns (uint256) {
// @audit Lack of ckecks on many inputs
/// ... The rest of code
}

Impact

several possible impacts:

- Inefficient Execution: If _maxDeposits is 0, the function may enter loops and perform calculations that do not lead to any meaningful outcome, consuming unnecessary gas and increasing transaction costs.

- Dos: Users might experience longer transaction times or failure without clear feedback on why the transaction did not succeed.

- Increased Gas Costs: The additional computation required for operations that ultimately do not execute deposits will result in higher gas fees, which could be avoided with a simple initial.

- Unexpected Behavior leading to potential errors or state inconsistencies.

Tools Used

Manual review.

Recommendations

function _depositToVaults(
uint256 _toDeposit,
uint256 _minDeposits,
uint256 _maxDeposits,
uint64[] memory _vaultIds
) private returns (uint256) {
+ require(_toDeposit > 0, "Deposit amount must be greater than zero");
+ require(_maxDeposits > 0, "Max deposits must be greater than zero");
+ require(_minDeposits <= _maxDeposits, "Min deposits must be <= Max deposits");
/// ... The rest of code
}
Updates

Lead Judging Commences

inallhonesty Lead Judge 12 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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