All vulnerabilities
CRITICALWeb3exploited in the wild

WEB3-CURVE-VYPER-2023

Web3 · Ethereum · Curve Finance (Vyper)

Summary

On July 30, 2023 several Curve Finance native-ETH stable pools were exploited via a compiler/toolchain supply-chain bug in specific Vyper versions (0.2.15, 0.2.16, 0.3.0). The compiler's storage-slot allocator assigned every @nonreentrant(key) decorator its own unique storage slot instead of reusing one shared slot per key, so functions meant to share a single reentrancy lock each got an independent, separately-set lock. This left the guard effective against single-function reentrancy but defeated cross-function reentrancy, letting an attacker re-enter a different guarded function via the native-ETH transfer callback while balances were mid-update. WETH-paired pools were unaffected; the exploited native-ETH pools included CRV/ETH, pETH/ETH, msETH/ETH and alETH/ETH, impacting Alchemix, JPEG'd and Metronome. Gross losses were around $61M; white-hat actors and MEV bots such as c0ffeebabe.eth returned a significant portion, reducing net losses to roughly $52M.

How to avoid it in your code

  • Pin exact, audited compiler versions and rebuild/verify deployed bytecode against the audited source before release.
  • Track compiler security advisories and re-audit or migrate contracts when a toolchain-level bug is disclosed.
  • Treat the compiler and build pipeline as part of the trusted supply chain: reproducible builds and signed releases.
  • Add explicit cross-function reentrancy guards and read-only reentrancy checks rather than relying solely on compiler-generated locks.
  • Test reentrancy protection at the bytecode level, including native-ETH transfer callback paths.

References

Related vulnerabilities

All Web3 →