Skip to content
Business logic Audit finding Intermediate

Protocol’s Walls / cushion bonds remain active even if heart is not beating

The protocol's wall swap mechanism remains active even when the price feed is stale because it does not check whether beat() has been called recently. An attacker could buy the token cheaply on an external market and sell it to the wall at an outdated, higher price, draining funds.

Trust Follow

Originally disclosed on Code4rena

Submitted by Trust

https://github.com/code-423n4/2022-08-olympus/blob/b5e139d732eb4c07102f149fb9426d356af617aa/src/policies/Operator.sol#L188-L191 https://github.com/code-423n4/2022-08-olympus/blob/main/src/policies/Operator.sol#L272 https://github.com/code-423n4/2022-08-olympus/blob/b5e139d732eb4c07102f149fb9426d356af617aa/src/policies/Operator.sol#L346

The Walls of the RBS mechanism offer zero slippage swaps at the high and low of the moving average spread. The capacity to be swapped at these prices is usually very large, so it must make sure to only be enabled when the prices are guaranteed to be synced. However, there is no such check. If beat() is not called for some time, meaning we cannot determine if the current spread is legit, swap() still operates as usual.

Impact

The worst case scenario is that the wall is swapping at a losing price, meaning they can be immediately drained via arbitrage bot.

Proof of concept

1. Price is X at the start
2. Oracle stops updating for some reason / no one calls beat()
3. Price drops to Y , where Y < low wall centered around X
4. Attacker can perform arbitrage by buying Ohm at external markets at Y and selling Ohm at low wall price, netting the difference.

Recommended mitigation steps:

Change modifier onlyWhileActive to add a check for beat out of sync:

if (block.timestamp > lastBeat + SYNC_THRESHOLD * frequency())

Oighty (Olympus) confirmed and commented:

This is an interesting unintended consequence of a bad price feed or other beat() issue. Your suggested update makes sense, but we will probably adjust slightly to only manage the bad data threshold in one place.

After originally looking at it, I thought a try/catch block on the external call to PRICE.getLastPrice() in Operator.operate() would work, but it doesn’t handle cases where operate() isn’t reached by the beat() function.


The original report as published on Code4rena, by Trust. 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 onlyWhileActive modifier does not verify that the price feed has been updated recently (i.e., that beat() was called within a safe time window).

Impact

The wall could swap at a losing price and be immediately drained via arbitrage.

What the attacker needed

Beat() not called for some time; price moves below the low wall; attacker can trade on external markets

The fix

The onlyWhileActive modifier should be changed to also check that the last beat is not older than a sync threshold.

How it was found

  1. The price starts at X.
  2. The oracle stops updating or no one calls beat().
  3. The price drops to Y, which is below the low wall centered around X.
  4. The attacker buys Ohm on external markets at Y and sells it to the low wall at the higher price, netting the difference.

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.

This is a smart contract bug where a trading feature keeps working even when the price information it relies on is out of date. An attacker can take advantage of the old price to buy low elsewhere and sell high to the contract, making a profit at the protocol's expense.

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 Trust

View all

77 more disclosed reports, best first.

More from Olympus DAO contest

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.