Skip to content
Business logic Audit finding Intermediate

Reducing the epoch length results in leaking value from advancement incentives

The smart contract calculates the start time of the next epoch using the current epoch length and the genesis timestamp, without accounting for past changes to the epoch length. If the epoch length is reduced, the contract may believe that many epochs have already passed, allowing an attacker to call the advance function repeatedly and collect incentives for each advancement.

TomFrench Follow

Originally disclosed on Code4rena

Submitted by TomFrench

Unintended advancement incentives being paid out to third party

Proof of Concept

DAO.sol incentives outside parties to advance the epoch by minting 100 MALT tokens for calling the advance function. This is limited by checking that the start timestamp of the next epoch has passed.

https://github.com/code-423n4/2021-11-malt/blob/d3f6a57ba6694b47389b16d9d0a36a956c5e6a94/src/contracts/DAO.sol#L55-L63

This start timestamp is calculated by multiplying the new epoch number by the length of an epoch and adding it to the genesis timestamp.

https://github.com/code-423n4/2021-11-malt/blob/d3f6a57ba6694b47389b16d9d0a36a956c5e6a94/src/contracts/DAO.sol#L65-L67

This method makes no accommodation for the fact that previous epochs may have been set to be a different length to what they are currently.

https://github.com/code-423n4/2021-11-malt/blob/d3f6a57ba6694b47389b16d9d0a36a956c5e6a94/src/contracts/DAO.sol#L111-L114

In the case where the epoch length is reduced, DAO will think that the epoch number can be incremented potentially many times. Provided the advanceIncentive is worth more than the gas necessary to advance the epoch will be rapidly advanced potentially many times paying out unnecessary incentives.

Recommended Mitigation Steps

Rather than calculating from the genesis timestamp, store the last time that the epoch length was modified and calculate from there.

0xScotch (sponsor) confirmed

Alex the Entreprenerd (judge) commented:

Given a specific epoch length, the system will be able to determine which incentives to pay out. Because the math for calculating the next epoch is based on the initial time, changing the epochLength can cause unintended consequences and allow for further calls to advance with the goal of receiving more caller incentives.

The exploit can be triggered by admin privileges (changing epochLength), and because it’s a leak of value, I agree with medium severity

The original report as published on Code4rena, by TomFrench. 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 contract calculates the next epoch's start time from the genesis timestamp and the current epoch length, ignoring that the epoch length may have been different in the past.

Impact

If the advancement incentive exceeds the gas cost, an attacker could repeatedly advance the epoch and drain the incentive pool, leaking value from the protocol.

What the attacker needed

Admin reduces epoch length; advanceIncentive > gas cost

The fix

The contract should store the last time the epoch length was modified and calculate the next epoch start from that point instead of from the genesis timestamp.

How it was found

  1. The administrator reduces the epoch length.
  2. The contract's calculation of the next epoch start time becomes incorrect, indicating that many epochs have already passed.
  3. An attacker calls the advance function repeatedly to advance the epoch multiple times.
  4. The attacker receives the advancement incentive for each call.

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 pays a reward to anyone who calls a function to move to the next time period (epoch). The contract decides if it's time to move by multiplying the current epoch length by the epoch number and adding a starting timestamp. If the epoch length is later reduced, the calculation makes it seem like many epochs are already overdue, so the reward can be claimed many times in a row.

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