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

Receipt owners can cheat on marketplaces claiming before accepting a bid offer #315

Closed
code423n4 opened this issue Jan 29, 2023 · 2 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 duplicate-119 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/RabbitHoleReceipt.sol#L148

Vulnerability details

Impact

Already claimed NFTs can be transfered so owners could cheat on marketplaces (like OpenSea) by accepting a bid offer after having claimed rewards. Those NFTs doesnt need to be transfered as its function is accomplished so its transferability could be limited. In beforeTransfer hook they can check if NFT is already claimed and revert in that case.

Proof of Concept

diff --git a/test/Erc20Quest.spec.ts b/test/Erc20Quest.spec.ts.new2
index d0626ee..794ad33 100644
--- a/test/Erc20Quest.spec.ts
+++ b/test/Erc20Quest.spec.ts.new2
@@ -302,6 +302,20 @@ describe('Erc20Quest', async () => {
       await expect(deployedQuestContract.claim()).to.be.revertedWithCustomError(questContract, 'AlreadyClaimed')
       await ethers.provider.send('evm_increaseTime', [-86400])
     })
+
+    it('allows an owner to accept a marketplace bid order after claim', async () => {
+      await deployedRabbitholeReceiptContract.mint(owner.address, questId)
+      await deployedQuestContract.start()
+
+      await ethers.provider.send('evm_increaseTime', [86400])
+
+      await deployedQuestContract.claim()
+      //simulate a marketplace deal with a transfer (for example an OpenSea atomicMatch, owner accepts a bid)
+      await deployedRabbitholeReceiptContract.transferFrom(owner.address, firstAddress.address, "1")
+
+      await deployedQuestContract.connect(firstAddress).claim()
+      await ethers.provider.send('evm_increaseTime', [-86400])
+    })
   })
 
   describe('withdrawRemainingTokens()', async () => {

Tools Used

VSCode and hardhat.

Recommended Mitigation Steps

diff --git a/contracts/RabbitHoleReceipt.sol b/contracts/RabbitHoleReceipt.sol.new
index 085b617..ba354e5 100644
--- a/contracts/RabbitHoleReceipt.sol
+++ b/contracts/RabbitHoleReceipt.sol.new
@@ -151,6 +151,11 @@ contract RabbitHoleReceipt is
         uint256 tokenId_,
         uint256 batchSize_
     ) internal override(ERC721Upgradeable, ERC721EnumerableUpgradeable) {
+        string memory questId = questIdForTokenId[tokenId_];
+        (address questAddress, , ) = QuestFactoryContract.questInfo(questId);
+        IQuest questContract = IQuest(questAddress);
+        bool claimed = questContract.isClaimed(tokenId_);
+        require(!claimed, "RabbitHoleReceipt: token already claimed");
         super._beforeTokenTransfer(from_, to_, tokenId_, batchSize_);
     }
 
@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 29, 2023
code423n4 added a commit that referenced this issue Jan 29, 2023
@c4-judge
Copy link
Contributor

c4-judge commented Feb 5, 2023

kirk-baird marked the issue as duplicate of #201

@c4-judge c4-judge closed this as completed Feb 5, 2023
@c4-judge c4-judge added the satisfactory satisfies C4 submission criteria; eligible for awards label Feb 14, 2023
@c4-judge
Copy link
Contributor

kirk-baird marked the issue as satisfactory

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 duplicate-119 satisfactory satisfies C4 submission criteria; eligible for awards
Projects
None yet
Development

No branches or pull requests

2 participants