The constructor accepts an unbounded array of treats and iterates through each element to call the public addTreat() function, which performs storage operations (mapping updates and array pushes) for each treat. Since there's no limit on the input array size and each iteration consumes significant gas through storage operations, passing a large number of treats during deployment could cause the transaction to exceed Ethereum's block gas limit (currently ~30M gas). This would render the contract undeployable and could be exploited as a denial-of-service vector by malicious actors who intentionally provide an oversized array.
The impact is that malicious actors could permanently prevent the SpookyTreats contract from being deployed by providing an excessively large array of treats that exceeds the block gas limit, effectively denying the entire service/protocol from ever launching on-chain.
To create a test
folder and a file named TestTrickOrTreat.t.sol
for your Foundry project, you can follow these steps:
Create the test
folder: Navigate to your project directory and create a test folder.
Create the TestTrickOrTreat.t.sol
file: Inside the test folder, create a file named TestTrickOrTreat.t.sol
.
Add the Foundry test code: Here’s an example of what you might include in your TestTrickOrTreat.t.sol
file:
Manual Review
Mitigate DOS risk by removing constructor's unbounded loop and introducing a size-limited batch addition function for treats
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.