Skip to content
DoS Audit finding Intermediate

DoS on KeeperGauge due to division by zero

The KeeperGauge contract's claim functions divide by perPeriodTotalFees[i] without checking for zero, so if an epoch has no fees, a division by zero reverts and blocks all reward claims. An attacker or normal operation could trigger this by advancing or killing an epoch without fees, causing a denial of service until fees are reported.

fatherOfBlocks Follow

Originally disclosed on Code4rena

Submitted by fatherOfBlocks

In the _calcTotalClaimable() function it should be validated that perPeriodTotalFees[i] != 0 since otherwise it would generate a DoS in claimableRewards() and claimRewards(). This would be possible since if advanceEpoch() or kill() is executed by the InflationManager address, the epoch will go up without perPeriodTotalFees[newIndexEpoch] is 0. The negative of this is that every time the InflationManager executes these two methods (kill() and advanceEpoch()) DoS is generated until you run reportFees(). Another possible case is that kill() or advanceEpoch() are executed 2 times in a row and there is no way of a perPeriodTotalFees[epoch-1] updating its value, therefore it would be an irreversible DoS.

Recommended Mitigation Steps

Generate a behavior for the case that perPeriodTotalFees[i] == 0.

samwerner (Backd) confirmed, but disagreed with severity

Alex the Entreprenerd (judge) commented:

The finding at face value is valid and it’s impact is a DOS.

A division by zero in keeperRecords[beneficiary].feesInPeriod[i].scaledDiv(perPeriodTotalFees[i]), will cause an instantaneous revert making it impossible to claim fees.

After more reading I believe that the finding is valid and can cause issues if there’s one epoch without fees, if for any reason the protocol skips one epoch via advanceEpoch, while no perPeriodTotalFees are increased, then, because keeperRecords(beneficiary).nextEpochToClaim will include the empty epoch, the beneficiary will not be able to receive fees.

Given that setup is necessary for this to happen, I believe Medium Severity to be more appropriate.


The original report as published on Code4rena, by fatherOfBlocks. 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 calcTotalClaimable() function does not validate that perPeriodTotalFees[i] is non-zero before using it as a divisor.

Impact

The division by zero causes an instantaneous revert, making it impossible to claim fees; if two epochs are advanced in a row without fees, the denial of service could be irreversible.

What the attacker needed

InflationManager calls advanceEpoch or kill; No fees reported for the new epoch

The fix

The contract should handle the case where perPeriodTotalFees[i] is zero, for example by skipping the division or returning zero.

How it was found

  1. The InflationManager calls advanceEpoch() or kill(), increasing the epoch without setting perPeriodTotalFees for the new epoch.
  2. The new epoch has perPeriodTotalFees equal to zero.
  3. A beneficiary calls claimableRewards() or claimRewards().
  4. The function calcTotalClaimable() divides by perPeriodTotalFees[i], which is zero, causing a revert.
  5. The revert blocks the claim until reportFees() is called to set a non-zero value.

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 calculation divides by a number that can be zero. In Ethereum, dividing by zero makes the transaction fail and revert, so users cannot claim their rewards. The problem happens when an epoch (a time period) has no fees recorded, but the system still tries to divide by that zero total.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More by fatherOfBlocks

View all

3 more disclosed reports, best first.

More from Backd Tokenomics contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.