Potential incorrect index update in revived gauge under specific conditions #4
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
M-06
🤖_primary
AI based primary recommendation
🤖_04_group
AI based duplicate group recommendation
satisfactory
satisfies C4 submission criteria; eligible for awards
selected for report
This submission will be included/highlighted in the audit report
sponsor acknowledged
Technically the issue is correct, but we're not going to resolve it for XYZ reasons
Lines of code
https://github.com/code-423n4/2024-09-fenix-finance/blob/main/contracts/core/VoterUpgradeableV2.sol#L250-L256
Vulnerability details
Impact
This vulnerability could allow revived gauges to claim more rewards than intended under specific circumstances, potentially leading to unfair distribution of rewards.
Description
The
reviveGauge
function fails to update the gauge's index to the current global index when reviving a previously killed gauge. While this issue is mitigated in most scenarios by thedistributeAll
function, which updates all gauges' indices to the global index on each epoch, a vulnerability still exists under specific conditions.Relevant code snippet:
The vulnerability arises in scenarios where:
distributeAll
cannot update all gauges in a single transaction.distribute
function for a killed gauge.In this specific scenario, a revived gauge could retain an outdated index, leading to incorrect reward calculations.
Example scenario
Epoch x:
Epoch x+1:
distributeAll
fails to update all gauges due to gas limitationsEpoch x+2:
When claiming rewards:
Gauge A claims excess rewards for the period it was killed. This discrepancy, while rare, could lead to unfair reward distribution for all gauges.
Rationale on severity
High impact - Lead to loss of funds of other gauges.
Low likelihood - Only happen in specific circumstances.
Hence, Medium severity.
Proof-of-Concept
The following test tries to demonstrate described scenario where GaugeA is killed and due to specific circumstance doesn't get update before being revived.
Steps
reviveGaugeBug.ts
intest/core/VoterV2/
npx hardhat test test/core/VoterV2/reviveGaugeBug.ts --grep "reviveGaugeDoesNotUpdateToGlobalIndex" --trace
Recommended Mitigations
Assessed type
Context
The text was updated successfully, but these errors were encountered: