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#L596contracts/incentives/src/contract.rs#L677contracts/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_supplyinvocation is decoded asu128instead of the token’si128, 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
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.