Always increasing gas cost of the getOwnedTokenIdsOfQuest function #466
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
downgraded by judge
Judge downgraded the risk level of this issue
duplicate-552
satisfactory
satisfies C4 submission criteria; eligible for awards
Lines of code
https://github.com/rabbitholegg/quest-protocol/blob/8c4c1f71221570b14a0479c216583342bd652d8d/contracts/RabbitHoleReceipt.sol#L106-L135
https://github.com/rabbitholegg/quest-protocol/blob/8c4c1f71221570b14a0479c216583342bd652d8d/contracts/RabbitHoleReceipt.sol#L95-L104
Vulnerability details
Impact
If the user often participates in quests, buys tokens he accumulates tokens that remain on his account. This leads to huge transactions cost after a while.
Proof of Concept
When user want to claim rewards Quest contract calls
getOwnedTokenIdsOfQuest
which iterates over all tokens which user has. All iteration cost a gas, so after a while user will have a lot of outdated tokens, but the algorithm still will be iterates over them.And this function calls from Quest's
claim()
transaction, thereforegetOwnedTokenIdsOfQuest
may use enormous gas amount.Tools Used
Manual Audit
Recommended Mitigation Steps
In Quest contract when calling claim function, each claimed token must be burned.
The text was updated successfully, but these errors were encountered: