Skip to content
Audit finding Intermediate

secRewardsPerShare Insufficient precision

The secRewardsPerShare calculation uses insufficient precision, causing rounding down to zero for typical market supplies. This means secondary rewards are effectively not accumulated, leading to a loss of yield for participants.

bin2chen Follow with xuwinnie

Originally disclosed on Code4rena

Submitted by bin2chen, also found by xuwinnie

We also introduced the field secRewardDebt. The idea of this field is to enable any lending platforms that are integrated with Neofinance Coordinator to send their own rewards based on this value (or rather the difference of this value since the last time secondary rewards were sent) and their own emission schedule for the tokens.

The current calculation formula for secRewardsPerShare is as follows:

market.secRewardsPerShare += uint128((blockDelta * 1e18) / marketSupply);

marketSupply is cNOTE, with a precision of 1e18 So as long as the supply is greater than 1 cNote, secRewardsPerShare is easily rounded down to 0 Example: marketSupply = 10e18 blockDelta = 1 secRewardsPerShare=1 * 1e18 / 10e18 = 0

Impact

Due to insufficient precision, secRewardsPerShare will basically be 0.

Recommended Mitigation

It is recommended to use 1e27 for secRewardsPerShare:

    market.secRewardsPerShare += uint128((blockDelta * 1e27) / marketSupply);

Alex the Entreprenerd (Judge) commented:

The Warden has shown how, due to incorrect precision, it is possible to create a loss due to rounding down.

Because the loss is limited to yield, Medium Severity seems most appropriate.

OpenCoreCH (sponsor) confirmed


The original report as published on Code4rena, by bin2chen. 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 reward-per-share accumulator uses a scaling factor of 1e18, which is too small relative to the market supply, causing integer division to round down to zero.

Impact

Secondary rewards per share are effectively zero, causing a loss of yield for users; the judge rated this as Medium severity because the loss is limited to yield.

What the attacker needed

Market supply greater than 1 cNOTE

The fix

The precision should be increased by using a scaling factor of 1e27 instead of 1e18.

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.

This is a smart contract bug where a reward calculation loses precision because it divides by a large number. When the result is rounded down to zero, users don't get the rewards they should, so they lose out on yield.

More by bin2chen

View all

139 more disclosed reports, best first.

More from Canto

View all

The newest disclosed reports for this program.

Similar reports

Same bug class and techniques, clearest first.