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

When quest is paused, RabbitHole receipt can still be traded and transferred to others #446

Open
code423n4 opened this issue Jan 30, 2023 · 5 comments
Labels
bug Something isn't working downgraded by judge Judge downgraded the risk level of this issue grade-a QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax sponsor acknowledged Technically the issue is correct, but we're not going to resolve it for XYZ reasons

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/rabbitholegg/quest-protocol/blob/main/contracts/Quest.sol#L96-L118

Vulnerability details

Impact

When the quest is paused, the minted RabbitHole receipt can still be traded and transferred from its holder to another user. If a user wants to exchange some tokens to the reward tokens of the quest, and the price for purchasing the receipt is better than the rates offered by other exchanges, she or he would purchase the receipt from the holder. However, since the quest is paused at that moment, calling the following claim function for this purchased receipt will revert with the QuestPaused custom error. Although the quest can be unpaused later, the buyer fails to receive the associated reward tokens immediately and cannot fulfill the goal for exchanging tokens in a timely manner. Also, when the quest becomes unpaused, the exchange rate offered by the quest can become worse than these offered by other exchanges at that moment.

https://github.com/rabbitholegg/quest-protocol/blob/main/contracts/Quest.sol#L96-L118

    function claim() public virtual onlyQuestActive {
        if (isPaused) revert QuestPaused();

        ...
    }

Proof of Concept

Please append the following test in the claim() describe block in quest-protocol\test\Erc20Quest.spec.ts. This test will pass to demonstrate the described scenario.

    it.only('RabbitHole receipt can still be traded and transferred to others when quest is paused', async () => {
      // firstAddress mints a RabbitHole receipt
      await deployedFactoryContract.connect(firstAddress).mintReceipt(questId, messageHash, signature)
      await deployedQuestContract.start()

      await ethers.provider.send('evm_increaseTime', [10000])

      // quest becomes paused
      await deployedQuestContract.pause()

      // firstAddress can still trade and transfer its RabbitHole receipt to secondAddress
      await deployedRabbitholeReceiptContract.connect(firstAddress)['safeTransferFrom(address,address,uint256)'](firstAddress.address, secondAddress.address, 1)

      // yet, secondAddress is unable to claim any rewards associated with this RabbitHole receipt immediately
      await expect(deployedQuestContract.connect(secondAddress).claim()).to.be.revertedWithCustomError(questContract, 'QuestPaused')

      await ethers.provider.send('evm_increaseTime', [-10000])
    })

Tools Used

VSCode

Recommended Mitigation Steps

When the quest is paused, the transfer functionality of the minted RabbitHole receipts can be paused as well.

@code423n4 code423n4 added 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 labels Jan 30, 2023
code423n4 added a commit that referenced this issue Jan 30, 2023
@c4-judge
Copy link
Contributor

c4-judge commented Feb 6, 2023

kirk-baird changed the severity to QA (Quality Assurance)

@c4-judge c4-judge added downgraded by judge Judge downgraded the risk level of this issue QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax and removed 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value labels Feb 6, 2023
@c4-sponsor
Copy link

waynehoover marked the issue as sponsor acknowledged

@c4-sponsor c4-sponsor added the sponsor acknowledged Technically the issue is correct, but we're not going to resolve it for XYZ reasons label Feb 7, 2023
@c4-judge
Copy link
Contributor

kirk-baird marked the issue as grade-a

@c4-judge
Copy link
Contributor

kirk-baird marked the issue as grade-b

@c4-judge c4-judge added grade-b and removed grade-a labels Feb 14, 2023
@c4-judge
Copy link
Contributor

kirk-baird marked the issue as grade-a

@c4-judge c4-judge added grade-a and removed grade-b labels Feb 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working downgraded by judge Judge downgraded the risk level of this issue grade-a QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax sponsor acknowledged Technically the issue is correct, but we're not going to resolve it for XYZ reasons
Projects
None yet
Development

No branches or pull requests

3 participants