Skip to content
Business logic Audit finding Advanced

Custom redemption can be used to get more than RToken value, when an upwards depeg occurs

Custom redemption allows an attacker to redeem RToken for a mix of current and previous basket collateral, and when a collateral has depegged upwards, the attacker can receive more value than the RToken's target value. This takes funds that were meant for revenue traders.

0xA5DF Follow

Originally disclosed on Code4rena

Submitted by 0xA5DF

https://github.com/reserve-protocol/protocol/blob/c4ec2473bbcb4831d62af55d275368e73e16b984/contracts/p1/RToken.sol#L245-L338 https://github.com/reserve-protocol/protocol/blob/c4ec2473bbcb4831d62af55d275368e73e16b984/contracts/p1/BasketHandler.sol#L437-L440

Custom redemption allows to redeem RToken in exchange of a mix of previous baskets (as long as it’s not more than the prorata share of the redeemer). The assumption is that previous baskets aren’t worth more than the target value of the basket. However, a previous basket can contain a collateral that depegged upwards and is now actually worth more than its target.

Impact

Funds that are supposed to go revenue traders would be taken by an attacker redeeming RToken.

Proof of Concept

The following code shows that when a depeg occurs the collateral becomes IFFY (which means it’ll be disabled after a certain delay):

            // If the price is below the default-threshold price, default eventually
            // uint192(+/-) is the same as Fix.plus/minus
            if (pegPrice < pegBottom || pegPrice > pegTop || low == 0) {
                markStatus(CollateralStatus.IFFY);
            } else {
                markStatus(CollateralStatus.SOUND);
            }

Consider the following scenario:

  • Basket contains token X which is supposed to be pegged to c
  • Token X depegs upwards and is now worth 2c
  • After delayUntilDefault passes the basket gets disabled
  • A basket refresh is executed (can be done by anybody) and token Y kicks in as the backup token
  • Half of token X is now traded for the required Y tokens
  • The other half should go to revenue traders (rsr trader and Furnace), but before anyone calls ‘forewardRevenue’ the attacker calls custom redemption with half from the current basket and half of the previous one
  • The user would get 0.5X+0.5Y per each RToken which is worth 1.5c

Recommended Mitigation Steps

When doing custom redemption check that the collateral used is sound or at least check that the price isn’t higher then the peg price.

tbrent (Reserve) acknowledged, but disagreed with severity and commented:

This is also true of normal redemption via redeem() until refreshBasket() is called after the collateral has cycled from IFFY to DISABLED.

It only checks basketHandler.fullyCollateralized(), not basketHandler.isReady(). This is intended. It is important to not disallow redemption, and using USD prices to determine redemption quantities is opposite to the fundamental design of the protocol.

Agree that the behavior is as the warden indicates. All alternatives seem worse, however. I think this is probably not HIGH. We do not expect to make any change to the behavior.

0xean (judge) reduced severity to Medium and commented:

I think Medium seems like the correct severity here. There are pre-conditions for this to occur and in addition the likelihood doesn’t seem very high.


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, custom redemption does not check that the collateral used is sound or that its price is not above the peg price, allowing redemption of a previous basket that contains an upward-depegged collateral worth more than its target.

What the attacker needed

A collateral depegs upwards; delayUntilDefault passes; basket refresh executed; attacker calls custom redemption before forwardRevenue

How it was found

  1. A basket contains token X pegged to c.
  2. Token X depegs upwards and is now worth 2c.
  3. After delayUntilDefault passes, the basket gets disabled.
  4. A basket refresh is executed and token Y becomes the backup token; half of token X is traded for Y.
  5. Before anyone calls forwardRevenue, the attacker calls custom redemption with half from the current basket and half from the previous one.
  6. The attacker receives 0.5X+0.5Y per RToken, worth 1.5c.

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, an RToken is backed by a basket of other tokens. Normally, if a token in the basket becomes worth more than its target, the extra value goes to the protocol's revenue traders. But the report shows that an attacker can use a feature called custom redemption to take that extra value for themselves before the revenue is forwarded.

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.