Skip to content
Business logic Audit finding Intermediate

AuctionBurnReserveSkew.getPegDeltaFrequency() Wrong implementation can result in an improper amount of excess Liquidity Extension balance to be used at the end of an auction

The function getPegDeltaFrequency() divides by auctionAverageLookback even when fewer observations exist, producing a smaller value than intended. This inaccurate result feeds into the burn budget calculation, potentially causing an improper amount of excess Liquidity Extension balance to be used and even depleted to zero.

WatchPug Follow

Originally disclosed on Code4rena

Submitted by WatchPug

https://github.com/code-423n4/2021-11-malt/blob/c3a204a2c0f7c653c6c2dda9f4563fd1dc1cecf3/src/contracts/AuctionBurnReserveSkew.sol#L116-L132

  function getPegDeltaFrequency() public view returns (uint256) {
    uint256 initialIndex = 0;
    uint256 index;

    if (count > auctionAverageLookback) {
      initialIndex = count - auctionAverageLookback;
    }

    uint256 total = 0;

    for (uint256 i = initialIndex; i < count; ++i) {
      index = _getIndexOfObservation(i);
      total = total + pegObservations[index];
    }

    return total * 10000 / auctionAverageLookback;
  }

When count < auctionAverageLookback, at L131, it should be return total * 10000 / count;. The current implementation will return a smaller value than expected.

The result of getPegDeltaFrequency() will be used for calculating realBurnBudget for auctions. With the result of getPegDeltaFrequency() being inaccurate, can result in an improper amount of excess Liquidity Extension balance to be used at the end of an auction.

0xScotch (sponsor) confirmed and disagreed with severity:

I actually think this should be higher severity. This bug could manifest in liquidity extension being depleted to zero which could have catastrophic consequences downstream.

Alex the Entreprenerd (judge) commented:

Agree with the finding, this is an incorrect logic in the protocol, which can limit it’s functionality and as the sponsor says: could have catastrophic consequences downstream as such I’ll increase the severity to high.

Mitigation seems to be straightforward

The original report as published on Code4rena, by WatchPug. 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

The function always divides by auctionAverageLookback instead of the actual number of observations when count is less than auctionAverageLookback.

Impact

The incorrect value could cause an improper amount of excess Liquidity Extension balance to be used, potentially depleting it to zero with catastrophic downstream consequences.

What the attacker needed

Count < auctionAverageLookback

The fix

The function should divide by count instead of auctionAverageLookback when count is less than auctionAverageLookback.

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 function calculates an average but divides by the wrong number when there are not enough data points. That makes the average too small, which then causes the auction to use too much of a reserve fund, possibly emptying it.

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 WatchPug

View all

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