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

Unlike questFee_ , royaltyFee_ is missing Upper Limit #651

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

Unlike questFee_ , royaltyFee_ is missing Upper Limit #651

code423n4 opened this issue Jan 30, 2023 · 3 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 confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/rabbitholegg/quest-protocol/blob/8c4c1f71221570b14a0479c216583342bd652d8d/contracts/RabbitHoleReceipt.sol#L90-L93

Vulnerability details

In the QuestFactory.sol contract, as expected there is an upper limit on the questFee_ so that no unjust amount is set for the questFee_

186-189:     function setQuestFee(uint256 questFee_) public onlyOwner { 
        if (questFee_ > 10_000) revert QuestFeeTooHigh();  
        questFee = questFee_;
    }

However, in RabbitHoleReceipt.sol, the function setRoyaltyFee() does not set an upper limit to the royaltyFee_ parameter. Thus any arbitrarily large values can be set for royaltyFee_

https://github.com/rabbitholegg/quest-protocol/blob/8c4c1f71221570b14a0479c216583342bd652d8d/contracts/RabbitHoleReceipt.sol#L90-L93

90-93: function setRoyaltyFee(uint256 royaltyFee_) public onlyOwner {
        royaltyFee = royaltyFee_;
        emit RoyaltyFeeSet(royaltyFee_);
    }

setting large values of royaltyFee_ will change all calculations in the contract wherever royaltyFee_ is involved and very large sums of money will flow towards royalty fees. Royalty fee is meant to be a small amount, however here that is not the case.

Recommended Mitigation Steps

modify the setRoyaltyFee() function to set an upper limit to the royaltyFee_ . A code similar to the following can be used

function setRoyaltyFee(uint256 royaltyFee_) public onlyOwner {
		if (royaltyFee_ > 1_000) revert RoyaltyFeeTooHigh();  
        royaltyFee = royaltyFee_;
        emit RoyaltyFeeSet(royaltyFee_);
    }
@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 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-judge
Copy link
Contributor

c4-judge commented Feb 6, 2023

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

@c4-sponsor c4-sponsor added the sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity") label Feb 7, 2023
@c4-sponsor
Copy link

waynehoover marked the issue as sponsor confirmed

@kirk-baird kirk-baird mentioned this issue Feb 9, 2023
@c4-judge
Copy link
Contributor

kirk-baird marked the issue as grade-a

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 confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Projects
None yet
Development

No branches or pull requests

3 participants