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.
Submitted by pauliax
https://github.com/code-423n4/2022-05-rubicon/blob/main/contracts/rubiconPools/BathPair.sol#L128
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.
Issue stands because there’s a non-zero possibility of it happening.
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.