DeFiHardhat
12,000 USDC
View results
Submission Details
Severity: low
Invalid

Missing check for the length of the `reserves` in calcLPTokenUnderlying

Summary

It assumes the length of the reserves array is 2, but there is no checking for it.
If the array has a different size, it could cause unexpected behavior or errors.

Vulnerability Details

function calcLPTokenUnderlying(
uint256 lpTokenAmount,
uint256[] calldata reserves, // @audit missing check for the length of reserves
uint256 lpTokenSupply,
bytes calldata
) external pure returns (uint256[] memory underlyingAmounts) {
underlyingAmounts = new uint256[](2);
underlyingAmounts[0] = lpTokenAmount.mulDiv(reserves[0], lpTokenSupply);
underlyingAmounts[1] = lpTokenAmount.mulDiv(reserves[1], lpTokenSupply);
}

Impact

It could cause unexpected behavior or errors.

Tools Used

Manual

Recommendations

Consider add the checking for the length of reserves.

if (reserves.length != 2) revert("Invalid length");

or calculate the underlyingAmounts from reserves length like this.

underlyingAmounts = new uint256[](reserves.length);
for (uint256 i; i < reserves.length; ++i) {
underlyingAmounts[i] = lpTokenAmount.mulDiv(reserves[i], lpTokenSupply);
}
Updates

Lead Judging Commences

giovannidisiena Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Design choice
Assigned finding tags:

Informational/Invalid

Support

FAQs

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