Skip to content
Business logic Audit finding Intermediate

Early Reward Accrual Undermines Validator Group Performance Incentives

The EpochManager contract lets anyone call setToProcessGroups() right after an epoch starts, which locks in each validator group's rewards based on its score at that moment. A group could then underperform or plan to leave for the rest of the epoch without losing rewards, weakening the performance incentives.

jovi Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

#37391 [SC-High] Early Reward Accrual Undermines Validator Group Performance Incentives

Submitted on Dec 3rd 2024 at 18:24:38 UTC by @jovi for Audit Comp | Celo

Description

Vulnerability Details

The EpochManager contract allows for premature accrual of epoch rewards, potentially undermining the incentive structure designed to maintain high-quality validator performance throughout an epoch. Due to the lack of restrictions on when setToProcessGroups() can be called within an epoch. This function, which calculates and locks in rewards based on the current group score, can be invoked immediately after a new epoch starts. The key issues are:

  1. No Cooldown Period: Unlike starting a new epoch, there's no enforced cooldown or waiting period for calling setToProcessGroups(). This allows for premature reward accrual.
  2. Reward Calculation Timing: Rewards are calculated based on the group's score at the time setToProcessGroups() is called, which can be at the very beginning of an epoch.
  3. Misaligned Incentives: Once rewards are calculated and locked in, a group's performance for the remainder of the epoch becomes irrelevant to their rewards for that epoch.
  4. Potential for Exploitation: Groups intending to leave or underperform can exploit this by ensuring setToProcessGroups() is called early, then behaving poorly for the rest of the epoch without financial consequences.

The relevant code snippet from EpochManager.sol:

Solidity
function setToProcessGroups() external {
    require(isOnEpochProcess(), "Epoch process is not started");
}

This function can be called by anyone, at any time during an epoch, as long as the epoch process has started. The lack of additional timing constraints allows for the described vulnerability.

Impact

This vulnerability could lead to:

  1. Reduced validator performance and network security
  2. Misaligned incentives for validator groups
  3. Potential exploitation by groups planning to quit or underperform

Proof of Concept

Proof of Concept

The following proof of concept rely mainly on executing function calls at specific periods and the vulnerability lies on the context in which those calls are invoked. Furthermore, all the functions involved are permissionless and only have epoch statuses/timing to fulfill. For this reason, I have opted to avoid making a coded POC as such is already available at the EpochManager contract tests at EpochManager.t.sol and the most important aspect of this submission is the semantical repercussions for the governance process.

  1. An epoch begins with startNextEpochProcess().
  2. Immediately after, anyone can call setToProcessGroups(). Which will in turn calculate the epoch rewards for a group based on the group's score:
Solidity
 function setToProcessGroups() external {
    require(isOnEpochProcess(), "Epoch process is not started");
...
      if (processedGroups[group] == 0) {
        ...
        uint256 groupScore = scoreReader.getGroupScore(group);
        // We need to precompute epoch rewards for each group since computation depends on total active votes for all groups.
        uint256 epochRewards = election.getGroupEpochRewardsBasedOnScore(
          group,
          _epochProcessing.totalRewardsVoter,
          groupScore
        );
        processedGroups[group] = epochRewards == 0 ? type(uint256).max : epochRewards;
      }
    }
  }
  1. This locks in rewards based on the group's score at that specific moment of the epoch.
  2. The group's performance for the rest of the epoch becomes irrelevant to their rewards as it is locked in for the whole duration of the epoch.
  3. The contract will wait till the condition for isTimeForNextEpoch() is fulfilled before beginning a new epoch. In practice, this means a preemptive execution of setToProcessGroups() can make an epoch's rewards be distributed to groups regardless of how well they perform.

The original report as published on Immunefi, by jovi. Images and videos are our own copies; raw HTML is shown as text. View it on Immunefi.

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 setToProcessGroups() function has no timing restriction beyond the epoch process having started, so rewards can be computed and locked in at the very beginning of an epoch.

Impact

Validator groups could underperform or prepare to leave without losing that epoch's rewards, which could reduce validator performance and network security and misalign incentives.

What the attacker needed

Epoch process has started; no special permissions needed

The fix

The contract should enforce a timing constraint or cooldown so that rewards are only calculated after the epoch's performance has actually been measured, rather than at its start.

How it was found

  1. An epoch begins with startNextEpochProcess().
  2. Immediately afterwards, anyone calls setToProcessGroups().
  3. The call calculates and locks in each group's epoch rewards based on its current score.
  4. The group's performance for the rest of the epoch no longer affects its rewards.

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 blockchain network pays validator groups for keeping it running well, and the payment is meant to reflect how well they performed during a period called an epoch. Here the payment is calculated at the very start of the epoch, so a group can get paid for good early behaviour and then stop performing for the rest of the period. That makes the reward system less effective at encouraging good service.

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.

More by jovi

View all

25 more disclosed reports, best first.

More from Celo

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.