Skip to content
Business logic Audit finding Beginner

Missing "reward" Parameter in "Staked" Event Breaks Off-Chain Accounting

The Staked event emitted by the staking contract records the deposited amount but not the reward calculated at stake time. Off-chain indexers that rebuild the reward from current period parameters can therefore show a figure that differs from the value actually stored on-chain.

Oxb4b Follow

Originally disclosed on Immunefi

Informational View original
  • Disclosed after under an hour

68880 sc insight missing reward parameter in staked event breaks off chain accounting

Submitted on Mar 11th 2026 at 19:35:35 UTC by @Oxb4b for Audit Comp | Folks Finance: Staking Contracts

Description

Brief/Intro

The Staked event emits the deposited amount but omits the calculated reward value. This creates an observability gap where off-chain systems (indexers, dashboards, analytics) cannot accurately reconstruct user rewards from event logs alone. When staking period parameters are updated between stake execution and off-chain processing, the reconstructed reward will differ from the actual on-chain value, leading to incorrect accounting and user-facing data.

Vulnerability Details

Affected Code: Staking.sol, _stake() function

Current Implementation:

Solidity
// Reward calculated using CURRENT period parameters
uint256 reward = (amount * stakingPeriod.aprBps * stakingPeriod.stakingDurationSeconds) / rewardBpsDenominator;

// Reward stored immutably in UserStake
userStakes[msg.sender].push(
    UserStake({
        amount: amount,
        reward: reward,  // ← Stored on-chain
        claimedAmount: 0,
        claimedReward: 0,
        aprBps: stakingPeriod.aprBps,
        stakeTime: uint64(block.timestamp),
        unlockTime: uint64(block.timestamp) + stakingPeriod.stakingDurationSeconds,
        unlockDuration: stakingPeriod.unlockDurationSeconds
    })
);

// Event emission WITHOUT reward
emit Staked(msg.sender, periodIndex, params.referrer, stakeIndex, amount);
//                                                                 ^^^^^^
//                                                                 Missing: reward

Root Cause:
The Staked event signature (defined in IStakingV1.sol) is:

Solidity
event Staked(
    address indexed user,
    uint8 indexed periodIndex,
    address indexed referrer,
    uint8 stakeIndex,
    uint256 amount
    // Missing: uint256 reward
);

Attack Path / Observability Failure Scenario:

  1. T₀: User stakes 10 ETH with Period 0 (APR = 50%, duration = 30 days)
    • On-chain: reward = 10 * 5000 * 30 days / (1e4 * 365 days) ≈ 0.4109 ETH stored in UserStake
    • Event emitted: Staked(user, 0, referrer, 0, 10 ether) — no reward field
  2. T₁: Manager updates Period 0 parameters (legitimate governance action)
    • Period 0 APR changed from 50% → 10%
    • StakingPeriodUpdated event emitted
  3. T₂: Off-chain indexer processes Staked event from T₀
    • Indexer reads current Period 0 parameters via RPC: aprBps = 1000 (10%)
    • Indexer reconstructs: reward = 10 * 1000 * 30 days / (1e4 * 365 days) ≈ 0.0821 ETH
    • Discrepancy: 0.0821 ETH (reconstructed) vs 0.4109 ETH (actual) — 80% error
  4. Impact: User dashboard shows incorrect reward, audit trails fail, accounting mismatch

Impact and Likelihood Details

Impact: Low — No on-chain funds at risk, no user loss, no exploitable attack vector

Affected Systems:

  • Off-chain indexers (TheGraph subgraphs, custom backends)
  • User-facing dashboards showing staking positions
  • Analytics platforms tracking protocol metrics
  • Accounting/audit systems reconciling rewards
  • Mobile/light clients unable to make RPC calls

Likelihood: High — Occurs whenever:

  • Staking periods are updated (routine governance operation)
  • Network congestion delays event processing
  • Indexer catches up on historical events after period updates

Link to Proof of Concept

https://gist.github.com/tharunbethina/497b3263c659393a585118e2dbf2c74c

Proof of Concept

  1. User stakes 10 ETH in Period 0 (50% APR, 30-day duration)
  2. On-chain reward calculated and stored: 0.4109 ETH
  3. Manager updates Period 0 APR to 10% (legitimate governance)
  4. Off-chain indexer reconstructs reward from event data: 0.0821 ETH (uses updated APR)
  5. Assertion: reconstructedReward ≠ actualReward → 80% discrepancy

Foundry Testcase gist:

https://gist.github.com/tharunbethina/497b3263c659393a585118e2dbf2c74c

The original report as published on Immunefi, by Oxb4b. 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

The Staked event signature does not include the reward value, so the reward stored in the user's stake record cannot be recovered from the log alone.

Impact

No on-chain funds are at risk; the effect is limited to off-chain dashboards, indexers and audit trails showing rewards that differ from the stored values.

What the attacker needed

Staking period parameters are later updated; off-chain system relies on event logs

The fix

The event should be extended to include the calculated reward so that logs alone are sufficient to reconstruct the stored value.

How it was found

  1. A user stakes an amount in a staking period, and the reward is calculated and stored on-chain.
  2. A manager later updates that period's parameters, such as the APR.
  3. An off-chain indexer processes the earlier Staked event and reads the current period parameters.
  4. The indexer reconstructs a reward that differs from the stored on-chain value.

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 smart contract can announce what happened by writing an 'event', a log entry that outside software reads. Here the announcement left out the reward figure, so a dashboard has to guess it from the contract's current settings, which can change later. The guess can then be wrong even though nothing on-chain is broken.

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 Oxb4b

View all

6 more disclosed reports, best first.

More from Folks Finance: Staking Contracts

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.