Skip to content
Business logic Audit finding Intermediate

Services can earn undeserved rewards by manipulating checkpoint timing during reward droughts

The staking contract skips its checkpoint and activity check whenever no rewards are available, so the last checkpoint timestamp goes stale. A service can stay inactive during that gap and then perform transactions just before rewards return, making its activity ratio look high enough to earn rewards for time it did not serve.

Takarez Follow with Aristos, Avalance and 3 others

Originally disclosed on Code4rena

Submitted by Takarez, also found by Aristos, Avalance, Cecuro, fullstop, and Valves

autonolas-registries/../contracts/staking/StakingBase.sol #L635

A time manipulation vulnerability allows inactive services to earn rewards for periods they provided no service. When availableRewards is zero, checkpoint operations are skipped, creating unmeasured time gaps that services can exploit by becoming active only when rewards become available again.

Vulnerability Details

The checkpoint mechanism in StakingBase.sol#L635 only executes when rewards are available:

if (size > 0 && block.timestamp - tsCheckpointLast >= livenessPeriod && lastAvailableRewards > 0) {
    // Activity checking and reward distribution logic
}

When availableRewards == 0, the global tsCheckpoint timestamp is not updated, creating time measurement gaps. Activity is measured from the last checkpoint timestamp in StakingBase.sol#L650-665:

// Get the last service checkpoint: staking start time or the global checkpoint timestamp
uint256 serviceCheckpoint = tsCheckpointLast;  // Uses stale timestamp when no rewards
uint256 ts = sInfo.tsStart;
if (ts > serviceCheckpoint) {
    serviceCheckpoint = ts;
}

// Calculate activity over the entire gap period
ts = block.timestamp - serviceCheckpoint;
bool ratioPass = _checkRatioPass(sInfo.multisig, sInfo.nonces, ts);

The activity check in StakingActivityChecker.sol#L54-59 calculates the ratio over the entire time period:

if (ts > 0 && curNonces[0] > lastNonces[0]) {
    uint256 ratio = ((curNonces[0] - lastNonces[0]) * 1e18) / ts;
    ratioPass = (ratio >= livenessRatio);
}

This allows services to appear active by executing transactions only at the end of long inactive periods.

Impact

  • Services receive compensation for periods of inactivity

Tools Used

Foundry

Recommended Mitigation

Separate activity tracking from reward distribution by maintaining activity state regardless of reward availability:

function _calculateStakingRewards() internal view returns (...) {
    uint256 tsCheckpointLast = tsCheckpoint;
    lastAvailableRewards = availableRewards;

    // Always track activity regardless of reward availability
    if (size > 0 && block.timestamp - tsCheckpointLast >= livenessPeriod) {
        // Track activity and inactivity
        _updateServiceActivity(serviceIds, tsCheckpointLast);

        // Only distribute rewards if available
        if (lastAvailableRewards > 0) {
            _calculateRewardDistribution(serviceIds, lastAvailableRewards);
        }
    }
}

Proof of Concept

View detailed Proof of Concept


The original report as published on Code4rena, by Takarez. 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 checkpoint condition combines the liveness period with a reward-availability check, so activity is only measured when rewards exist and the stale checkpoint timestamp is used for the next ratio calculation.

Impact

Services could receive compensation for periods of inactivity, though the text does not quantify the loss or show a working exploit.

What the attacker needed

A staking service; a period with no available rewards

The fix

Activity tracking should be separated from reward distribution so activity is always measured, and rewards are only paid when available.

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 staking contract pays services for staying active, and it checks activity at regular checkpoints. If there is no reward money at a checkpoint, the contract skips the check and does not move its clock forward. A service can then do a few transactions right before rewards come back, and the contract divides that small amount of activity by the whole long gap, so it looks active enough to be paid.

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 from Olas

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.