Quest
: Potential out-of-gas in claim
#497
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
duplicate-552
satisfactory
satisfies C4 submission criteria; eligible for awards
Lines of code
https://github.com/rabbitholegg/quest-protocol/blob/8c4c1f71221570b14a0479c216583342bd652d8d/contracts/Quest.sol#L96-L118
Vulnerability details
Note: I can't seem to edit my submitted QA report, so I am filing this as a Med, but expect it to be downgraded!
Quest#claim
claims all rewards for all owned receipt tokens owned by the caller. It's possible in certain situations for this to exceed the block gas limit, preventing the end user from claiming rewards:Proof of concept
claim()
costs about ~125,000 gas, based on the gas report.claim
could exceed the block gas limit of 30 million if a user owns more than 240 tokens and callsclaim()
.This is probably not very likely, but not out of the realm of possibility, especially since receipts are intended to trade on the secondary market. The likelihood depends in part on the value of the underlying rewards and how many tokens will be issued per quest.
There is a potential workaround: end users can transfer tokens to another wallet to claim less than their full balance at once.
Suggestion:
Add a separate
claim(uint256[] tokenIds)
function that allows the user to claim a specific set of tokens by ID. In the worst case, a user can call this function multiple times to process their tokens in batches.However, be careful to ensure this implementation handles duplicate token IDs in the input array: the existing logic in
claim()
can't be directly applied to a user-provided array of tokens, since it sets tokens claimed after counting them up.The text was updated successfully, but these errors were encountered: