RabbitHoleReceipt’s address might be changed therefore only manual mint will be available
The QuestFactory contract stores a mutable address for the RabbitHoleReceipt contract, while each Quest contract stores an immutable copy at creation. If the factory's receipt address is changed, users can still mint receipts through the factory, but those receipts are unknown to the Quest's original receipt contract, so users cannot claim rewards without manual intervention.
Submitted by glcanvas, also found by libratus, adriro, and hansfriese
https://github.com/rabbitholegg/quest-protocol/blob/8c4c1f71221570b14a0479c216583342bd652d8d/contracts/Quest.sol#L13 https://github.com/rabbitholegg/quest-protocol/blob/8c4c1f71221570b14a0479c216583342bd652d8d/contracts/Quest.sol#L44 https://github.com/rabbitholegg/quest-protocol/blob/8c4c1f71221570b14a0479c216583342bd652d8d/contracts/Quest.sol#L96-L118 https://github.com/rabbitholegg/quest-protocol/blob/8c4c1f71221570b14a0479c216583342bd652d8d/contracts/RabbitHoleReceipt.sol#L95-L104 https://github.com/rabbitholegg/quest-protocol/blob/8c4c1f71221570b14a0479c216583342bd652d8d/contracts/QuestFactory.sol#L215-L229
Might be impossible to claim rewards by users. And admins must distribute tokens manually and pay fee for this. On a huge amount of participants this leads to huge amount of fees.
Proof of Concept
Let’s consider QuestFactory. It has:
RabbitHoleReceipt public rabbitholeReceiptContract;
Which responsible for mint tokens for users.
Then consider createQuest function. Here we pass rabbitholeReceiptContract into Quest.
In Quest this field is immutable.
Now let’s consider next case:
- We initialized whole contracts.
- We created new Quest.
- Next we decided to change
rabbitholeReceiptContractinQuestFactoryfor another. To do this we call:setRabbitHoleReceiptContract. And successfully changing address. - Next we distribute signatures to our participants.
- Users starts to mint tokens. But here is a bug
QuestFactorystorages new address ofrabbitholeReceiptContract, butQuestinitialized with older one. So users successfully minted their tokens, but can’t exchange them for tokens because the Quest’s receipt contract know nothing about minted tokens.
Possible solution here is change minterAddress in the original RabbitHoleReceipt contract and manually mint tokens by admin, but it will be too expensive and the company may lost a lot of money.
Recommended Mitigation Steps
In QuestFactory contract in the function mintReceipt the rabbitholeReceiptContract must be fetched from the quest directly.
To Quest Add:
function getRabbitholeReceiptContract() public view returns(RabbitHoleReceipt) {
return rabbitHoleReceiptContract;
}
Modify mintReceipt function in QuestFactory like:
function mintReceipt(string memory questId_, bytes32 hash_, bytes memory signature_) public {
...
RabbitHoleReceipt rabbitholeReceiptContract = Quest(quests[questId_].questAddress).getRabbitholeReceiptContract();
rabbitholeReceiptContract.mint(msg.sender, questId_);
...
}
waynehoover (RabbitHole) disagreed with severity and commented:
Since our contract is upgradeable, they have to trust us that we aren’t going to do this during live quests. This was an emergency function, and likely won’t ever need to be used and only be accessible by only owner/us.
kirk-baird (judge) decreased severity to Medium and commented:
This is a valid issue as upgrading the receipt contract will break currently open quests to prevent minting of receipts. This does not result in a loss of funds as they can be recovered by the quest creator.
Additionally, it is only accessible by the admin and so I’m going to downgrade this to a medium.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the factory uses a mutable receipt contract address for minting, while each quest stores an immutable copy at creation, so changing the factory's address breaks the link between minted receipts and the quest's expected receipt contract.
Impact
Users may be unable to claim rewards, and admins would have to distribute tokens manually at significant cost; the judge noted this does not result in a loss of funds as they can be recovered by the quest creator, and the function is only accessible by the admin.
What the attacker needed
Admin changes the receipt contract address; active quests exist
The fix
The factory should fetch the receipt contract address directly from the quest when minting, rather than using its own stored address.
How it was found
- Initialise the contracts.
- Create a new Quest.
- Change the rabbitholeReceiptContract in QuestFactory by calling setRabbitHoleReceiptContract.
- Distribute signatures to participants.
- Users mint tokens, which are recorded in the new receipt contract, but the Quest still references the old one, so the tokens cannot be exchanged for rewards.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A smart contract is a program on a blockchain. Here, a factory contract creates quests and also points to a receipt contract that records who earned a reward. Each quest saves its own copy of that receipt address when it is created. If the factory later changes its pointer, new receipts are recorded in a different contract than the one the quest checks, so the quest does not recognise them.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.