Closed code423n4 closed 1 year ago
kirk-baird marked the issue as duplicate of #42
kirk-baird changed the severity to QA (Quality Assurance)
This previously downgraded issue has been upgraded by kirk-baird
kirk-baird marked the issue as satisfactory
kirk-baird changed the severity to 2 (Med Risk)
Lines of code
https://github.com/rabbitholegg/quest-protocol/blob/8c4c1f71221570b14a0479c216583342bd652d8d/contracts/Erc1155Quest.sol#L56-L62
Vulnerability details
Impact
The
withdrawRemainingTokens()
function in theErc1155Quest
contract does not consider the amount of unclaimed tokens. When the owner calls the function when the quest has ended, all tokens belonging to the contract will be withdrawn. Any user who has not yet used their receipt to claim their token(s) will no longer be able to claim them since all tokens has been withdrawn by the owner, leaving their receipts useless.Proof of Concept
The following test can be added in
quest-protocol/test/Erc1155Quest.spec.ts
to theclaim()
group (https://github.com/rabbitholegg/quest-protocol/blob/8c4c1f71221570b14a0479c216583342bd652d8d/test/Erc1155Quest.spec.ts#L199)The command
yarn hardhat test --grep "leaves no tokens behind"
can be used to run the testRecommended Mitigation Steps
Note that the
Erc20Quest
contract considers the unclaimed token amount and ensures this amount will be kept in the contract to allow users to claim their tokens even afterwithdrawRemainingTokens()
has been called, as can be seen on lines 84-86 inErc20Quest
(https://github.com/rabbitholegg/quest-protocol/blob/8c4c1f71221570b14a0479c216583342bd652d8d/contracts/Erc20Quest.sol#L84-L86)A similiar calculation should be introduced to
withdrawRemainingTokens()
in theErc1155Quest
contract.