Skip to content
Business logic Audit finding Intermediate

RubiconMarketAddress in BathPair can’t be updated

The BathPair contract copies the Rubicon market address from BathHouse only once at initialisation, while BathHouse allows an admin to change that market address later. As a result the two contracts can fall out of sync, so BathPair would keep pointing at the old market.

pauliax Follow

Originally disclosed on Code4rena

Submitted by pauliax

https://github.com/code-423n4/2022-05-rubicon/blob/main/contracts/rubiconPools/BathPair.sol#L128

https://github.com/code-423n4/2022-05-rubicon/blob/main/contracts/rubiconPools/BathHouse.sol#L335-L337

Impact

RubiconMarketAddress in BathPair is initialized only once:

  RubiconMarketAddress = IBathHouse(_bathHouse).getMarket();

but market can change in Bath house:

    /// @notice Admin-only function to set a Bath Token's target Rubicon Market
    function setMarket(address newMarket) external onlyAdmin {
        RubiconMarketAddress = newMarket;
    }

Thus it will get out of sync. Also, the comment says that it changes Bath Token’s target Rubicon market but actually it updates its own instance variable.

Recommended Mitigation Steps

I think RubiconMarketAddress should sync between BathPair and BathHouse.

bghughes (Rubicon) acknowledged and commented:

Not needed in practice.

HickupHH3 (judge) commented:

Issue stands because there’s a non-zero possibility of it happening.


The original report as published on Code4rena, by pauliax. 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 market address is cached in BathPair at construction time instead of being read from BathHouse whenever it is needed, so later admin changes are not propagated.

Impact

BathPair could keep using a stale market address after an admin changes the market in BathHouse, though the team says this is not needed in practice.

What the attacker needed

Admin changes the market address; BathPair already initialised

The fix

RubiconMarketAddress should be kept in sync between BathPair and BathHouse, for example by reading it from BathHouse rather than caching it.

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.

A smart contract is a program on a blockchain. Here one contract (BathPair) saves a copy of an address held by another contract (BathHouse) when it starts up. If the admin later changes the address in BathHouse, the saved copy in BathPair is never refreshed, so the two disagree.

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 pauliax

View all

16 more disclosed reports, best first.

More from Rubicon v2

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.