The getUserDeposits function in PerpetualVault.sol iterates over all deposits for a user, which could lead to gas exhaustion if the number of deposits is large.
The function uses EnumerableSet to store user deposits, but it does not limit the number of deposits that can be retrieved in a single call.
If a user has a large number of deposits, the function could run out of gas and revert.
The getUserDeposits function iterates over all deposits for a user using EnumerableSet and returns an array of deposit IDs. The issue arises because the function does not implement pagination or any mechanism to limit the number of deposits retrieved in a single call. If a user has a large number of deposits, the function could consume an excessive amount of gas, potentially leading to gas exhaustion and causing the transaction to revert.
Example Scenario:
A user has made 10,000 deposits into the vault.
When the getUserDeposits function is called, it attempts to iterate over all 10,000 deposits.
The gas cost of iterating over 10,000 deposits exceeds the block gas limit, causing the transaction to revert.
The user is unable to retrieve their deposit information, and the contract becomes unusable for them.
Gas exhaustion could prevent users from retrieving their deposit information.
Manual Review
Add pagination to the getUserDeposits function to limit the number of deposits retrieved in a single call.
Alternatively, use a mapping to store deposit information instead of an EnumerableSet.
Please read the CodeHawks documentation to know which submissions are valid. If you disagree, provide a coded PoC and explain the real likelihood and the detailed impact on the mainnet without any supposition (if, it could, etc) to prove your point.
Please read the CodeHawks documentation to know which submissions are valid. If you disagree, provide a coded PoC and explain the real likelihood and the detailed impact on the mainnet without any supposition (if, it could, etc) to prove your point.
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.