getUserMemorabiliaDetailed — View Function Exceeds Block Gas LimitFestivalPass.sol
The getUserMemorabiliaDetailed() function is a view function intended to return all memorabilia NFTs owned by a user, along with their collection and item IDs.
The function uses nested loops iterating over all collections × all items (lines 269-276, duplicated at lines 284-294). As the number of collections and items grows, the gas cost scales as O(collections × items). Since nextCollectionId and currentItemId only increase, this function will eventually exceed the block gas limit, rendering it uncallable. Any frontend or dApp relying on this function will break.
Likelihood: Medium
Gas cost grows proportionally with protocol usage. With ~100 collections of ~100 items each, the view function exceeds standard RPC gas limits. Occurs naturally over time.
Impact: Low
View function becomes uncallable — no state changes lost, but UX is degraded. Frontend queries fail, requiring off-chain indexing (subgraph) as a workaround.
Severity: Low
The vulnerability is confirmed through code trace analysis. The function at lines 262-297 contains two passes over all collections and items. With nextCollectionId = N and each collection having M items on average, the function performs 2 × N × M iterations, each involving a balanceOf storage read. At an estimated 2,600 gas per SLOAD, 100 collections × 100 items = 52M gas — far exceeding the 30M block gas limit.
Use an off-chain indexer (subgraph) for enumeration, or maintain a per-user owned-tokens mapping to avoid unbounded iteration.
The contest is live. Earn rewards by submitting a finding.
Submissions are being reviewed by our AI judge. Results will be available in a few minutes.
View all submissionsThe contest is complete and the rewards are being distributed.