Reproduced Exploit
Magic Yearn MyStaking: stake stores claimable rewards twice
Chain
Other
Category
logic
Date
Aug 2022
Source
AuditVault
EVM Playground
Source-level debugger — step opcodes and Solidity in sync
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.
Source & credit. Reproduction of a public audit finding curated by AuditVault — the original finding: 57532-incorrect-storage-of-user-rewards-during-staking-in-mystakin. Standalone Foundry PoC and full write-up: 57532-incorrect-storage-of-user-rewards-during-staking-in-mystakin_exp in the
evm-hack-registrymirror.
Vulnerability classes: vuln/logic/reward-calculation
Reproduction: faithful local reproduction of AuditVault 57532.
claimableAmountalready addsunclaimedAmount, andstakeadds that total back ontounclaimedAmount.
Root cause#
claimableAmount returns fresh accrual plus unclaimedAmount. stake then does unclaimedAmount += claimable. The stored rewards are counted twice.
uint256 claimable = claimableAmount(msg.sender);
// @> VULN: claimable already includes unclaimedAmount, so this doubles it
u.unclaimedAmount += claimable;
Two equal stakers share a 2,000 RWD pool, 1,000 each. The attacker's second stake(0) turns a stored 1,000 into 2,000. Their claim empties the pool.
Attack path#
Impact#
The attacker is paid 2,000 RWD. The other staker is paid 0. 1,000 RWD of that payout is the victim's share and is forwarded to the sink. The fixed stake adds only the fresh accrual, and each staker claims 1,000 RWD.
PoC#
cd 57532-incorrect-storage-of-user-rewards-during-staking-in-mystakin_exp
forge test -vv
Sources#
- AuditVault finding 57532
- Zokyo, Magic Yearn, 2022-08-17: https://github.com/solodit/solodit_content/blob/main/reports/Zokyo/2022-08-17-Magic%20Yearn.md
Sources & further analysis#
Reproductions & code
- Standalone PoC + full trace: 57532-incorrect-storage-of-user-rewards-during-staking-in-mystakin_exp (evm-hack-registry mirror).
- AuditVault finding: 57532-incorrect-storage-of-user-rewards-during-staking-in-mystakin.
Alerts & third-party analyses
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.