Erc1155Quest.withdrawRemainingTokens() will unexpectedly withdraw unclaimed rewards of participants #318
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-528
satisfactory
satisfies C4 submission criteria; eligible for awards
Lines of code
https://github.com/rabbitholegg/quest-protocol/blob/8c4c1f71221570b14a0479c216583342bd652d8d/contracts/Erc1155Quest.sol#L54-L63
Vulnerability details
Participants will not be able to claim their rewards after the quest owner calls Erc1155Quest.withdrawRemainingTokens(), which will withdraw all remaining tokens including unclaimed ones. This is different from Erc20Quest, which will retain any unclaimed rewards even after withdrawRemainingTokens() is called.
This behaviour is also different from the claim process documentation at https://user-images.githubusercontent.com/14314818/214354756-0af7e34d-746e-4429-8b55-8eb6d8bb1e31.png
Proof of Concept
Suppose the ERC1155 quest has ended and the quest owner calls withdrawRemainingTokens() to transfer out all the remaining tokens in the contract. Now, participants who still has unredeemed RH receipts will not be able to claim their rewards from the contract as the balance is zero.
https://github.com/rabbitholegg/quest-protocol/blob/8c4c1f71221570b14a0479c216583342bd652d8d/contracts/Erc1155Quest.sol#L54-L63
Recommended Mitigation Steps
Rectify the withdrawRemainingTokens() to only withdraw non-claimable rewards (based on proportion of unminted RH receipts), while leaving the unclaimed rewards in the contract.
The text was updated successfully, but these errors were encountered: