Skip to content
Business logic Audit finding Intermediate

Unconstrained fee

The MasterChef contract allows the admin to set a token fee above 100%, which causes deposit calls to fail due to underflow when subtracting the fee from the reward. This can permanently break the contract's deposit functionality for that token, as the fee cannot be undone.

Czar102 Follow

Originally disclosed on Code4rena

Submitted by Czar102, also found by defsec, Dravee, harleythedog, hickuphh3, and throttle

MasterChef.sol#L86-L101

Token fee in MasterChef can be set to more than 100%, (for example, by accident) causing all deposit calls to fail due to underflow on subtraction when reward is lowered by the fee, thus breaking essential mechanics. Note that after the fee has been set to any value, it cannot be undone. A token cannot be removed, added, or added the second time. Thus, mistakenly (or deliberately, maliciously) added fee that is larger than 100% will make the contract impossible to recover from not being able to use the token.

Recommended Mitigation Steps

On setting fee ensure that it is below a set maximum, which is set to no more than 100%.

ryuheimat (Concur) confirmed

Alex the Entreprenerd (judge) commented:

The warden has identified admin privilege that would enable them to set the deposit fee to 100%. The value can also be increased above 100% to cause a denial of service to the user.

Mitigation would require offering a more appropriate upper limit to the fee.


The original report as published on Code4rena, by Czar102. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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 fee-setting function lacks an upper bound check, allowing values above 100% that cause an underflow during reward calculation.

Impact

The contract's deposit function becomes unusable for the affected token, and the fee cannot be undone, potentially locking funds or breaking the contract permanently.

What the attacker needed

Admin privileges to set fee

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.

In a smart contract, a fee is a percentage taken from a deposit or reward. If the fee is set higher than 100%, the code tries to subtract a larger number from a smaller one, which causes an error called an underflow. This error makes every deposit fail, and because the fee cannot be changed back, the contract becomes stuck for that token.

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.

More by Czar102

View all

12 more disclosed reports, best first.

More from Concur Finance contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.