Vyper return statement in nested for loops causes revert

Severity: medium · Published 2026-10-06

Vyper, a language for writing smart contracts on Ethereum-like blockchains, has a bug where return statements inside for loops within nested internal function calls cause transactions to revert unexpectedly. This could be exploited to create denial-of-service conditions in public contracts, preventing legitimate operations from completing.

Technologies: vyper (PyPI), Vyper. Vendors: PyPI, Vyper.

Quick answers

Is This vulnerability exploited in the wild?
No. Junglewise Threat Intelligence has no report of This vulnerability being exploited in the wild.
How severe is This vulnerability?
Medium severity, published 6 October 2026.
Which products and versions are affected?
vyper (PyPI) >= 0.1.0b10, < 0.2.3; Vyper before 0.2.3.
Is there a fix for This vulnerability?
Yes: fixed in Vyper 0.2.3. Until then: Avoid placing return statements inside for loops in internal functions that are called from other internal functions; instead, move the return statement outside the loop. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is This vulnerability attacked?
It is attacked over the network, in a software library.
Am I affected?
Check whether you run vyper (PyPI) or Vyper at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

How to fix

  • Fixed in: Vyper 0.2.3

Avoid placing return statements inside for loops in internal functions that are called from other internal functions; instead, move the return statement outside the loop.

Technical details

The vulnerability occurs when a return statement is placed inside a for loop that is part of a nested internal function call chain (2+ levels deep), resulting in an invalid jump destination that causes a stack underflow. The issue affects code patterns where internal functions call other internal functions that contain return statements in loops. A fix exists in Vyper 0.2.3 and was patched in PR #2110.

Affected products

  • Vyper Vyper before 0.2.3

Timeline

  • 2026-10-06: disclosed
  • 2026-10-06: patched: Fixed in Vyper 0.2.3 via PR #2110

This page as Markdown. Free to reuse under CC BY 4.0 with a link back.