The issue is the lack of a maximum length restriction for calldata arrays in batch functions such as batchAddLiquidity, batchRemoveLiquidity, batchRedeemPositionToken, batchRedeemWToken, and batchClaimYield in the AaveDIVAWrapper.sol contract. This omission may result in excessive gas consumption and a potential vector for denial-of-service (DOS) attacks.
contracts/src/AaveDIVAWrapper.sol:batchCreateContingentPool#L113-L115
contracts/src/AaveDIVAWrapper.sol:batchAddLiquidity#L126
contracts/src/AaveDIVAWrapper.sol:batchRemoveLiquidity#L138-L140
contracts/src/AaveDIVAWrapper.sol:batchRedeemPositionToken#L155-L157
contracts/src/AaveDIVAWrapper.sol:batchRedeemWToken#L172-L174
contracts/src/AaveDIVAWrapper.sol:batchApproveCollateralTokenForAave#L202
Each batch function processes multiple operations in a loop, with each iteration consuming gas. If the calldata array is excessively large:
The transaction's total gas usage could exceed the block gas limit, leading to transaction failure or an "out of gas" error.
This may also render the contract unusable in certain scenarios, especially when batch operations are critical for high-throughput use cases.
An attacker could deliberately pass a large calldata array to:
Prolong execution time for the transaction.
Consume a disproportionate amount of gas, potentially exhausting the resources of the network.
Delay the execution of other users' transactions by congesting the network with high gas-consuming operations.
Gas Efficiency and Failure: Unrestricted calldata array lengths can lead to inefficient gas usage and wasted user funds. And Transactions involving oversized calldata arrays are likely to fail.
Security: Large calldata arrays can be exploited to execute DOS attacks, rendering the contract temporarily inaccessible.
Manual Code Review
It is recommended to introduce a maximum batch size and add a constant to define the maximum allowable length for calldata arrays as well as implement length checks in all batch functions to ensure calldata arrays do not exceed the defined limit. For example:
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.