Skip to content
Business logic Audit finding Intermediate

theft of system profit

The stabilisation mechanism that should return the Malt token price to its peg can be sandwiched by anyone, allowing them to extract profit that would otherwise go to investors. An attacker can use a flash loan to sell Malt at a high price, call stabilize to push the price down, then buy back Malt cheaply and repay the loan, keeping the difference.

danb Follow

Originally disclosed on Code4rena

Submitted by danb, also found by leastwood and WatchPug

System profit comes from the stabilize function when the price of malt is above 1. Therefore it should not be allowed for anyone to take a part of the system profit when the price is above one. Right now, anyone can take a part of the investors’ profits, even if they don’t own any malt at all.

Proof of Concept

suppose that the price went up to 1.2 dai; the investors should get the reward for this rise. instead, anyone can take a part of the reward in the following steps: The price of malt is now 1.2 dai. Take a flash loan of a large amount of malt. Sell the malt for dai. Now the price went down to 1.1 dai because of the enormous swap. Call stabilize in order to lower the price to 1 dai. Buy malt to repay the flash loan at a lower cost with the bought dai. Repay the flash loan, and take the profit.

It is a sandwich attack because they sold malt for a high price, then they called stabilize to lower the value, then repurchase it for a low price.

The user made a profit at the expense of the investors.

If a user already has malt, it’s even easier: just sell all malt at a high cost.

Recommended Mitigation Steps

in _beforeTokenTransfer, if the price is above 1$ and the receiver is the AMM pool, stabilize it.

Alex the Entreprenerd (judge) commented:

@0xScotch The warden says that if the price is above the peg price, the system should stabilize it From reading the PoolTransferVerification.verifyTransfer, the system wants you to trade when Malt is above peg (minus tolerance)

Would you say this finding is invalid?

0xScotch (sponsor) commented:

@0xScotch The warden says that if the price is above the peg price, the system should stabilize it From reading the PoolTransferVerification.verifyTransfer, the system wants you to trade when Malt is above peg (minus tolerance)

Would you say this finding is invalid?

I think the issue being pointed out is that the stabilization above peg can be sandwiched and some profit that would go to LPs can be extracted. I think this is an issue but its not absolutely critical.

We have discussed internally how to deal with this and the suggestion of calling stabilize would require some additional logic in the transfer verification as it would create a circular execution path.

  1. User tries to sell at 1.2
  2. Transfer verifier triggers stabilize
  3. StabilizerNode tries to sell Malt ahead of initial user
  4. Transfer verifier runs again and will call stabilize again unless we modify it to deal with this case.

I don’t think that is an issue but we will consider how to best move ahead with it.

Alex the Entreprenerd (judge) commented:

Let’s dissect the warden’s finding:

The price of malt is now 1.2 dai.
Take a flash loan of a large amount of malt.
Sell the malt for dai.
Now the price went down to 1.1 dai because of the enormous swap.
Call stabilize in order to lower the price to 1 dai.
Buy malt to repay the flash loan at a lower cost with the bought dai.
Repay the flash loan, and take the profit.

-> Flashloan Malt (assumes liquidity to do so, but let’s allow that) -> Sell malt for dai -> price goes lower -> Call stabilize -> system reduces price even further -> Buy back the malt -> repay the loan

I feel like this is something that can’t really be avoided as due to the permissionless nature of liquidity pools, limiting the ability to sell or buy to a path will be sidestepped by having other pools being deployed to avoid those checks.

That said, the warden has identified a way to leak value from the price control system.

To be precise the value is being extracted against traders, as to get Malt to 1.2 you’d need a trader to be so aggressive in their purchase to push the price that high. The warden showed how any arber / frontrunner can then “steal” the potential profits of the malt system users by frontrunning them.

Due to the profit extraction nature of the finding, I believe Medium Severity to be correct

The original report as published on Code4rena, by danb. 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 can be called by anyone at any time, so an attacker can sandwich the price movement it causes.

Impact

An attacker could extract profit that would otherwise go to investors, though the judge noted this is not critical and the sponsor said it is not absolutely critical.

What the attacker needed

Malt price above 1 DAI; Flash loan liquidity available; No special account needed

The fix

The suggested mitigation is to call stabilize in _beforeTokenTransfer when the price is above one dollar and the receiver is the AMM pool, but the sponsor noted this would create a circular execution path and said they would consider how to proceed.

How it was found

  1. The price of Malt is 1.2 DAI.
  2. Take a flash loan of a large amount of Malt.
  3. Sell the Malt for DAI, pushing the price down to 1.1 DAI.
  4. Call stabilize to lower the price further to 1 DAI.
  5. Buy Malt back at the lower price to repay the flash loan.
  6. Repay the flash loan and keep the profit.

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 token called Malt is meant to stay near one dollar. When its price goes above that, a function called stabilize is supposed to bring it back down. The report shows that anyone can sell Malt at the high price, trigger stabilize to push the price lower, then buy Malt back cheaply and keep the profit. This takes money away from the people who invested in the system.

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 danb

View all

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