DeFiFoundry
50,000 USDC
View results
Submission Details
Severity: low
Invalid

Unbounded Loops in VaultReader.sol

Summary

The VaultReader.sol contract contains unbounded loops when iterating over user deposits. This could lead to gas exhaustion and denial of service (DoS) attacks.

Vulnerability Details

The getUserDeposits function iterates over all deposits for a given user without any limit. If a user has a large number of deposits, this function could run out of gas

function getUserDeposits(address user) external view returns (Deposit[] memory) {
Deposit[] memory deposits = new Deposit[](userDeposits[user].length);
for (uint256 i = 0; i < userDeposits[user].length; i++) {
deposits[i] = userDeposits[user][i];
}
return deposits;
}

Impact

An attacker could create a large number of deposits, causing the getUserDeposits function to fail and potentially disrupting the protocol's functionality

Tools Used

  • Slither (static analysis tool)

  • Manual code review

Recommendations

Implement pagination or limit the number of deposits that can be retrieved in a single call

function getUserDeposits(address user, uint256 start, uint256 limit) external view returns (Deposit[] memory) {
require(limit <= 100, "Limit too high");
uint256 end = start + limit;
if (end > userDeposits[user].length) {
end = userDeposits[user].length;
}
Deposit[] memory deposits = new Deposit[](end - start);
for (uint256 i = start; i < end; i++) {
deposits[i - start] = userDeposits[user][i];
}
return deposits;
}
Updates

Lead Judging Commences

n0kto Lead Judge 3 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Informational or Gas

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.

n0kto Lead Judge 3 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Informational or Gas

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.

Support

FAQs

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