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-48020 Overview
CVE-2021-48020 is a memory corruption vulnerability in the Vyper smart contract compiler affecting versions 0.1.0b4 through 0.3.0. The compiler emits an incorrect stack tip pointer when internal function calls appear inside array contexts. Contracts that place internal calls in nested array elements, external call arguments, struct literals, or raw_log topics can experience memory corruption. The corruption produces incorrect contract behavior, which can affect integrity of on-chain operations compiled by vulnerable Vyper releases. The flaw is classified under [CWE-787] (Out-of-Bounds Write).
Critical Impact
Smart contracts compiled with vulnerable Vyper versions can produce silently incorrect results, undermining the integrity of financial logic executed on Ethereum Virtual Machine networks.
Affected Products
- Vyper compiler versions 0.1.0b4 through 0.2.x
- Vyper compiler versions prior to 0.3.0
- Smart contracts compiled with any affected Vyper release that use internal function calls inside arrays, external call arguments, struct literals, or raw_log topics
Discovery Timeline
- 2026-10-21 - CVE-2021-48020 published to NVD
- 2026-10-22 - Last updated in NVD database
Technical Details for CVE-2021-48020
Vulnerability Analysis
Vyper is a Pythonic smart contract language that compiles to Ethereum Virtual Machine (EVM) bytecode. The compiler tracks the top of the EVM stack during code generation to allocate scratch memory for intermediate values. When an internal function call is lowered inside an array-forming expression, the compiler computes the stack tip incorrectly. Subsequent writes land at an address that overlaps memory already in use by the surrounding expression.
The result is deterministic data corruption at compile-time rather than a runtime memory safety issue in the traditional sense. Contracts may transfer wrong amounts, write wrong storage slots, or emit malformed events. Because the bytecode is deterministic, the same miscompiled contract produces the same incorrect behavior on every invocation.
Root Cause
The root cause is an incorrect stack tip pointer computation in Vyper's internal call lowering logic. When an internal call appears as a sub-expression of an array literal, nested array element, external call argument, struct literal, or raw_log topic, the compiler fails to reserve space for the callee's return data on the stack. Memory corruption then occurs when the enclosing expression writes its own operands, overwriting the callee results.
Attack Vector
Exploitation requires that a contract be compiled with a vulnerable Vyper version and contain the specific syntactic patterns listed in the advisory. An attacker able to influence contract inputs or trigger affected code paths can cause the contract to execute with corrupted memory. Because EVM contracts are network-accessible once deployed, the attack vector is network-reachable without authentication for any publicly callable function containing the vulnerable pattern.
No verified public exploit code is available. For technical specifics, refer to the GitHub Security Advisory GHSA-22wc-c9wj-6q2v and the VulnCheck Advisory on Vyper Memory Corruption.
Detection Methods for CVE-2021-48020
Indicators of Compromise
- Deployed contracts whose compiler metadata references Vyper versions between 0.1.0b4 and 0.3.0
- Transaction traces showing event payloads or storage writes inconsistent with the Vyper source logic
- raw_log emissions where topic values do not match the expected hashed arguments
Detection Strategies
- Inventory deployed smart contracts and extract compiler version strings from Solidity/Vyper metadata or build artifacts
- Perform static review of Vyper source for internal function calls nested inside array literals, external call arguments, struct literals, or raw_log topics
- Recompile suspect contracts with Vyper 0.3.0 or later and diff the resulting bytecode to identify miscompilation artifacts
Monitoring Recommendations
- Monitor on-chain contract behavior for value mismatches between emitted events and resulting state transitions
- Track CI/CD pipelines to flag any build that pins Vyper to a version earlier than 0.3.0
- Alert on new deployments of contracts whose compiler metadata matches the affected version range
How to Mitigate CVE-2021-48020
Immediate Actions Required
- Upgrade the Vyper compiler to version 0.3.0 or later across all development and build environments
- Recompile and redeploy any production smart contract that contains internal function calls inside arrays, external call arguments, struct literals, or raw_log topics
- Audit on-chain state of affected contracts for integrity before migrating users or funds to replacement deployments
Patch Information
The fix is included in Vyper 0.3.0. The upstream advisory, GitHub Security Advisory GHSA-22wc-c9wj-6q2v, documents the corrected stack tip handling in the compiler's internal call lowering path. There is no in-place patch for already-deployed EVM bytecode; mitigation requires redeployment.
Workarounds
- Refactor Vyper source to hoist internal function calls out of array literals, struct literals, external call arguments, and raw_log topics into named local variables before use
- Pin build tooling to Vyper 0.3.0 or later and reject older versions in dependency manifests such as requirements.txt or pyproject.toml
- Add linting rules to continuous integration that reject the vulnerable syntactic patterns until the compiler upgrade is confirmed
# Configuration example
pip install --upgrade 'vyper>=0.3.0'
vyper --version
vyper contracts/MyContract.vy -o build/MyContract.bin
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

