Reproduced Exploit

Regnum Aurum: updateUserRewards adds stored rewards on top of themselves and one staker takes the whole pool

_calculatePendingRewards returns storedRewards + userShare. updateUserRewards then does rewards += pending. The first call, with nothing stored, books the fair 100. The index is checkpointed, so the next share is 0, but the helper still returns the stored 100. The second call makes rewards 200. The…

May 2025•Ethereum•logic•3 min read

Loss

200 reward tokens claimed from a 100 accrual. The other staker's 100 is booked against an empty gauge

Chain

Ethereum

Category

logic

Date

May 2025

Source

AuditVault

EVM Playground

Source-level debugger — step opcodes and Solidity in sync

evm-hack-analyzer

The attack is replayed in an in-browser EVM preloaded with the exact dumped fork state. The execution tree shows every call; step by Solidity line or by opcode across all depths — source, Stack, Memory, Storage, Balances (native / ERC-20 / NFT), Transient storage and Return value stay in sync. Click a tree node, opcode, or source line to jump. Query opens a search over the trace: previous and next writes, balance changes and calls, breakpoints, and a diff of everything that changed between two steps. No backend, no live RPC.

Loading fork state…

Source & credit. Reproduction of a public audit finding curated by AuditVault — the original finding: 66159-c-05-double-counting-stored-rewards-causes-reward-inflation. Standalone Foundry PoC and full write-up: 66159-c-05-double-counting-stored-rewards-causes-reward-inflation_exp in the evm-hack-registry mirror.


Vulnerability classes: vuln/logic/reward-calculation · vuln/logic/state-update

Key info#

FieldValue
Loss200 reward tokens claimed from a 100 accrual. The other staker's 100 is booked against an empty gauge
Vulnerable contractBaseGauge._calculatePendingRewards
Attacker EOA0x1111111111111111111111111111111111111111
Attack contractExploit
Attack txExploit.run()
Chain / block / dateEthereum model · block 0 · 2025-05
Compilersolc 0.8.27, cancun, via IR
Bug classPending rewards include the stored balance, and the caller adds that sum onto the stored balance again

TL;DR#

_calculatePendingRewards returns storedRewards + userShare. updateUserRewards then does rewards += pending. The first call, with nothing stored, books the fair 100. The index is checkpointed, so the next share is 0, but the helper still returns the stored 100. The second call makes rewards 200. The third makes them 400. claimRewards pays the gauge's entire 200 balance. The other staker is still booked for 100 and the contract is empty. Returning only the new share pays 100 and leaves 100.

Background#

Pashov Audit Group's Regnum Aurum review dated 2025-05-06, finding C-05. The report walks the same helper: a stored balance of 100 is returned again and added, then 200 is returned and added, doubling on every call. The published test drains the notified reward after three updateUserRewards calls.

The vulnerable code#

SOLIDITY
function _calculatePendingRewards(address token, address user) internal view returns (uint256) {
    uint256 storedRewards = rewards[token][user];
    uint256 userShare = _pendingShare(token, user);
    // @> VULN: pending already contains storedRewards, and the caller adds it onto rewards again
    return storedRewards + userShare;
}

The caller is:

SOLIDITY
uint256 pending = _calculatePendingRewards(token, msg.sender);
if (pending > 0) {
    rewards[token][msg.sender] += pending;
    userRewardPerTokenPaid[token][msg.sender] = rewardPerTokenStored[token];
}

Root cause#

The helper's return value is a total, not a delta. Adding a total onto the same storage word counts the old balance twice. After the paid index catches up, userShare is 0 and each later call still adds the whole stored balance.

Preconditions#

  • The caller has a 100 stake and an unpaid index gap of 1e18, so the new share is 100. Stored rewards start at 0.
  • Another account already has 100 stored and is checkpointed, so they accrue nothing new.
  • The gauge holds 200 reward tokens, 100 for each account.

Attack walkthrough#

  1. The first updateUserRewards reads stored rewards of 0 and returns 100. Rewards become 100 and the index is checkpointed.
  2. The second call returns 100 plus a zero share. Rewards become 200.
  3. The third call returns 200. Rewards become 400. No time passes between the calls.
  4. claimRewards caps the payout at the 200 token balance and transfers all of it.
  5. The other account is still booked for 100. The gauge balance is 0.
  6. The control adds only _pendingShare. Three updates still book 100. The claim pays 100 and leaves 100.

Diagrams#

flowchart TD A["Unpaid share is 100 and stored rewards are 0"] --> B["First update books 100 and checkpoints the index"] B --> C["VULN: the next pending value is the stored 100 plus a zero share"] C --> D["Second update stores 200 and the third stores 400"] D --> E["claimRewards pays the gauge balance of 200"] E --> F["The other staker is still owed 100 against an empty gauge"]

Sources & further analysis#

Reproductions & code

Alerts & third-party analyses

  • Web3Sec X hacked database: search.
  • Rekt leaderboard: search.
  • Solodit incident search: search.

These dashboards index community alerts tweets, post-mortems, and independent write-ups. Reach them through the protocol name above to cross-check this reproduction against other analyses.