contracts/core/governance/proposals/TimelockController.sol
The executeBatch function within the TimelockController contract is responsible for executing a batch of scheduled operation, making calls to target addresses passed in as an array, each call is executed one at a time within a for loop, in a situation where one of the target contracts’ returndata is maliciously set to a large value, it would consume all the gas and cause the remaining call operations to fail since there would not be enough gas to continue the execution.
TimelockController.executeBatch
Recall that when a contract makes a call to another contract, if no gas usage cap is set, it automatically sends 63/64 of the remaining gas to the called contract for it’s operation, the remaining 1/64 is reserved so the calling contract can perform any cleanups once control is handed back (e.g event emission) so in a case where the malicious contract uses up all the gas and returns a large returndata that would require more that the remaining 1/64 reserved gas, the overall transaction would continue to fail with an OOG error.
Sample code
If you use Foundry, you can run the debugger in one line:
forge debug --optimize --optimizer-runs 200 --use 0.8.19 --via-ir ReturnBombExample.sol --target-contract Victim --sig "oops()" --debug
Batch executions can be reverted due to OOG errors leading to waste of gas
Manual Review
In this case there the returndata value isn’t used anywhere else in the function, it can be completely removed without introducing any other side effect while completely eliminating the attack surface
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.