# DoS on KeeperGauge due to division by zero

KeeperGauge divides by perPeriodTotalFees[i] which can be zero after advanceEpoch/kill, reverting claimableRewards and claimRewards and blocking fee claims.

- Payout: Contest reward
- Severity: medium
- Program: Backd
- Credited: fatherOfBlocks
- Disclosed: 2022-07-19
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2022-05-backd-findings/issues/35
- Library page: https://bugbountylibrary.com/r/c4%3A2022-05-backd%3AM-01
- Tags: domain:web3 impact:dos kind:contest platform:code4rena sev:medium tech:solidity technique:source-review vuln:dos

**Target:** KeeperGauge tokenomics contract (claimableRewards/claimRewards)
**Root cause:** _calcTotalClaimable divides feesInPeriod[i] by perPeriodTotalFees[i] without checking it is nonzero; advanceEpoch()/kill() can advance the epoch while perPeriodTotalFees[newIndexEpoch] stays 0.
**Steps:**
1. InflationManager calls advanceEpoch() or kill(), incrementing epoch without reportFees() populating perPeriodTotalFees[newIndexEpoch].
2. keeperRecords[beneficiary].nextEpochToClaim now includes the empty epoch.
3. Call claimableRewards() or claimRewards(); _calcTotalClaimable executes feesInPeriod[i].scaledDiv(perPeriodTotalFees[i]) with divisor 0.
4. Transaction reverts, blocking all fee claims until reportFees() runs; two consecutive advances make it irreversible.
**How found:** Code reading of _calcTotalClaimable and the epoch-advance path, noticing perPeriodTotalFees[newIndexEpoch] is not guaranteed nonzero when the epoch increments.
**Exploitation:** Requires InflationManager to advance an epoch with no fees reported; the zero divisor causes an instantaneous revert in scaledDiv, denying fee claims to all beneficiaries for that epoch.
**Escalation:** Two consecutive advanceEpoch()/kill() calls with no perPeriodTotalFees update make the DoS irreversible.
**Insight:** When a divisor is an epoch-indexed accumulator, check whether epoch advancement can outpace accumulator population; an empty period leaves a zero divisor that bricks all claims referencing that epoch.
