Skip to main content
Vulnerability Database/CVE-2020-37288

CVE-2020-37288: Vyper Compiler Code Generation DoS Vulnerability

CVE-2020-37288 is a code generation flaw in Vyper compiler affecting versions 0.1.0b10 through 0.2.2. The vulnerability causes incorrect jump destinations in nested function calls. This article covers technical details, affected versions, impact assessment, and mitigation strategies.

Published:

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-2020-37288 Overview

CVE-2020-37288 affects the Vyper smart contract compiler, a Python-like language that compiles to Ethereum Virtual Machine (EVM) bytecode. Versions from 0.1.0b10 before 0.2.3 generate incorrect bytecode when a return statement appears inside a for loop within an internal function invoked two or more internal calls deep. The compiler emits an invalid jump destination, causing a stack underflow at runtime. Affected contracts revert these calls unnecessarily, which in limited circumstances enables denial of service against publicly callable contracts. The flaw is tracked under [CWE-670: Always-Incorrect Control Flow Implementation].

Critical Impact

Smart contracts compiled with vulnerable Vyper versions revert on specific nested internal calls, potentially rendering public contract functionality unavailable.

Affected Products

  • Vyper compiler versions 0.1.0b10 through 0.2.2
  • Ethereum smart contracts compiled with affected Vyper releases
  • Downstream dApps relying on nested internal functions with loop-based returns

Discovery Timeline

  • 2026-10-21 - CVE-2020-37288 published to NVD
  • 2026-10-22 - Last updated in NVD database

Technical Details for CVE-2020-37288

Vulnerability Analysis

The defect lives in Vyper's code generation path for return statements nested inside for loops. When the compiler processes an internal function containing such a return, and that function is reached through two or more layers of internal calls, the emitted EVM bytecode contains a jump target that does not correspond to a valid JUMPDEST opcode. Execution reaching this instruction triggers an EVM exception from stack underflow, forcing the transaction to revert.

The bug is strictly a compiler correctness issue, not a logic flaw in user code. Developers writing idiomatic Vyper patterns unknowingly produce contracts that fail at runtime on specific call paths. Because EVM reverts consume gas and roll back state, repeated invocation of the broken call path can block legitimate users from interacting with public entry points that depend on the affected internal function.

Root Cause

The compiler's control-flow lowering mishandles the interaction between loop exit semantics and the internal-call return convention. At depth two or greater, the stack layout assumed by the generated jump no longer matches the actual EVM stack state, producing an invalid destination and a resulting stack underflow during contract execution.

Attack Vector

Exploitation requires that a vulnerable contract be deployed on-chain with a public function whose execution path reaches the broken internal call. Any network participant can submit transactions that trigger the faulty path, causing deterministic reverts. See the GitHub Security Advisory GHSA-vg88-3v92-rjx2 and the Vulncheck Invalid Jump Destination Advisory for further technical context.

Detection Methods for CVE-2020-37288

Indicators of Compromise

  • Repeated failed transactions reverting with invalid-opcode or stack-underflow errors against a specific Vyper-compiled contract
  • Deployed bytecode produced by Vyper versions in the range 0.1.0b10 to 0.2.2
  • EVM traces showing a JUMP to an address lacking a JUMPDEST opcode

Detection Strategies

  • Audit project build manifests and CI logs for Vyper compiler versions prior to 0.2.3
  • Recompile and diff bytecode against patched-compiler output to confirm whether the invalid jump target is present
  • Run static analysis to flag internal functions that contain return statements inside for loops and are reachable through two or more internal call hops

Monitoring Recommendations

  • Instrument dApp back-ends and RPC gateways to alert on recurring revert reasons tied to specific contract addresses
  • Track on-chain error signatures for stack-underflow reverts in contracts the organization owns or depends on
  • Include compiler-version metadata in software bill of materials (SBOM) for all deployed smart contracts

How to Mitigate CVE-2020-37288

Immediate Actions Required

  • Upgrade the Vyper toolchain to version 0.2.3 or later and rebuild affected contracts
  • Inventory deployed contracts and identify any compiled with versions 0.1.0b10 through 0.2.2
  • For contracts already deployed on immutable chains, deploy a patched replacement and migrate state or route callers to the new address

Patch Information

The fix is included in Vyper 0.2.3. The upstream advisory GHSA-vg88-3v92-rjx2 documents the corrected code generation for return inside for loops in nested internal functions. Recompiling source with the patched compiler is sufficient; no source-level changes are required.

Workarounds

  • Refactor affected internal functions to move the return outside the for loop, using a sentinel variable to carry the result
  • Flatten the call graph so the function containing the loop-based return is invoked at depth one or directly from an external entry point
  • Restrict access to public functions whose execution reaches the broken path until a patched build is deployed
bash
# Upgrade Vyper to a patched release
pip install --upgrade "vyper>=0.2.3"

# Verify the installed compiler version
vyper --version

# Recompile affected contracts
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

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.