getUserMemorabiliaDetailed Will Inevitably Lead to Denial of ServiceThe function getUserMemorabiliaDetailed is designed to return all memorabilia NFTs owned by a user. It does this by iterating through every possible collectionId and itemId to check the user's balance for each potential tokenId.
As the number of collections and minted memorabilia increases, the gas cost required to execute these nested loops will grow without limit.
Likelihood:
When the gas cost will exceed the block gas limit, causing the transaction to revert every time it is called.
Impact:
Eventually, the gas cost will exceed the block gas limit, causing the transaction to revert every time it is called. At this point, the function will become permanently unusable for all users, including those with only a few memorabilia, effectively creating a permanent Denial of Service (DoS) for a core feature of the contract.
(Conceptual) The organizer creates 100 memorabilia collections via createMemorabiliaCollection. nextCollectionId is now 200.
Users redeem 500 items from each of these 100 collections. collections[cId].currentItemId is now ~501 for each collection.
A user who owns several memorabilia calls getUserMemorabiliaDetailed.
The outer loop runs from cId = 1 to 199. The inner loop runs from iId = 1 to ~500.
It is recommended to remove the getUserMemorabiliaDetailed function entirely.
The best practice is to handle this functionality off-chain:
Emit Detailed Events: Ensure that the MemorabiliaRedeemed event contains all necessary information (user, tokenId, collectionId, itemId) and that these fields are indexed.
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.