Skip to content
Business logic Audit finding Intermediate

priceTarget is inconsistent in StabilizerNode.stabilize

The stabilize function uses a different price target than the early check that decides whether to adjust supply, so when stabilizing to peg it can choose to run an auction instead of selling malt, or the reverse. This inconsistency could lead to the wrong stabilisation action being taken.

hansfriese Follow

Originally disclosed on Code4rena

Submitted by hansfriese

https://github.com/code-423n4/2023-02-malt/blob/main/contracts/StabilityPod/StabilizerNode.sol#L178-L182

https://github.com/code-423n4/2023-02-malt/blob/main/contracts/StabilityPod/StabilizerNode.sol#L294-L298

https://github.com/code-423n4/2023-02-malt/blob/main/contracts/StabilityPod/StabilizerNode.sol#L188

Impact

priceTarget is inconsistent in StabilizerNode.stabilize so stabilize can do auction instead of selling malt and vice versa.

Proof of Concept

In StabilizerNode.stabilize, there is an early check using _shouldAdjustSupply function.

    if (!_shouldAdjustSupply(exchangeRate, stabilizeToPeg)) {
      lastStabilize = block.timestamp;
      impliedCollateralService.syncGlobalCollateral();
      return;
    }

In _shouldAdjustSupply, priceTarget is calculated by stabilizeToPeg and then check if exchangeRate is outside of some margin of priceTarget.

    if (stabilizeToPeg) {
      priceTarget = maltDataLab.priceTarget();
    } else {
      priceTarget = maltDataLab.getActualPriceTarget();
    }

But in stabilize, priceTarget is always actual price target of maltDataLab regardless of stabilizeToPeg. And it decides selling malt or doing auction by the priceTarget. So when stabilizeToPeg is true, priceTarget (= actual price target) can be different from maltDataLab.priceTarget() in most cases, and it can cause wrong decision of selling or starting auction after that.

    uint256 priceTarget = maltDataLab.getActualPriceTarget();

So when stabilizeToPeg is true, stabilize can do auction instead of selling malt, or vice versa.

Recommended Mitigation Steps

Use same logic as _shouldAdjustSupply for priceTarget. priceTarget should be maltDataLab.priceTarget() in stabilize when stabilizeToPeg is true.

0xScotch (Malt) confirmed


The original report as published on Code4rena, by hansfriese. 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 stabilize function always reads the actual price target instead of selecting the same target as the _shouldAdjustSupply check based on the stabilizeToPeg flag.

Impact

When stabilizing to peg, the contract could perform an auction instead of selling malt, or vice versa, leading to an incorrect stabilisation action.

What the attacker needed

None

The fix

The stabilize function should use the same price target logic as _shouldAdjustSupply, selecting maltDataLab.priceTarget() when stabilizeToPeg is true.

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 has a function that decides whether to sell some tokens or run an auction to steady a token's price. It first checks one price target to see if action is needed, but then uses a different price target to pick which action to take. Because the two targets can differ, the contract may pick the wrong action.

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 hansfriese

View all

65 more disclosed reports, best first.

More from Malt Protocol - Versus 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.