What happened in the Curve Vyper reentrancy exploit?
On 30 July 2023, between 13:10 and 22:00 UTC, attackers drained several Curve pools paired with native ETH, among them pETH/ETH, msETH/ETH, alETH/ETH and CRV/ETH (Curve's post-mortem). The pools declared a reentrancy lock, but Vyper 0.2.15, 0.2.16 and 0.3.0 compiled it as a separate lock for each function, so an attacker could call add_liquidity in the middle of remove_liquidity (Vyper's post-mortem). The pools are written in Vyper, which QuillShield doesn't support today. For Vyper code, request a manual audit from QuillAudits.
What is the timeline of the Curve Vyper exploit?
| Protocol | Curve pools on Vyper 0.2.15 to 0.3.0 |
|---|---|
| Date | 30 July 2023 |
| Chain | Ethereum |
| Loss | about $61.7M to $69.3M taken, by source |
| What happened | A bug in Vyper 0.2.15, 0.2.16 and 0.3.0 gave every @nonreentrant decorator its own storage slot, so functions that shared the 'lock' key did not share a lock. In pools paired with native ETH, attackers used the ETH transfer in remove_liquidity to call add_liquidity mid-withdrawal, which minted LP tokens from pre-burn balances. A white hat and later returns recovered part of the funds. |
| Sources | Curve, published by LlamaRisk, Vyper team, CertiK |
- 21 July to 30 November 2021: Vyper releases from 0.2.15 to 0.3.0 carry a bug that gives every
@nonreentrantdecorator its own storage slot, whatever its key. Version 0.3.1 fixes it (Vyper). - 30 July 2023, 13:10 UTC: the pETH/ETH pool is drained (post-mortem).
- 14:50 UTC: msETH/ETH is exploited (post-mortem).
- 15:34 UTC: alETH/ETH is exploited (post-mortem).
- 16:44 UTC: Vyper's official account confirms a bug in versions 0.2.15, 0.2.16 and 0.3.0 (post-mortem).
- 19:08 UTC: CRV/ETH is exploited (post-mortem).
- 22:00 UTC: c0ffeebabe.eth takes 2,879.65 ETH out of CRV/ETH in a white-hat action and returns it to the Curve team shortly after (post-mortem).
- 3 August 2023: Curve, Metronome and Alchemix offer the attackers a 10% bounty to return the rest (Cointelegraph).
- 4 August 2023: JPEG'd, whose pETH/ETH pool was hit, confirms 5,495.4 WETH back in its multisig, after a 10% white-hat bounty of 610.6 WETH (Cointelegraph).
- 5 August 2023: Alchemix says all funds stolen from its pool have been returned (Cointelegraph).
Why did the reentrancy lock fail?
The pools guarded add_liquidity and remove_liquidity with @nonreentrant('lock') (CertiK; rekt.news). The same key on both is meant to make one lock: while either function runs, neither can start. Vyper's post-mortem traces the bug to a compiler change, PR #2391, that reserved a new storage slot for every @nonreentrant decorator and ignored the key (Vyper). Each function got a lock of its own. A function still could not re-enter itself, but one guarded function could run inside another.
Vulnerable: the guarded pool functions in Vyper, simplified, not the original code (illustrative, not audited code) eth_pool.vy
# Both functions name the same key, 'lock'. Vyper 0.2.15, 0.2.16 and 0.3.0
# gave each decorator its own storage slot, so this compiled to two locks.
@external
@payable
@nonreentrant('lock')
def add_liquidity(_amounts: uint256[2], _min_mint_amount: uint256) -> uint256:
# mints LP tokens from the pool's balances and the LP token supply
...
@external
@nonreentrant('lock')
def remove_liquidity(_burn_amount: uint256, _min_amounts: uint256[2]) -> uint256[2]:
# lowers the pool's balances and sends ETH with raw_call,
# which runs the caller's code in the middle of this function
...
In the pETH/ETH pool, remove_liquidity sent ETH to the attacker's contract, and its fallback added liquidity while the withdrawal was still running (CertiK). In the words of Curve's post-mortem, "the allotted pool tokens were calculated with the pre-burn balances" (post-mortem), so the deposit minted more LP tokens than it should have, and the attacker withdrew against them.
Pools paired with WETH were not affected (post-mortem): the native ETH transfer is what handed control to the attacker. Vyper 0.3.1 had already fixed the slot allocation, in PR #2514, without anyone treating it as a security fix (Vyper; rekt.news).
In Solidity, the usual guard is one storage variable that every guarded function checks, so all functions that carry it share one lock. The lesson still carries over: a guard in the source is a claim about the bytecode, and only a test against the compiled contract checks it. The pattern and its variants are covered on reentrancy.
How much was lost in the Curve exploit?
Totals differ by source. rekt.news counted $69M drained, including small losses at dBridge and at Ellipsis, a Curve fork on BNB Chain (rekt.news). CertiK counted about $69.3M taken across six projects, about $16.7M returned and a net loss of $52M (CertiK). CoinDesk reported $61.7M (CoinDesk). Curve's own post-mortem gives no single total, but it lists each pool (post-mortem):
| Pool | Time (UTC) | Amounts in the post-mortem | Value at the time |
|---|---|---|---|
| pETH/ETH | 13:10 | 6,106.65 WETH | about $11M |
| msETH/ETH | 14:50 | 866.55 WETH and 959.71 msETH | about $1.6M and $1.8M |
| alETH/ETH | 15:34 | 7,258.70 WETH and 4,821.55 alETH | about $13.6M and $9M |
| CRV/ETH | 19:08 | 7,193,401.77 CRV and 7,680.49 WETH | about $5.1M and $14.2M |
| CRV/ETH, white hat | 22:00 | 2,879.65 ETH, returned to Curve | about $5.4M |
Was any of the money returned?
A good part of it. c0ffeebabe.eth returned the 2,879.65 ETH it took from CRV/ETH to the Curve team (post-mortem). JPEG'd confirmed 5,495.4 WETH back on 4 August, after paying a 10% white-hat bounty (Cointelegraph). The attacker behind the Alchemix pool accepted the 10% bounty that Curve, Metronome and Alchemix offered on 3 August and started sending alETH back the next day (Cointelegraph), and on 5 August Alchemix said all funds stolen from its pool had been returned (Cointelegraph).
Curve's post-mortem lists its next steps: new plain pools for alETH, msETH and pETH, paired with WETH or a new ETH pool implementation, and the emergency DAO was expected to stop CRV emissions to the affected pools (post-mortem). Vyper set up bug bounties on Immunefi that cover all compiler versions, a multi-protocol bounty program, a competitive audit with CodeHawks and reviews of past versions by several audit firms (Vyper).
What would a proof-of-concept-first audit test here?
Test the compiled contract, not the decorator. An auditor would deploy the pool's bytecode in a test, call each function that sends ETH or calls out, and from the callback try every other guarded function. Each attempt must revert. Against a pool compiled with an affected Vyper version, the add_liquidity attempt goes through and the test fails, which is the point.
Re-entry test sketch against a compiled ETH pool (illustrative, not audited code) CrossFunctionReentryTest.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.28;
interface IEthPool {
function add_liquidity(uint256[2] calldata amounts, uint256 minMint) external payable returns (uint256);
function remove_liquidity(uint256 burnAmount, uint256[2] calldata minAmounts)
external
returns (uint256[2] memory);
}
/// Foundry-style test. setUp() deploys the compiled pool and gives this contract LP tokens.
contract CrossFunctionReentryTest {
IEthPool internal pool;
bool internal calledBack;
bool internal reentryReverted;
receive() external payable {
if (calledBack) return;
calledBack = true;
// The pool is in the middle of remove_liquidity. Try the other guarded function.
try pool.add_liquidity{value: msg.value}([msg.value, uint256(0)], 0) {
reentryReverted = false;
} catch {
reentryReverted = true;
}
}
function test_addLiquidityCannotRunInsideRemoveLiquidity(uint256 lpAmount) external {
pool.remove_liquidity(lpAmount, [uint256(0), uint256(0)]);
require(calledBack, "the pool never handed over control");
require(reentryReverted, "add_liquidity ran inside remove_liquidity");
}
}
- Pair every function that hands over control (ETH transfers, token hooks, external calls) with every other guarded function as well as itself.
- Include the view functions other protocols read as prices, since they run during the callback too.
- Write the compiler version into the audit scope, and rerun the test whenever it changes.
QuillShield supports Solidity in Foundry projects today, not Vyper. On a Solidity codebase, a full audit builds a security graph across contracts, a separate reviewer agent tries to disprove each finding, and on full audits each finding that holds up comes with a proof of concept, so a reentrancy finding shows whether the callback path works against your code. For Vyper pools like these, request a manual audit from QuillAudits or talk to an auditor. Getting ready for an audit of either kind starts with the audit readiness checklist.
FAQ
Was the bug in Curve's code or in the Vyper compiler?
In the compiler. The pools declared the lock, and Vyper 0.2.15, 0.2.16 and 0.3.0 compiled it into a separate lock per function (Vyper).
Which Vyper versions were affected?
Versions 0.2.15, 0.2.16 and 0.3.0. Version 0.3.1 had already fixed the bug before anyone knew it was a security problem (post-mortem).
Can the same thing happen in Solidity?
This bug was in Vyper's compiler. The lesson is general: check a guard by re-entering the compiled contract in a test, because a modifier or decorator in the source is not proof on its own.
Sources
- Curve Pool Reentrancy Exploit Postmortem, July 30th, 2023, Curve, published by LlamaRisk checked 3 December 2026
- Vyper technical post-mortem of the reentrancy lock bug, Vyper team checked 3 December 2026
- Curve, Vyper: REKT, rekt.news checked 3 December 2026
- Vyper Incident Analysis, CertiK checked 3 December 2026
- Looter Behind $61M Curve Hack Starts Returning Assets, Raising Hope for Recovery, CoinDesk checked 3 December 2026
- Curve Vyper exploit: the whole story so far, Cointelegraph checked 3 December 2026
- JPEG'd confirms return of ETH from Curve hacker, Cointelegraph checked 3 December 2026
- Alchemix reports return of all stolen funds from Curve pools, Cointelegraph checked 3 December 2026