https://github.com/Cyfrin/2024-07-the-predicter/blob/main/src/ThePredicter.sol#L121
The withdraw() function iterates over the players
array without any gas consumption safeguards. As the length of the players
array increases, the gas required to execute the loop also increases linearly. This can lead to transactions failing due to running out of gas.
The withdraw()
function iterates over the players
array using a for
loop. If the number of players in the players
array is excessively large, this loop can consume a significant amount of gas, potentially exceeding the block gas limit and causing the transaction to fail.
Transactions attempting to call the withdraw()
function may fail if the gas required exceeds the block gas limit. The following POC in foundry demonstrates the exploitation of vulnerabily. This test simulates registering a large number of players to demonstrate how the withdraw
function may run out of gas due to the unbounded iteration over the players
array. The vm.expectRevert()
is used to assert that the transaction will revert, which indicates the potential gas issue caused by the large loop iteration.
Manual Review and Foundry
Impose a maximum limit on the number of players to keep the gas consumption manageable.
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.