Skip to content
Business logic Audit finding Intermediate

BasketHandler: Users might not be able to redeem their rToken when protocol is paused due to refreshBasket function

The RToken redemption function is meant to work while the protocol is paused, but it depends on the basket not being DISABLED. When the basket is DISABLED and the protocol is paused, only governance can call refreshBasket, so users cannot redeem their rTokens without governance action.

HollaDieWaldfee Follow

Originally disclosed on Code4rena

Submitted by HollaDieWaldfee

https://github.com/reserve-protocol/protocol/blob/df7ecadc2bae74244ace5e8b39e94bc992903158/contracts/p1/RToken.sol#L439-L514 https://github.com/reserve-protocol/protocol/blob/df7ecadc2bae74244ace5e8b39e94bc992903158/contracts/p1/RToken.sol#L448 https://github.com/reserve-protocol/protocol/blob/df7ecadc2bae74244ace5e8b39e94bc992903158/contracts/p1/BasketHandler.sol#L183-L192

The Reserve protocol allows redemption of rToken even when the protocol is paused.

The docs/system-design.md documentation describes the paused state as:

all interactions disabled EXCEPT RToken.redeem + RToken.cancel + ERC20 functions + StRSR.stake

Redemption of rToken should only ever be prohibited when the protocol is in the frozen state.

You can see that the RToken.redeem function (https://github.com/reserve-protocol/protocol/blob/df7ecadc2bae74244ace5e8b39e94bc992903158/contracts/p1/RToken.sol#L439-L514) has the notFrozen modifier so it can be called when the protocol is in the paused state.

The issue is that this function relies on the BasketHandler.status() to not be DISABLED (https://github.com/reserve-protocol/protocol/blob/df7ecadc2bae74244ace5e8b39e94bc992903158/contracts/p1/RToken.sol#L448).

The BasketHandler.refreshBasket function (https://github.com/reserve-protocol/protocol/blob/df7ecadc2bae74244ace5e8b39e94bc992903158/contracts/p1/BasketHandler.sol#L183-L192) however, which must be called to get the basket out of the DISABLED state, cannot be called by any user when the protocol is paused.

When the protocol is paused it can only be called by the governance (OWNER) address.

So in case the basket is DISABLED and the protocol is paused, it is the governance that must call refreshBasket to allow redemption of rToken.

This is dangerous because redemption of rToken should not rely on governance to perform any actions such that users can get out of the protocol when there is something wrong with the governance technically or if the governance behaves badly.

Proof of Concept

The RToken.redeem function has the notFrozen modifier so it can be called when the protocol is paused (https://github.com/reserve-protocol/protocol/blob/df7ecadc2bae74244ace5e8b39e94bc992903158/contracts/p1/RToken.sol#L439).

The BasketHandler.refreshBasket function can only be called by the governance when the protocol is paused:

https://github.com/reserve-protocol/protocol/blob/df7ecadc2bae74244ace5e8b39e94bc992903158/contracts/p1/BasketHandler.sol#L186-L190

require(
    main.hasRole(OWNER, _msgSender()) ||
        (status() == CollateralStatus.DISABLED && !main.pausedOrFrozen()),
    "basket unrefreshable"
);

Therefore the situation exists where rToken redemption should be possible but it is blocked by the BasketHandler.refreshBasket function.

Tools Used

VSCode

Recommended Mitigation Steps

The BasketHandler.refreshBasket function should be callable by anyone when the status() is DISABLED and the protocol is paused.

So the above require statement can be changed like this:

diff --git a/contracts/p1/BasketHandler.sol b/contracts/p1/BasketHandler.sol
index f74155b1..963e29de 100644
--- a/contracts/p1/BasketHandler.sol
+++ b/contracts/p1/BasketHandler.sol
@@ -185,7 +185,7 @@ contract BasketHandlerP1 is ComponentP1, IBasketHandler {

         require(
             main.hasRole(OWNER, _msgSender()) ||
-                (status() == CollateralStatus.DISABLED && !main.pausedOrFrozen()),
+                (status() == CollateralStatus.DISABLED && !main.frozen()),
             "basket unrefreshable"
         );
         _switchBasket();

It was discussed with the sponsor that they might even allow rToken redemption when the basket is DISABLED.

In other words only disallow it when the protocol is frozen.

This however needs further consideration by the sponsor as it might negatively affect other aspects of the protocol that are beyond the scope of this report.

0xean (judge) commented:

I believe this to be a design choice. Will leave open to sponsor review and most likely downgrade to QA.

pmckelvy1 (Reserve) acknowledged

0xean (judge) commented:

The warden identified a state that was inconsistent with sponsors expectations since they acknowledged the issue, I believe this should be Medium as it does affect the availability of the protocol.

tbrent (Reserve) mitigated:

This PR enables redemption while the basket is DISABLED: reserve-protocol/protocol#575

Status: Mitigation confirmed. Full details in reports from 0xA5DF, HollaDieWaldfee, and AkshaySrivastav.


The original report as published on Code4rena, by HollaDieWaldfee. 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 refreshBasket function's access check blocks non-governance callers when the protocol is paused, even if the basket is DISABLED, so redemption cannot proceed without governance.

Impact

Users may be unable to redeem their rTokens while the protocol is paused and the basket is DISABLED, unless governance calls refreshBasket, which affects availability and relies on governance acting correctly.

What the attacker needed

Basket is DISABLED; protocol is paused; governance does not call refreshBasket

The fix

The refreshBasket function should be callable by anyone when the basket is DISABLED and the protocol is paused (only disallow when frozen); the sponsor mitigated by enabling redemption while the basket is DISABLED.

How it was found

  1. The basket is in the DISABLED state.
  2. The protocol is paused.
  3. A user calls RToken.redeem, which has the notFrozen modifier so it is callable while paused.
  4. The redeem function checks BasketHandler.status() and finds it is DISABLED, so redemption is blocked.
  5. The user cannot call refreshBasket because the require statement only allows governance when paused.
  6. Only governance can call refreshBasket to move the basket out of DISABLED and allow redemption.

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 protocol has a pause switch that is supposed to stop most actions but still let users take their money out. However, if the basket of assets backing the token is marked as broken (DISABLED), the withdrawal path gets blocked unless the protocol owners step in. This means users could be stuck waiting for the owners to act.

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 HollaDieWaldfee

View all

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