Erc1155Quest.sol: withdrawRemainingTokens function withdraws unclaimed rewards #47
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
Impact
The
Erc1155Quest.withdrawRemainingTokens
function is used to withdraw the remaining funds from the contract after the quest has ended (https://github.com/rabbitholegg/quest-protocol/blob/8c4c1f71221570b14a0479c216583342bd652d8d/contracts/Erc1155Quest.sol#L54-L63).It is intended that users that have a valid receipt can claim their reward even after the quest has ended. This was confirmed by the sponsor.
The issue is that the
Erc1155Quest.withdrawRemainingTokens
function withdraws ALL remaining tokens and does not leave unclaimed tokens in the contract. This means that any users that want to claim their token afterErc1155Quest.withdrawRemainingTokens
was called cannot do so anymore because there are no tokens left.You can see in the
Erc20Quest.withdrawRemainingTokens
function (which is implemented correctly) how it should work:https://github.com/rabbitholegg/quest-protocol/blob/8c4c1f71221570b14a0479c216583342bd652d8d/contracts/Erc20Quest.sol#L84-L86
The unclaimed tokens should remain in the contract.
Proof of Concept
Erc1155Quest
contractendTime
is reached and the owner callsErc1155Quest.withdrawRemainingTokens
which transfers all reward tokens to theto
addressTools Used
VSCode
Recommended Mitigation Steps
The
Erc1155Quest.withdrawRemainingTokens
function should make sure thatreceiptRedeemers() - redeemedTokens
tokens remain in the contract.Therefore it also needs to implement the
receiptReedemers()
function which can be the same as in theErc20Quest
contract.The text was updated successfully, but these errors were encountered: