Skip to content
Business logic Audit finding Intermediate

Stale reward indexes accrue emissions across inactive periods

Reward deactivation and deletion paths leave the reward index timestamp in place, so when the same asset/reward pair is reactivated the stale timestamp is reused. The next index update then accrues emissions for the whole inactive gap, letting users claim rewards for periods when emissions should have been off.

v12 Follow with 4funnds, BlackAdam and 8 others

Originally disclosed on Code4rena

Submitted by v12, also found by 4funnds, BlackAdam, D_Auditor, ht111111, makarov, oxwhite, Silvermist, SOPROBRO, Tigerfrake, and wuji

Found by V12

  • contracts/incentives/src/contract.rs #L726
  • contracts/incentives/src/contract.rs #L780
  • contracts/incentives/src/storage.rs #L385
  • contracts/incentives/src/contract.rs #L531
  • contracts/incentives/src/calculation.rs #L12
  • contracts/incentives/src/contract.rs #L369
  • contracts/incentives/src/contract.rs #L71

Targets

  • IncentivesContract::removeassetreward
  • IncentivesContract::deleterewardtoken
  • storage::removerewardtoken
  • IncentivesContract::configureassetrewards
  • IncentivesContract::updateassetreward_index
  • IncentivesContract::claimallrewards
  • IncentivesContract::handle_action

Affected Locations

  • IncentivesContract.removeassetreward: Disabling an asset reward only flips is_active and leaves the existing reward index timestamp in place.
  • IncentivesContract.deleterewardtoken: Deleting a reward token removes registration metadata but can leave per-asset reward config/index state reusable on later reconfiguration.
  • storage.removerewardtoken: The helper cleanup for reward-token deletion does not clear all persisted state tied to the removed reward.
  • IncentivesContract.configureassetrewards: Reconfiguration reuses an existing index when present instead of resetting its timestamp for a newly reactivated reward.
  • IncentivesContract.updateassetreward_index: The stale last_update_timestamp is consumed here to accrue rewards across periods when the reward was inactive or deleted.
  • IncentivesContract.claimallrewards: User-triggered reward claims can be the first path that realizes the retroactive accrual.
  • IncentivesContract.handle_action: Regular balance updates can also trigger the stale index update after reactivation.

Description

Reward lifecycle transitions do not fully reset or finalize index state when a reward is deactivated or deleted. In remove_asset_reward, the code marks the reward inactive without first advancing the index timestamp, and delete_reward_token/remove_reward_token can leave related ASSET_REWARD_CONFIG or ASSET_REWARD_INDEX data behind. Later, configure_asset_rewards only initializes a fresh index when none exists, so reactivation of the same asset/reward pair reuses the stale last_update_timestamp. The next call into update_asset_reward_index through handle_action or claim_all_rewards then treats the inactive gap as elapsed active time. This causes rewards to be accrued retroactively for periods when emissions were supposed to be off.

Root Cause

Reward removal and deactivation paths fail to clear or checkpoint existing reward index state, and configure_asset_rewards reuses that stale index instead of resetting last_update_timestamp on reactivation.

Impact

Users can claim reward tokens for inactive or deleted periods, causing the incentives system to over-distribute from prefunded reward balances. If a reward is re-enabled with a different emission rate, the entire gap can be repriced at the new rate, making the misallocation substantially larger.

Proof of Concept

See this gist for full 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

Reward removal and deactivation paths fail to clear or checkpoint existing reward index state, and configure_asset_rewards reuses that stale index instead of resetting last_update_timestamp on reactivation.

Impact

Users could claim rewards for inactive or deleted periods, over-distributing from prefunded balances, and the misallocation may be substantially larger if the reward is re-enabled at a higher emission rate.

What the attacker needed

A reward is deactivated or deleted; the same asset/reward pair is reactivated; an index update or claim occurs afterwards

The fix

Deactivation and deletion should checkpoint or clear the reward index state, and reactivation should reset last_update_timestamp rather than reuse the stale index.

How it was found

  1. Deactivate an asset reward, which only flips the active flag and leaves the index timestamp.
  2. Reactivate the same asset/reward pair through configuration, which reuses the existing index.
  3. Trigger an index update via a balance action or a reward claim.
  4. The inactive gap is counted as active time and rewards are accrued for it.

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 pays people over time by remembering when it last updated a running total. When a reward is switched off, that 'last updated' time should be reset, but here it is kept. If the reward is switched back on, the contract thinks all the time it was off was active, so it pays out extra rewards that were never meant to be earned.

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.