Users can find themselves with valid receipts that are unable to claim due to lack of funds in the quest contract. #88
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-601
satisfactory
satisfies C4 submission criteria; eligible for awards
Lines of code
https://github.com/rabbitholegg/quest-protocol/blob/8c4c1f71221570b14a0479c216583342bd652d8d/contracts/Erc20Quest.sol#L81-L87
https://github.com/rabbitholegg/quest-protocol/blob/8c4c1f71221570b14a0479c216583342bd652d8d/contracts/Erc1155Quest.sol#L54-L63
Vulnerability details
Impact
Users can find themselves with valid receipts that are unable to claim due to lack of funds in the quest contract.
Proof of Concept
The QuestFactory contract does not put into place any checks regarding the timestamp of minting. This means that a user can obtain a signature to mint a receipt (possibly before the
endTime
of a specific quest) and mint it after theendTime
. It is important to note that after theendTime
, the owner of the quest can withdraw unallocated rewards withQuest.withdrawRemainingTokens
. For anERC20Quest
, the amount to leave in the contract is calculated as the protocol fee + the amount of tokens needed to pay all existent unclaimed receipts. For anERC1155Quest
, all funds are withdrawn regardless of status.If a user mints a receipt for a quest after the quest funds have been withdrawn, there won't be enough funds left in the contract for the user to claim their receipt. An example of this is shown below (using foundry):
Tools Used
Vscode, Foundry
Recommended Mitigation Steps
The recommended mitigation for this finding is to check if the
endTime
has passed and revert if it has inQuestFactory.mintReceipt
. An example of this is as follows:Additionally, in
ERC1155Quest
, instead of transferring out the full balance when withdrawing, only the unallocated rewards should be transferred out.The text was updated successfully, but these errors were encountered: