Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB
CVE-2021-48018 Overview
CVE-2021-48018 affects the Vyper smart contract compiler versions 0.2.13 through 0.2.14. The compiler allocates storage slots for @nonreentrant reentrancy locks at the same locations as contract storage variables. When a function marked with @nonreentrant executes, setting the lock overwrites the overlapping storage variable. This corrupts contract state and breaks the contract's intended logic. The flaw maps to CWE-787 (Out-of-Bounds Write) because the compiler writes lock data outside the memory layout reserved for it. Contracts compiled with vulnerable Vyper releases can suffer silent state corruption whenever a protected function is invoked.
Critical Impact
Any Ethereum contract compiled with a vulnerable Vyper version using @nonreentrant can experience storage variable corruption, leading to integrity loss and broken contract behavior.
Affected Products
- Vyper smart contract compiler version 0.2.13
- Vyper smart contract compiler version 0.2.14
- Ethereum contracts compiled with the affected Vyper releases that use the @nonreentrant decorator
Discovery Timeline
- 2026-10-21 - CVE-2021-48018 published to NVD
- 2026-10-22 - Last updated in NVD database
Technical Details for CVE-2021-48018
Vulnerability Analysis
Vyper is a Pythonic programming language that targets the Ethereum Virtual Machine (EVM). The @nonreentrant(<key>) decorator provides mutex protection against reentrancy. The compiler reserves a dedicated storage slot that holds the lock value during function execution. In Vyper releases 0.2.13 and 0.2.14, the slot allocation algorithm did not reserve a distinct region for reentrancy locks. Instead, the compiler assigned the lock to a slot already in use by a declared contract storage variable.
When a protected function runs, the generated bytecode writes the lock sentinel into that overlapping slot. The write silently overwrites the declared variable. Depending on the variable's semantics, this can zero out balances, invalidate owner addresses, reset configuration fields, or alter accounting mappings. The corruption is deterministic and occurs on every call to a @nonreentrant function.
Root Cause
The root cause is an incorrect storage layout computation inside the Vyper compiler's code generation stage. Reentrancy lock slots were allocated from the same index space as user-declared storage variables rather than from a reserved region. The resulting out-of-bounds write pattern [CWE-787] produces slot collisions between compiler-managed state and contract-managed state.
Attack Vector
Exploitation does not require a crafted transaction. Any caller invoking a @nonreentrant function triggers the corruption because the behavior is a byproduct of normal execution. An attacker who identifies a vulnerable deployed contract can call a protected function to deliberately overwrite the targeted storage variable. The attack is network-reachable through standard Ethereum RPC endpoints and requires no authentication.
For technical details on the collision behavior, see the GitHub Security Advisory GHSA-7f92-rr6w-cq64 and the VulnCheck Advisory on Vyper Storage Corruption.
Detection Methods for CVE-2021-48018
Indicators of Compromise
- Unexpected zeroing or mutation of storage variables immediately after calls to functions decorated with @nonreentrant.
- Deployed contract bytecode produced by Vyper 0.2.13 or 0.2.14 as confirmed by compiler metadata or build artifacts.
- On-chain events showing state transitions that cannot be explained by the contract's documented logic.
Detection Strategies
- Audit source repositories and CI pipelines for Vyper compiler versions in the vulnerable 0.2.13 to 0.2.14 range.
- Reconstruct the storage layout of compiled contracts and verify that reentrancy lock slots do not overlap declared storage variables.
- Replay historical transactions in a forked environment and compare post-call storage snapshots against expected values.
Monitoring Recommendations
- Monitor transactions targeting @nonreentrant functions on contracts of unknown provenance for anomalous state changes.
- Alert on deployments whose embedded compiler metadata matches vulnerable Vyper releases.
- Track dependency manifests such as requirements.txt and pyproject.toml for pinned Vyper versions in the affected range.
How to Mitigate CVE-2021-48018
Immediate Actions Required
- Upgrade the Vyper compiler to version 0.2.15 or later and rebuild all affected contracts.
- Redeploy contracts that were compiled with Vyper 0.2.13 or 0.2.14 and use the @nonreentrant decorator.
- Review on-chain state of previously deployed vulnerable contracts for signs of storage corruption before migrating users.
Patch Information
The Vyper maintainers released version 0.2.15 to correct the storage slot allocation for reentrancy locks. The fix reserves dedicated slots that do not overlap user-declared storage variables. Full remediation details are published in the GitHub Security Advisory GHSA-7f92-rr6w-cq64.
Workarounds
- Remove the @nonreentrant decorator and implement reentrancy protection manually using an explicit mutex variable until a patched compiler is adopted.
- Pin build toolchains to Vyper 0.2.15 or later across all development, staging, and production pipelines to prevent accidental use of vulnerable versions.
- Freeze new deployments of contracts compiled with vulnerable Vyper releases until recompilation and redeployment are complete.
# Configuration example: upgrade Vyper to a fixed release
pip install --upgrade "vyper>=0.2.15"
vyper --version
vyper contracts/MyContract.vy -f bytecode,abi
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB

