The batch
function in the Batch
contract lacks a limit on the number of batched calls, which can lead to out-of-gas errors during execution. This poses a risk for unexpected transaction failures.
The batch
function allows users to execute multiple function calls in a single transaction via delegatecall
. However, if the calls
array exceeds a certain size, the total gas consumed during execution can exceed the block gas limit or the gas limit set by the user. This results in the entire transaction failing, leading to a poor user experience and potentially leaving the contract in an inconsistent state.
The security guarantee that is broken here is availability. Users may be unable to execute their intended operations if the gas limit is exceeded. A malicious user could exploit this by submitting a batch with an excessive number of calls, causing gas exhaustion intentionally.
Location: The vulnerability exists within the batch
function of the Batch
contract.
Propagation: If a user submits a large number of calls in the calls
array, the function will attempt to process them all without any check on the number of calls. This can lead to an out-of-gas condition, resulting in the transaction reverting without executing any of the calls.
The inability to process a large number of calls in one transaction could lead to failed transactions, causing user frustration and potential loss of funds if the calls involve state changes. The overall user experience would be severely impacted, as they might assume that the function works correctly without understanding the underlying gas constraints.
A user could create a transaction with the following call:
If this transaction is sent, it could exceed the gas limit and cause the transaction to fail.
To mitigate this issue, the contract should implement a maximum limit on the number of calls allowed in a single transaction. For example, limiting the number of calls to 100 ensures that users cannot submit excessively large arrays that could lead to gas exhaustion.
Here's a suggested code snippet to enforce this limit:
src/abstracts/Batch.sol
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.