A potential Denial of Service (DoS) vulnerability has been identified in the SpookySwap contract's constructor. The vulnerability stems from unbounded iteration over an input array during contract deployment, which could cause the contract deployment to fail due to exceeding the block gas limit.
The constructor accepts an array of Treat
structs and iterates over them using a for loop:
Each iteration performs multiple storage operations which is gas-intensive:
Updates treatList
mapping
Pushes to treatNames
array
Emits an event
Gas consumption increases linearly with array size.
Contract deployment could fail if the treats
array is too large.
Manual code review
Slither
Aderyn
Foundry
For the solution it might be good to implement a maximum array length check like this:
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.