The _whiteListCollection
function in the smart contract contains an unbounded loop that iterates over the entire _collections
array. This design could lead to excessive gas consumption or even function failure due to block gas limits, especially as the number of whitelisted collections grows.
The vulnerable code is located in the _whiteListCollection
function:
The function iterates through the entire _collections array to check if the collection already exists before adding it. As the number of collections grows, this operation becomes increasingly expensive in terms of gas consumption.
Gas Limit Exceeded: For a large number of collections, the function may exceed the block gas limit, preventing any further additions to the whitelist.
Denial of Service: The contract could become unusable for whitelist management operations if the gas cost becomes prohibitively high.
Increased Costs: Even when successful, the operation becomes increasingly expensive for users as the list grows.
Manual code review
Use OpenZeppelin's EnumerableSet library: OpenZeppelin provides an efficient implementation for enumerable sets, which is ideal for this use case. Replace the current implementation with EnumerableSet.AddressSet. This will provide efficient add, remove, and enumeration operations.
LightChaser: Low-19, Gas-10
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.