Skip to content
Business logic Audit finding Intermediate

Emission updates retroactively rewrite unaccrued rewards

Reward-configuration setters in the Incentives contract change emission parameters without first checkpointing accrued rewards, so new settings apply retroactively to time that has already elapsed. An attacker or admin action could cause users to lose already-earned rewards or over-credit the prior interval, leaking excess rewards from the incentive program.

v12 Follow with 0xFBI, 6FigFundedTrader and 8 others

Originally disclosed on Code4rena

Submitted by v12, also found by 0xFBI, 6FigFundedTrader, aestheticbhai, Agozie, audithor, doe611810, FANGO, kmxunan, pepoc, and Wojack

Found by V12

  • contracts/incentives/src/contract.rs #L596
  • contracts/incentives/src/contract.rs #L677
  • contracts/incentives/src/contract.rs #L726

Targets

  • Incentives::setemissionper_second
  • Incentives::setdistributionend
  • Incentives::removeassetreward

Affected Locations

  • Incentives.setemissionper_second: Admin emission updates attempt to checkpoint rewards, but the scaled_total_supply invocation is decoded as u128 instead of the token’s i128, causing the fallback path to skip the index update.
  • Incentives.setdistributionend: This admin setter updates the distribution horizon without first accruing rewards through the current timestamp, so the new end time is applied to the entire uncheckpointed interval.
  • Incentives.removeassetreward: Removing an asset reward also mutates emission configuration without first checkpointing the prior reward index, retroactively changing reward accounting for elapsed time.

Description

Reward-configuration setters in Incentives do not reliably checkpoint accrued rewards before changing emission parameters, so new settings are applied retroactively to already elapsed time. In set_emission_per_second, the contract tries to fetch scaled_total_supply before updating the index, but it invokes the token with try_invoke_contract::<u128> even though the token returns i128. That type mismatch causes the call to fall through to _ => 0, which prevents the intended accrual update from happening. The other admin setters, set_distribution_end and remove_asset_reward, do not attempt this checkpoint at all before mutating reward parameters. As a result, changing emissions, shortening distribution, or removing a reward can rewrite the reward rate for the whole unaccrued interval instead of only affecting future accruals.

Root Cause

Administrative reward-parameter setters mutate emission state without first checkpointing the current reward index, and set_emission_per_second additionally decodes scaled_total_supply with the wrong return type.

Impact

Users can lose rewards they had already earned but that were not yet checkpointed when an admin changes emission settings. Conversely, raising emissions before checkpointing can over-credit the prior interval and leak excess rewards from the incentive program. Any administrative adjustment to reward configuration can therefore produce materially incorrect reward accounting.

Proof of Concept

See proof of concept


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

Administrative reward-parameter setters mutate emission state without first checkpointing the current reward index, and set_emission_per_second additionally decodes scaled_total_supply with the wrong return type.

Impact

Users could lose rewards they had already earned but that were not yet checkpointed, or the prior interval could be over-credited and leak excess rewards from the incentive program.

What the attacker needed

Admin changes emission settings

The fix

The setters should accrue and checkpoint rewards through the current timestamp before changing emission parameters, and set_emission_per_second should decode the token return value as i128.

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 rewards contract is supposed to pay people based on how long they held something. When an admin changes the reward rate, the contract should first record what everyone has earned so far. Here it does not, so the new rate is applied to past time as well, which can make people lose rewards they already earned or give out too many.

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 v12

View all

37 more disclosed reports, best first.

More from K2

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.