Reproduced Exploit
Cork — expiry redeem pays RA twice because the withdrawal pool is not debited
redeemExpired takes the excess path when the caller asks for more than userEligible. The inner helper is a view: it prices the excess with raExchangeRate and returns the sum, but it never decreases withdrawalPool.raBalance or paBalance. The vault still transfers the full amount.
Chain
Other
Category
logic
Date
Aug 2024
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. 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.
Source & credit. Reproduction of a public audit finding curated by AuditVault — the original finding: 41480-h-6-users-will-steal-excess-funds-from-the-vault-due-to-vaul. Standalone Foundry PoC and full write-up: 41480-h-6-users-will-steal-excess-funds-from-the-vault-due-to-vaul_exp in the
evm-hack-registrymirror.
Vulnerability classes:
vuln/logic/state-update·vuln/logic/missing-check
Reproduction: a self-contained Foundry PoC that compiles and runs offline with only
forge-std— no fork and no RPC. Trace: output.txt. PoC: test/41480-h-6-users-will-steal-excess-funds-from-the-vault-due-to-vaul_exp.sol.
Key info#
| Impact | HIGH — the caller extracts 2,000 RA from a pool that held 1,000 RA; the next depositor loses the deposit |
| Protocol | Cork, VaultPoolLib.redeem / __tryRedeemExcessFromAmmPool |
| Vulnerable code | excess is added to the payout and raBalance / paBalance are not decreased |
| Bug class | Withdrawal-pool accounting is left stale, then counted again |
| Finding | Sherlock #144 — Cork Protocol, August 2024 · id 41480 |
| Report | Sherlock issue 144 |
| Source | AuditVault finding |
| Compiler | solc 0.8.27, cancun, via IR |
TL;DR#
redeemExpired takes the excess path when the caller asks for more than userEligible. The inner helper is a view: it prices the excess with raExchangeRate and returns the sum, but it never decreases withdrawalPool.raBalance or paBalance. The vault still transfers the full amount.
The next issuance's reserve() still reads that stale balance. A second redeem pays it again out of the new deposit. The caller ends with 2,000 RA. The vault and the victim are at zero, while raBalance still reads 1,000.
The fixed path debits the pool and pays only the 400 RA that was actually requested.
The vulnerable code#
(raOut, paOut) = __tryRedeemfromWithdrawalPool(amountAttributed);
withdrawnFromAmm = (excessAmount * withdrawalPool.raExchangeRate) / 1e18; // @> VULN
raOut += withdrawnFromAmm;
__tryRedeemfromWithdrawalPool is view. Nothing writes raBalance or paBalance.
-(raOut, paOut) = __tryRedeemfromWithdrawalPool(amountAttributed);
+(raOut, paOut) = __redeemfromWithdrawalPool(amountAttributed); // debits raBalance and paBalance
Attack walkthrough#
- The pool holds 1,000 RA. The caller is eligible for 400 and calls
redeemExpired(1000). - The excess of 600 is priced at the 1:1 exchange rate and added to the 400. The vault transfers 1,000 RA.
raBalanceandpaBalanceare still 1,000.- The victim deposits 1,000 RA.
reserve()setsphantomClaimto the staleraBalance. redeemStaletransfers that 1,000. The caller now holds 2,000 RA.
Diagrams#
Impact#
The caller takes the original 1,000 RA and the victim's 1,000 RA. Other withdrawal-pool claims cannot be paid. The vault is insolvent while its own accounting still shows a 1,000 RA balance.
Sources#
- AuditVault 41480
- Sherlock judging issue 144
- Cork contest repo —
VaultPoolLib.__tryRedeemExcessFromAmmPool
Sources & further analysis#
Reproductions & code
- Standalone PoC + full trace: 41480-h-6-users-will-steal-excess-funds-from-the-vault-due-to-vaul_exp (evm-hack-registry mirror).
- AuditVault finding: 41480-h-6-users-will-steal-excess-funds-from-the-vault-due-to-vaul.
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.