Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RabbitHole receipts can be minted after the quest has ended #525

Closed
code423n4 opened this issue Jan 30, 2023 · 3 comments
Closed

RabbitHole receipts can be minted after the quest has ended #525

code423n4 opened this issue Jan 30, 2023 · 3 comments
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

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/rabbitholegg/quest-protocol/blob/8c4c1f71221570b14a0479c216583342bd652d8d/contracts/QuestFactory.sol#L219-L229

Vulnerability details

Impact

The function mintReceipt has no check that block.timestamp < quest endTime. So, it is possible to mint receipts after the quest has ended which can lead to loss of assets. If the owner of the quest contract withdraws the remaining tokens immediately after the end of the quest, assets can be lost by users, who did not claim rewards, or the protocol.

Proof of Concept

Several scenarios are possible:

  1. The quest has ended (but quest.numberMinted < quest.totalParticipants), all users claimed rewards (unclaimedTokens = 0), protocol withdrawn fees, owner withdrawn remaining tokens. Contract balance = 0.
    User mints Receipt and can not claim rewards because there are no tokens left on quest contract balance.
  2. The quest has ended (but quest.numberMinted < quest.totalParticipants), not all users claimed rewards, protocol withdrawn fees, owner withdrawn remaining tokens.
    User mints Receipt and claim rewards but one of the users who has not yet claimed a reward will not be able to receive a reward because there are not enough tokens.
  3. The quest has ended (but quest.numberMinted < quest.totalParticipants), all users claimed rewards (unclaimedTokens = 0), protocol did not withdraw fees, owner withdrawn remaining tokens.
    User mints Receipt and claim rewards but protocol will not be able to receive fees because there are not enough tokens.

Tools Used

Manual review.

Recommended Mitigation Steps

Restrict the ability to mintReceipt when block.timestamp > quest.endTime.

@code423n4 code423n4 added 3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working labels Jan 30, 2023
code423n4 added a commit that referenced this issue Jan 30, 2023
@c4-judge c4-judge closed this as completed Feb 6, 2023
@c4-judge
Copy link
Contributor

c4-judge commented Feb 6, 2023

kirk-baird marked the issue as duplicate of #22

@c4-judge c4-judge added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value downgraded by judge Judge downgraded the risk level of this issue and removed 3 (High Risk) Assets can be stolen/lost/compromised directly labels Feb 14, 2023
@c4-judge
Copy link
Contributor

kirk-baird changed the severity to 2 (Med Risk)

@c4-judge
Copy link
Contributor

kirk-baird marked the issue as satisfactory

@c4-judge c4-judge added satisfactory satisfies C4 submission criteria; eligible for awards duplicate-601 and removed duplicate-22 labels Feb 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

No branches or pull requests

2 participants