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.
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.
This start timestamp is calculated by multiplying the new epoch number by the length of an epoch and adding it to the genesis timestamp.
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.
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.
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
epochLengthcan cause unintended consequences and allow for further calls toadvancewith 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
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
- The administrator reduces the epoch length.
- The contract's calculation of the next epoch start time becomes incorrect, indicating that many epochs have already passed.
- An attacker calls the advance function repeatedly to advance the epoch multiple times.
- 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.