Reproduced Exploit

GammaSwap: disburseClaims pays a new period with the previous period's unclaimed tokens

disburseClaims sets totalClaimable[period] to the vault's entire token balance. That balance still holds rewards users have not claimed. Period-3 claimants are paid from Alice's period-2 balance. Bob's fair share of the new 500 is 100; he receives 300. Carol receives 1200. Alice's later claim pays…

Dec 2024•Other•logic•3 min read

Loss

Alice's unclaimed 1000 GS is paid to period 3. Bob, entitled to 100, receives 300

Chain

Other

Category

logic

Date

Dec 2024

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: 45529-c-01-disburseclaims-allows-theft-of-unclaimed-funds-pashov-a. Standalone Foundry PoC and full write-up: 45529-c-01-disburseclaims-allows-theft-of-unclaimed-funds-pashov-a_exp in the evm-hack-registry mirror.


Vulnerability classes: vuln/logic/state-update

Key info#

FieldValue
LossAlice's unclaimed 1000 GS is paid to period 3. Bob, entitled to 100, receives 300
Vulnerable contractFundingVault.disburseClaims
Attacker EOA0x1111111111111111111111111111111111111111
Attack contractExploit (Bob)
Attack txExploit.run()
Chain / block / dateLocal synthetic · 2024-12
Compilersolc 0.8.27, cancun, via IR
Bug classCurrent-period claimable amount is the whole token balance

TL;DR#

disburseClaims sets totalClaimable[period] to the vault's entire token balance. That balance still holds rewards users have not claimed. Period-3 claimants are paid from Alice's period-2 balance. Bob's fair share of the new 500 is 100; he receives 300. Carol receives 1200. Alice's later claim pays 0.

The vulnerable code#

SOLIDITY
totalClaimable[_period] = GammaSwapLibrary.balanceOf(claimToken, address(this)); // @> VULN
_claimable = GSMath.min(GammaSwapLibrary.balanceOf(claimToken, address(this)), _claimable);
GammaSwapLibrary.safeTransfer(claimToken, _to, _claimable);

The report's fix passes the new amount in as an argument instead of reading the live balance. disburseClaimsFixed(500) pays Bob 100, Carol 400, and still leaves Alice her 1000.

Root cause#

The vault keeps unclaimed rewards in the same token balance as the next period's funding. Booking that whole balance to the new period lets the new period's weights spend the old period's tokens.

Preconditions#

  • Period 2 was disbursed for 1000 GS and Alice (weight 1000 of 1000) has not claimed.
  • Period 3 is funded with 500 GS. Bob's weight is 100 and Carol's is 400, out of 500.
  • The manager calls disburseClaims with no separate new-amount argument.

Attack walkthrough#

  1. After period 2, the vault holds Alice's 1000. Period 3 adds 500. Balance is 1500.
  2. disburseClaims stores 1500 as totalClaimable[3].
  3. Bob claims 1500 * 100 / 500 = 300.
  4. Carol claims 1500 * 400 / 500 = 1200. The vault is empty.
  5. Alice's period-2 claim is capped by min(balance, 1000) and pays 0.

Diagrams#

flowchart TD A["Alice is owed 1000 and has not claimed"] --> B["500 new rewards arrive and the balance is 1500"] B --> C["disburseClaims stores 1500 as period 3 claimable"] C --> D["Bob takes 300 and Carol takes 1200"] D --> E["Alice's period 2 claim pays 0"]

Impact#

Unclaimed rewards are stolen by the next period's claimants. In this run the stolen amount is Alice's full 1000 GS. Bob's personal take is 300 instead of 100, which is the profit the Playground records.

How to reproduce#

BASH
cd 45529-c-01-disburseclaims-allows-theft-of-unclaimed-funds-pashov-a_exp
forge test -vv

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.