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.

Aug 2024•Other•logic•3 min read

Chain

Other

Category

logic

Date

Aug 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: 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-registry mirror.


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#

ImpactHIGH — the caller extracts 2,000 RA from a pool that held 1,000 RA; the next depositor loses the deposit
ProtocolCork, VaultPoolLib.redeem / __tryRedeemExcessFromAmmPool
Vulnerable codeexcess is added to the payout and raBalance / paBalance are not decreased
Bug classWithdrawal-pool accounting is left stale, then counted again
FindingSherlock #144 — Cork Protocol, August 2024 · id 41480
ReportSherlock issue 144
SourceAuditVault finding
Compilersolc 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#

SOLIDITY
(raOut, paOut) = __tryRedeemfromWithdrawalPool(amountAttributed);
withdrawnFromAmm = (excessAmount * withdrawalPool.raExchangeRate) / 1e18; // @> VULN
raOut += withdrawnFromAmm;

__tryRedeemfromWithdrawalPool is view. Nothing writes raBalance or paBalance.

DIFF
-(raOut, paOut) = __tryRedeemfromWithdrawalPool(amountAttributed);
+(raOut, paOut) = __redeemfromWithdrawalPool(amountAttributed); // debits raBalance and paBalance

Attack walkthrough#

  1. The pool holds 1,000 RA. The caller is eligible for 400 and calls redeemExpired(1000).
  2. The excess of 600 is priced at the 1:1 exchange rate and added to the 400. The vault transfers 1,000 RA.
  3. raBalance and paBalance are still 1,000.
  4. The victim deposits 1,000 RA. reserve() sets phantomClaim to the stale raBalance.
  5. redeemStale transfers that 1,000. The caller now holds 2,000 RA.

Diagrams#

flowchart TD A["Partial request redeems more than userEligible"] --> B["Excess is priced and paid"] B --> C["raBalance and paBalance stay unchanged"] C --> D["Next depositor sends 1000 RA"] D --> E["reserve still counts the old balance"] E --> F["Second redeem takes the new deposit"]

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#


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.