HardhatDeFi
15,000 USDC
View results
Submission Details
Severity: high
Invalid

Gas Limit

Summary

The contract contains batch functions (e.g., batchRegisterCollateralToken, batchCreateContingentPool, batchAddLiquidity) that process arrays of inputs in a loop.

https://github.com/Cyfrin/2025-01-diva/blob/1b6543768c341c2334cdff87b6dd627ee2f62c89/contracts/src/AaveDIVAWrapper.sol#L113

https://github.com/Cyfrin/2025-01-diva/blob/1b6543768c341c2334cdff87b6dd627ee2f62c89/contracts/src/AaveDIVAWrapper.sol#L126

Vulnerability Details

The contract includes several batch functions (e.g., batchRegisterCollateralToken, batchCreateContingentPool, batchAddLiquidity) that process arrays of inputs in a loop. If the input array is too large, the transaction could exceed the Ethereum block gas limit, causing it to fail. This is a common issue in batch operations, as each iteration of the loop consumes additional gas, and large arrays can quickly push the total gas usage beyond the limit.

Impact

If a user submits a batch with too many items, the transaction will fail, resulting in wasted gas fees.

An attacker could intentionally submit large batches to cause transactions to fail, disrupting the normal operation of the contract.

Tools Used

Manual Code Review

Recommendations

Define a maximum batch size constant (MAX_BATCH_SIZE) and enforce it in all batch functions. This prevents transactions from exceeding the gas limit.

uint256 public constant MAX_BATCH_SIZE = 50

Check the length of the input array before processing the batch. If the array exceeds the maximum size, revert the transaction with a clear error message.

require(_collateralTokens.length <= MAX_BATCH_SIZE, "Batch size too large");

Updates

Lead Judging Commences

bube Lead Judge 10 months ago
Submission Judgement Published
Invalidated
Reason: Known issue

Support

FAQs

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

Give us feedback!