Skip to content
Business logic Audit finding Intermediate

In MultiRewardStaking.addRewardToken() , rewardsPerSecond is not accurate enough to handle all type of reward tokens.

The addRewardToken function stores rewardsPerSecond as a raw token amount, so for tokens with few decimals the minimum meaningful rate is impractically large. An attacker could not exploit this directly, but the protocol would fail to support such tokens as intended.

hansfriese Follow

Originally disclosed on Code4rena

Submitted by hansfriese

The raw rewardsPerSecond might be too big for some ERC20 tokens and it wouldn’t work as intended.

Proof of Concept

As we can see from _accrueStatic(), the rewardsPerSecond is a raw amount without any multiplier.

  function _accrueStatic(RewardInfo memory rewards) internal view returns (uint256 accrued) {
    uint256 elapsed;
    if (rewards.rewardsEndTimestamp > block.timestamp) {
      elapsed = block.timestamp - rewards.lastUpdatedTimestamp;
    } else if (rewards.rewardsEndTimestamp > rewards.lastUpdatedTimestamp) {
      elapsed = rewards.rewardsEndTimestamp - rewards.lastUpdatedTimestamp;
    }

    accrued = uint256(rewards.rewardsPerSecond * elapsed);
  }

But 1 wei for 1 second would be too big an amount for some popular tokens like WBTC(8 decimals) and EURS(2 decimals).

For WBTC, it will be 0.31536 WBTC per year (worth about $7,200) to meet this requirement, and for EURS, it must be at least 315,360 EURS per year (worth about $315,000).

Such amounts might be too big as rewards and the protocol wouldn’t work properly for such tokens.

Recommended Mitigation Steps

Recommend introducing a RATE_DECIMALS_MULTIPLIER = 10**9(example) to increase the precision of rewardsPerSecond instead of using the raw amount.

RedVeil (Popcorn) confirmed


The original report as published on Code4rena, by hansfriese. 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

Impact

For tokens like WBTC and EURS, the minimum reward rate would be too large, so the protocol may not work properly for those tokens.

What the attacker needed

Reward token with few decimals

The fix

Introduce a scaling multiplier (for example 10**9) to increase the precision of rewardsPerSecond instead of using the raw amount.

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.

Some tokens have very few decimal places, so the smallest unit is worth a lot. The code sets a reward rate in those smallest units per second, which forces the reward to be huge for such tokens. This is a design flaw, not an attack.

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 hansfriese

View all

65 more disclosed reports, best first.

More from Popcorn 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.