The Vault.sol contract contains a vulnerability in the _depositLiquidity function where it accesses the _data array without ensuring that its length matches the number of strategies. This oversight can lead to an out-of-bounds array access, causing transaction reverts and potentially disrupting the staking operations.
Assumption Flaw: The function assumes that the _data array provided has a length equal to or greater than the strategies array.
Risk of Reversion: If _data.length < strategies.length, accessing _data[i] for i >= _data.length will result in an out-of-bounds error, causing the transaction to revert.
Potential for Denial of Service: Malformed inputs with insufficient _data can prevent users from successfully depositing or withdrawing funds, leading to operational disruptions.
Code Snippet:
Explanation:
The attacker attempts to deposit 1000 LINK tokens but provides a _data array of length 2, which is shorter than the expected length of the strategies array (assumed to be 3). This triggers an out-of-bounds access when the loop in _depositLiquidity tries to access _data[2].
Code Snippet:
Explanation:
The test anticipates the transaction to revert with the specific error message "Invalid deposit data length". This confirms that the input validation effectively prevents out-of-bounds access.
Code Snippet:
Explanation:
Providing a _data array that matches the length of the strategies array ensures that the deposit function executes successfully without reverting, validating the effectiveness of the input validation.
Operational Disruption: Users may be unable to deposit or withdraw funds if the _data array does not meet the expected length, leading to failed transactions.
Denial of Service (DoS): Attackers can exploit this vulnerability by submitting transactions with intentionally short _data arrays, causing widespread transaction failures.
User Trust Erosion: Frequent transaction failures can diminish user confidence in the platform's reliability and security.
Manual Code Review:
Implement a require statement at the beginning of the _depositLiquidity function to ensure the _data array's length meets the required criteria.
If variability in the _data array's length is intended, adjust the loop to iterate only up to the minimum of strategies.length and _data.length to prevent out-of-bounds access.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.