Skip to content
Business logic Audit finding Advanced

Malt Protocol Uses Stale Results From MaltDataLab Which Can Be Abused By Users

The MaltDataLab contract relies on an externally triggered updater to refresh price and reserve averages, so those values can become stale. A user who can call stabilize could repeatedly trigger auctions and collect the 100 Malt incentive while colluding with a miner to censor the updater's transactions.

leastwood Follow

Originally disclosed on Code4rena

Submitted by leastwood

MaltDataLab integrates several MovingAverage contracts to fetch sensitive data for the Malt protocol. Primary data used by the protocol consists of the real value for LP tokens, the average price for Malt and average reserve ratios. trackMaltPrice, trackPoolReserves and trackPool are called by a restricted role denoted as the UPDATER_ROLE and represented by an EOA account and not another contract. Hence, the EOA account must consistently update the aforementioned functions to ensure the most up-to-date values. However, miners can censor calls to MaltDataLab and effectively extract value from other areas of the protocol which use stale values.

Proof of Concept

Consider the following attack vector:

  • The price of Malt exceeds the lower bound threshold and hence stabilize can be called by any user.
  • The _stabilityWindowOverride function is satisfied, hence the function will execute.
  • The state variable, exchangeRate, queries maltPriceAverage which may use an outdated exchange rate.
  • _startAuction is executed which rewards msg.sender with 100 Malt as an incentive for triggering an auction.
  • As the price is not subsequently updated, a malicious attacker could collude with a miner to censor further pool updates and continue calling stabilize on every fastAveragePeriod interval to extract incentive payments.
  • If the payments exceed what the UPDATER_ROLE is willing to pay to call trackMaltPrice, a user is able to sustain this attack.

This threatens the overall stability of the protocol and should be properly handled to prevent such attacks. However, the fact that MaltDataLab uses a series of spot price data points to calculate the MovingAverage also creates an area of concern as well-funded actors could still manipulate the MovingAverage contract by sandwiching calls to trackMaltPrice, trackPool and trackPoolReserves.

trackMaltPrice, trackPool, and trackPoolReserves should be added to the following areas of the code where applicable.

Recommended Mitigation Steps

Consider adding calls to trackMaltPrice, trackPoolReserves and trackPool wherever the values are impacted by the protocol. This should ensure the protocol is tracking the most up-to-date values. Assuming the cumulative values are used in the MovingAverage contracts, then sensitive calls utilising MaltDataLab should be protected from flashloan attacks. However, currently this is not the case, rather MovingAverage consists of a series of spot price data points which can be manipulated by well-funded actors or via a flashloan. Therefore, there needs to be necessary changes made to MaltDataLab to use cumulative price updates as its moving average instead of spot price.

0xScotch (sponsor) confirmed:

Gas issues were the reason updates weren’t inlined into paths that update critical values. However based on some thoughts from the team over the past few weeks and suggestions in other audit findings I think we can reduce gas enough to make it viable to inline it

Alex the Entreprenerd (judge) commented:

  1. Miners can censor transactions, that is a fact
  2. Relying on an external call can cause race conditions or situations where the call didn’t happen (price didn’t update in time)
  3. Arguably a malicious actor could collude with miners with the goal of extracting further value

However, the target chain for the deployment is Polygon, so unless they were to create custom validator code, and collude 1-1 with each validator (no flashbots on Polygon, yet) then the attack is increasingly more complex.

The attack is reliant on the externalities of the validator + somebody incentivized enough to exploit this.

I agree with he finding and believe after stabilize the system should auto-update the prices Because of the external requirements am downgrading to medium severity

The original report as published on Code4rena, by leastwood. 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 protocol reads price and reserve averages from MaltDataLab without forcing an update in the same transaction, so the values can be stale and the updater's transactions can be censored.

Impact

A user could repeatedly collect the 100 Malt auction incentive and threaten protocol stability, but the judge notes the attack needs validator collusion on Polygon and is therefore more complex.

What the attacker needed

Malt price above the lower bound; stability window override satisfied; collusion with a miner to censor updates; incentive exceeds updater gas cost

The fix

The protocol should call trackMaltPrice, trackPoolReserves and trackPool wherever those values are used, and MaltDataLab should use cumulative price updates rather than spot price data points.

How it was found

  1. The price of Malt exceeds the lower bound threshold so stabilize can be called by any user.
  2. The stability window override condition is satisfied and the function executes.
  3. The exchangeRate state variable queries maltPriceAverage, which may use an outdated exchange rate.
  4. The startAuction function runs and rewards the caller with 100 Malt.
  5. The attacker colludes with a miner to censor further pool updates and calls stabilize again on each fastAveragePeriod interval.

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.

Some smart contracts store prices that a separate account has to refresh by sending a transaction. If that refresh transaction is delayed or blocked, the contract keeps using old prices. Here, someone could keep triggering a reward-paying action while making sure the price refresh never happens, so they collect the reward repeatedly.

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 leastwood

View all

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