Skip to content
Business logic Audit finding Beginner

Improper Upper Bound Definition on the Fee

The contract's emission rate parameter lacks upper and lower bounds, so an owner could set an excessively large value. This would cause reversions in critical functions that rely on the rate.

Jujic Follow

Originally disclosed on Code4rena

Submitted by Jujic

The rJoePerSec does not have any upper or lower bounds. Values that are too large will lead to reversions in several critical functions.

Proof of Concept

https://github.com/code-423n4/2022-01-trader-joe/blob/a1579f6453bc4bf9fb0db9c627beaa41135438ed/contracts/RocketJoeStaking.sol#L151

function updateEmissionRate(uint256 _rJoePerSec) external onlyOwner {
    updatePool();
    rJoePerSec = _rJoePerSec;
    emit UpdateEmissionRate(msg.sender, _rJoePerSec);
}

Tools Used

Remix

Recommended Mitigation Steps

Consider define upper and lower bounds on the _rJoePerSec.

cryptofish7 (Trader Joe) confirmed, but disagreed with severity and commented:

Confirming issue but disagree with severity.

Fix: https://github.com/traderjoe-xyz/rocket-joe/pull/112


The original report as published on Code4rena, by Jujic. 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 setter function for the emission rate lacks validation to ensure the value falls within a safe range, allowing an excessively large number that causes arithmetic overflows or other failures downstream.

Impact

An excessively large emission rate could cause critical functions to revert, potentially disrupting staking or reward distribution, though only the owner can set the value.

What the attacker needed

Owner privileges

The fix

The issue was fixed by adding bounds to the emission rate parameter, as indicated by the linked pull request.

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 has a setting for how many reward tokens are given out per second. The person who controls this setting can put in any number, even one so huge that the maths in other parts of the contract breaks and those functions stop working. The report says this should be limited to a sensible range.

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 Jujic

View all

4 more disclosed reports, best first.

More from Trader Joe 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.