Finding: Division by Zero Risk in _updateWeights Due to Unchecked duration Parameter
Issue Summary
The _updateWeights function retrieves duration from getPeriodDuration(), which is then used as a divisor in:
If duration is zero, the division operation will revert, causing the transaction to fail.
Potential Vulnerability
Division by Zero
If getPeriodDuration() returns 0, the division currentTime / duration triggers an error, halting execution.
This could prevent weight updates, disrupt reward calculations, or halt time-based logic in the protocol.
Impact: High
Critical Functionality Disruption: A revert halts execution, preventing updates to time-weighted averages.
System-Wide Failure: If _updateWeights is crucial for periodic updates, it could break reward mechanisms or governance systems.
Likelihood: Medium
If getPeriodDuration() is guaranteed to return nonzero values, this risk is low.
However, uninitialized variables, incorrect configurations, or malicious input could set it to zero.
Proof of Concept (PoC)
getPeriodDuration() unexpectedly returns 0 (due to misconfiguration or contract state reset).
_updateWeights() executes:
Transaction reverts, preventing weight updates.
Recommended Fix
Check for Zero Before Division
Modify _updateWeights to validate duration:
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.