Reproduced Exploit

Streaming — recoverTokens steals rewards when depositToken == rewardToken

When deposit and reward tokens are the same, recoverTokens' deposit excess formula includes the reward inventory and the creator drains user rewards

Nov 2021Otheraccounting2 min read

Chain

Other

Category

accounting

Date

Nov 2021

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: 42394-h-02-tokens-can-be-stolen-when-deposittoken-rewardtoken-code. Standalone Foundry PoC and full write-up: 42394-h-02-tokens-can-be-stolen-when-deposittoken-rewardtoken-code_exp in the evm-hack-registry mirror.


Vulnerability classes: vuln/accounting/same-token-double-count · vuln/access-control/privileged-drain

Reproduction: a self-contained Foundry PoC that compiles & runs in an isolated project with only forge-std — no fork, no RPC, no anvil_state. Full trace: output.txt. PoC: test/42394-h-02-tokens-can-be-stolen-when-deposittoken-rewardtoken-code_exp.sol.

AuditVault taxonomy: lang/solidity · sector/token · platform/code4rena · severity/high · genome: wrong-condition · direct-drain · reward-accounting


Key info#

ImpactHIGH — When deposit and reward tokens are the same, recoverTokens' deposit excess formula includes the reward inventory and the creator drains user rewards
ProtocolStreaming Protocol
FindingCode4rena — Streaming Protocol, 2021-11 · #42394
Report2021-11-streaming
SourceAuditVault
StatusAudit finding — reproduced as a standalone local synthetic PoC.
Compiler^0.8.24 (PoC)

TL;DR#

When deposit and reward tokens are the same, recoverTokens' deposit excess formula includes the reward inventory and the creator drains user rewards

See the vulnerable line marked // @> VULN in test/42394-h-02-tokens-can-be-stolen-when-deposittoken-rewardtoken-code.sol and the end-to-end Exploit.run() that asserts the harm.


Diagrams#

flowchart TD A[Setup vulnerable state] --> B[Attacker triggers vulnerable path] B --> C["Vulnerable line executes @> VULN"] C --> D[Harm asserted in run]

Impact#

When deposit and reward tokens are the same, recoverTokens' deposit excess formula includes the reward inventory and the creator drains user rewards


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.