Skip to content
Business logic Audit finding Intermediate

Rewards lost when total supply drops to zero

When an asset's total supply reaches zero, the reward index update advances the last update timestamp without accruing emissions for the elapsed period. This permanently discards rewards for that window, and a sole depositor can repeatedly zero the supply to waste the emission budget.

v12 Follow with Brene, DemoreX and 1 other

Originally disclosed on Code4rena

Submitted by v12, also found by Brene, DemoreX, and oxwhite

Found by V12

  • contracts/incentives/src/calculation.rs #L12

Description

The update_asset_reward_index function advances last_update_timestamp to current_timestamp even when total_supply == 0 (line 61-65 early return). In the aToken contract, handle_incentives_action reads total_supply_scaled from state AFTER the mint/burn has already been applied (line 769, called at line 311 after burn). When the last depositor withdraws, total_supply is passed as 0. The function then skips the reward increment calculation but still sets last_update_timestamp = current_timestamp. This permanently discards all emission_per_second * elapsed_time rewards for the period between the previous update and the moment total_supply hit zero. The next depositor’s index update will only accrue from the new timestamp forward, as if no emissions occurred during the zero-supply window. In Aave V3’s reference implementation, this is mitigated by passing the pre-action total supply so the index is updated before the supply change takes effect.

Root Cause

The early return at line 61 advances last_update_timestamp to current_timestamp when total_supply == 0, permanently skipping the reward increment for the elapsed period, combined with handle_incentives_action passing the post-action (post-burn) total_supply_scaled rather than the pre-action value.

Impact

Reward tokens are permanently lost whenever the total scaled supply of an asset momentarily reaches zero. An attacker who is the sole depositor can grief other future depositors by repeatedly withdrawing fully (zeroing supply) to waste emission budget. Over time, accumulated lost emissions reduce the effective reward rate for all future participants and drain the reward budget without distributing tokens.

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

The early return when total supply is zero still advances the last update timestamp, and the caller passes the post-burn supply instead of the pre-action value, so elapsed emissions are skipped.

Impact

Reward tokens are permanently lost whenever supply momentarily hits zero, and a sole depositor could repeatedly withdraw fully to waste the emission budget and reduce the effective reward rate for future participants.

What the attacker needed

Sole depositor of an asset; total supply reaches zero

The fix

The index should be updated using the pre-action total supply so emissions are accrued before the supply change takes effect.

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 system pays out tokens over time based on how much is deposited. When the last person withdraws and the total drops to zero, the system moves its clock forward but forgets to count the rewards earned during that gap. Those rewards are lost forever, and someone who is the only depositor can keep doing this to waste the reward pool.

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.