Skip to content
Business logic Audit finding Intermediate

Stake before unfreeze can take away most of rsr rewards in the freeze period

During a system freeze, staking is allowed but reward payout is skipped, so when unfrozen the accumulated rewards are released at once. An attacker can stake a large amount just before unfreeze and then unstake to capture most of the rewards.

ronnyx2017 Follow with rvierdiiev and 0xA5DF

Originally disclosed on Code4rena

Submitted by ronnyx2017, also found by rvierdiiev and 0xA5DF

If the system is frozen, the only allowed operation is stRST.stake. And the _payoutRewards is not called during freeze period:

if (!main.frozen()) _payoutRewards();

function payoutRewards() external {
    requireNotFrozen();
    _payoutRewards();
}

So the payoutLastPaid stays before the freeze period. But when the system is unfreezed, accumulated rewards will be released all at once because the block.timestamp leapt the whole freeze period.

Impact

A front runner can stake huge proportion rsr before admin unfreezes the system. And the attacker can get most of rsr rewards in the next block. And he only takes the risk of the unstakingDelay period.

Proof of Concept

Assumption: there are 2000 rsr stake in the stRSR, and there are 1000 rsr rewards in the rsrRewardsAtLastPayout with a 1 year half-life period.

And at present, the LONG_FREEZER freezeLong system for 1 year(default).

After 1 year, at the unfreeze point, a front runner stake 2000 rsr into stRSR. And then the system is unfreeze. And in the next blcok,the front runner unstakes all the stRSR he has for 2250 rsr = 2000 principal + 1000 / 2 / 2 rsr rewards.

The only risk he took is unstakingDelay. The original rsr stakers took the risk of the whole freeze period + unstakingDelay but only got a part of rewards back.

Recommended Mitigation Steps

payoutRewards before freeze and update payoutLastPaid before unfreeze.

tbrent (Reserve) confirmed via duplicate issue #24

Reserve mitigated:

payoutRewards before freeze and update payoutLastPaid before unfreeze. PR: https://github.com/reserve-protocol/protocol/pull/857

Status: Mitigation confirmed. Full details in reports from rvierdiiev, 0xA5DF, and ronnyx2017 - and also shared below in the Mitigation Review section.


The original report as published on Code4rena, by ronnyx2017. 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 payout timestamp is not updated during the freeze, so when unfrozen the entire freeze period's rewards are distributed to whoever is staked at that moment.

Impact

An attacker could take most of the RSR rewards accumulated during the freeze period, risking only the unstaking delay, while original stakers who bore the freeze risk receive less.

What the attacker needed

System is frozen; attacker can stake before unfreeze; attacker can unstake after unfreeze

The fix

The project mitigated by calling payoutRewards before freeze and updating payoutLastPaid before unfreeze.

How it was found

  1. Wait until the system is frozen and only staking is allowed.
  2. Stake a large amount of RSR just before the admin unfreezes the system.
  3. After unfreeze, unstake to receive the staked amount plus a large share of the accumulated rewards.

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.

The system has a freeze period where only staking is allowed, but rewards are not paid out. When the freeze ends, all the rewards that built up during the freeze are suddenly released. An attacker can put in a large stake just before the freeze ends and then take out most of those rewards, leaving the original stakers with less.

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 ronnyx2017

View all

24 more disclosed reports, best first.

More from Reserve Core

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.