Skip to content
Business logic Audit finding Intermediate

Sell reward rTokens at low price because of skiping furnace.melt

The RevenueTrader's manageToken function only refreshes the asset registry and melts the furnace if the registry hasn't been refreshed in the same block. An attacker can call assetRegistry.refresh() first, so the furnace.melt() is skipped, leaving the RToken's basket unit exchange rate lower than actual and causing reward rTokens to be sold at a lower price.

ronnyx2017 Follow

Originally disclosed on Code4rena

Submitted by ronnyx2017

The reward rToken sent to RevenueTrader will be sold at a low price. RSR stakers will lose some of their profits.

Proof of Concept

RevenueTraderP1.manageToken function is used to launch auctions for any erc20 tokens sent to it. For the RevenueTrader of the rsr stake, the tokenToBuy is rsr and the token to sell is reward rtoken.

There is the refresh code in the manageToken function:

} else if (assetRegistry.lastRefresh() != uint48(block.timestamp)) {
    // Refresh everything only if RToken is being traded
    assetRegistry.refresh();
    furnace.melt();
}

It refreshes only when the assetRegistry has not been refreshed in the same block.

So if the actor calls the assetRegistry.refresh() before calling manageToken function, the furnace.melt() won’t been called. And the BU exchange rate of the RToken will be lower than actual value. So the sellPrice is also going to be smaller.

(uint192 sellPrice, ) = sell.price(); // {UoA/tok}

TradeInfo memory trade = TradeInfo({
    sell: sell,
    buy: buy,
    sellAmount: sell.bal(address(this)),
    buyAmount: 0,
    sellPrice: sellPrice,
    buyPrice: buyPrice
});

Recommended Mitigation Steps

Refresh everything before sell rewards.

tbrent (Reserve) confirmed

Reserve mitigated:

Refresh before selling rewards, refactor revenue & distro. PR: https://github.com/reserve-protocol/protocol-private/pull/7

Status: Mitigation confirmed. Full details in reports from ronnyx2017, 0xA5DF, and rvierdiiev - 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 manageToken function only calls furnace.melt() when assetRegistry.lastRefresh() is not the current block timestamp, so a prior refresh in the same block prevents the melt and leaves the RToken's exchange rate stale.

Impact

Reward rTokens could be sold at a lower price, causing RSR stakers to lose some of their profits.

What the attacker needed

Ability to call assetRegistry.refresh(); ability to trigger manageToken in same block

The fix

The code was mitigated by refreshing before selling rewards and refactoring revenue and distribution.

How it was found

  1. Call assetRegistry.refresh() to update the registry in the current block.
  2. Call RevenueTraderP1.manageToken, which sees the registry already refreshed and skips furnace.melt().
  3. The RToken's basket unit exchange rate remains lower than actual, so the sell price used in the auction is smaller.

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 system, reward tokens are sold through auctions. Before selling, the system is supposed to update some internal values (refresh and melt) so the price is correct. The bug is that if someone triggers the update just before the sale, the sale skips its own update and uses an outdated, lower price, so the sellers get less than they should.

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.