Skip to content
Business logic Audit finding Intermediate

A new era might be triggered despite a significant value being held in the previous era

The staking contract automatically starts a new era when the staking or draft rate exceeds a threshold after an RSR seizure, wiping out all holdings. If a previous seizure left the rate just below the threshold, a small subsequent seizure can push it over, destroying significant staked value.

0xA5DF Follow

Originally disclosed on Code4rena

Submitted by 0xA5DF

https://github.com/reserve-protocol/protocol/blob/c4ec2473bbcb4831d62af55d275368e73e16b984/contracts/p1/StRSR.sol#L441-L444 https://github.com/reserve-protocol/protocol/blob/c4ec2473bbcb4831d62af55d275368e73e16b984/contracts/p1/StRSR.sol#L457-L460

When RSR seizure occurs the staking and drafting rate is adjusted accordingly, if any of those rates is above some threshold then a new era begins (draft or staking era accordingly), wiping out all of the holdings of the current era. The assumption is that if the rate is above the threshold then there’s not much staking or drafts left after the seizure (and therefore it makes sense to begin a new era). However, there might be a case where a previous seizure has increased the staking/draft rate close to the threshold, and then even a small seizure would make it cross this threshold. In that case the total value of staking or drafts can be very high, and they will all be wiped out by starting a new era.

Impact

Stakers will lose their holdings or pending drafts.

Proof of Concept

Consider the following scenario:

  • Max stake rate is 1e9
  • A seizure occurs and the new rate is now 91e7
  • Not much staking is left after the seizure, but as time passes users keep staking bring back the total stakes to a significant value
  • A 10% seizure occurs, this causes the staking rate to cross the threshold (getting to 1.01e9) and start a new era

This means the stakings were wiped out despite holding a significant amount of value, causing a loss for the holders.

Recommended Mitigation Steps

This one is a bit difficult to mitigate. One way I can think of is to add a ‘migration’ feature, where in such cases a new era would be created but users would be able to transfer the funds that they held in the previous era into the new era. But this would require some significant code changes and checking that this doesn’t break anything or introduces new bugs.

tbrent (Reserve) commented:

@0xA5DF thoughts on a governance function that requires the ratio be out of bounds, that does beginEra() and/or beginDraftEra()?

The idea is that stakers can mostly withdraw, and since governance thresholds are all percentage, vote to immolate themselves and re-start the staking pool. I think it should treat beginEra() and beginDraftEra() separately, but I’m not confident in that yet.

tbrent (Reserve) acknowledged and commented:

We’re still not sure how to mitigate this one. Agree it should be considered HIGH and a new issue.

Reserve mitigated:

Adds governance function to manually push the era forward. PR: https://github.com/reserve-protocol/protocol/pull/888

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


The original report as published on Code4rena, by 0xA5DF. 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 era transition logic only checks if the rate exceeds a fixed threshold, without considering the actual remaining stake value, so a small seizure after a previous one can wipe out large holdings.

Impact

Stakers could lose their holdings or pending drafts when a new era is triggered despite significant value remaining.

What the attacker needed

Previous seizure left rate near threshold; users stake significant value; small seizure occurs

The fix

The project added a governance function to manually push the era forward, which was confirmed as a mitigation.

How it was found

  1. A seizure occurs and the staking rate becomes 91e7 (below the 1e9 threshold).
  2. Users keep staking, bringing total stakes back to a significant value.
  3. A 10% seizure occurs, pushing the rate to 1.01e9, crossing the threshold.
  4. A new era begins, wiping out all staking holdings.

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.

In this staking system, when the protocol takes some of the staked tokens (a seizure), it adjusts a rate. If that rate gets too high, the system starts a fresh 'era' and everyone's old stake is erased. The bug is that a small seizure can trigger this reset even when a lot of value is still staked, so people lose their funds.

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 0xA5DF

View all

35 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.