Reproduced Exploit

Surge — [H-03] Unstake causes all users to lose their rewards

1. User and attacker each stake 1000 into cycle 1 (total shares = 2000). 2. Rewards are injected for the cycle. 3. Attacker unstakes; _unstake reads total pool shares and subtracts that from itself → 0. 4. User's claimRewardsToOwed sees total = 0 and pays nothing. Rewards wiped for everyone.

Jan 2025Otheruntagged2 min read

Chain

Other

Category

untagged

Date

Jan 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. No backend, no live RPC.

Loading fork state…

Source & credit. Reproduction of a public audit finding curated by AuditVault — the original finding: 55142-unstake-causes-all-users-to-lose-rewards. Standalone Foundry PoC and full write-up: 55142-unstake-causes-all-users-to-lose-rewards_exp in the evm-hack-registry mirror.


Vulnerability classes: reward-calculation · reward-theft · reward-accounting

Reproduction: self-contained Foundry PoC with only forge-std — no fork. output.txt · test/55142-…_exp.sol.

AuditVault taxonomy: lang/solidity · platform/shieldify · severity/high · genome: reward-calculation · reward-theft · reward-accounting


Key info#

ImpactHIGH — a single unstake zeroes the cycle's total reward-pool shares; all users lose rewards
ProtocolSurge — StakingVault._unstake
Vulnerable codeshares = _rewardPoolShares[poolId][cycleId] then -= shares (subtracts the total)
Bug classWrong variable — total vs personal shares
FindingShieldify Security — Surge · #55142
ReportSurge-Security-Review.md
SourceAuditVault
FixSubtract the unstaking user's personal share amount only
Compiler^0.8.24 (PoC)

TL;DR#

  1. User and attacker each stake 1000 into cycle 1 (total shares = 2000).
  2. Rewards are injected for the cycle.
  3. Attacker unstakes; _unstake reads total pool shares and subtracts that from itself → 0.
  4. User's claimRewardsToOwed sees total = 0 and pays nothing. Rewards wiped for everyone.

Vulnerable code#

SOLIDITY
function _unstake(address user) internal {
    uint256 shares = rewardPoolShares[poolId][cycleId]; // @> VULN: total, not user
    // FIX: uint256 shares = userShares[user][poolId];
    rewardPoolShares[poolId][cycleId] -= shares; // zeroes the cycle
}

Diagrams#

flowchart TD A["User + attacker stake 1000 each"] --> B["rewardPoolShares cycle1 = 2000"] B --> C["Attacker unstake"] C --> D["shares = total 2000"] D --> E["total -= 2000 → 0"] E --> F["User claimRewards"] F --> G{"total == 0?"} G -->|yes| H["reward = 0 for all users"]

Impact#

Any unstake permanently destroys reward accounting for the affected cycle(s); remaining stakers cannot claim their fair share.

Sources#


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.