Return inside for loop breaks nested internal calls in Vyper
Key facts
- Attack vector
- —
- Privileges required
- —
- User interaction
- —
- Attack complexity
- —
- Impact type
- —
- Confidentiality · integrity · availability
- —
- Fix status
- Fixed
No CVSS vector from any source. Fix status from GitHub.
Summary
Vyper, a Python-based smart contract language, is affected from 0.1.0b10 before 0.2.3. A control flow management flaw (CWE-691) occurs when a return statement sits inside a for loop of nested internal calls, causing an invalid jump destination that reverts the transaction unnecessarily. The impact is described as minor, since a user would need nested internal calls with returns inside loops to hit it, and in limited circumstances it could enable a denial of service against public contracts.
Written with Claude Haiku 5.5 from the sources below · 2026-10-29
Description from the GitHub advisory
# VVE-2020-0002 Earlier today, we received a responsible disclosure of a potential issue from @michwill (developer of @curvefi) for Vyper users who use return statements inside for loops of nested internal calls. Returning inside a for loop causes an invalid jump dest, reverting the transaction unnecessarily. MWE: ```python @internal def _baz(): for i in range(1): return # Stack underflow happens here @internal def _bar(): self._baz() @external def foo(): self._bar() ``` ### Impact Impact is minor, it is unlikely a user would encounter this problem unless they were working with nested calls, and return statements inside calls. Even in that scenario, you would encounter a revert which should be noticeable with adequate testing. In limited circumstances, this could cause a DoS attack for public contracts under certain conditions. ### Patches Fixed in https://github.com/vyperlang/vyper/pull/2110. Please upgrade to [Vyper 0.2.3](https://pypi.org/project/vyper/) ### Workarounds Not returning inside a for loop nested 2+ internal calls deep works as is: ```python @internal def _baz(): for i in range(1): pass return # This works fine @internal def _bar(): self._baz() @external def foo(): self._bar() ``` ### For more information If you have any questions or comments about this advisory: * Chat with us in [our gitter ](https://gitter.im/vyperlang/community) * Open an issue in [https://github.com/vyperlang/vyper](https://github.com/vyperlang/vyper) * Email us at [[email protected]](mailto:[email protected])
Why it matters now
SSVC decision points
Not available: CISA has not published SSVC decision points for this record.
Affected products
| Vendor | Product | Affected versions | Fixed in | Status | Source |
|---|---|---|---|---|---|
| — | vyper (PyPI) | 0.1.0b10 to before 0.2.3 | 0.2.3 | Patch available | GHSA-vg88-3v92-rjx2 |
- vyper (PyPI) Vendor— Affected 0.1.0b10 to before 0.2.3 Fixed in 0.2.3 Patch available GHSA-vg88-3v92-rjx2
Remediation
Upgrade Vyper to version 0.2.3, which contains the fix from pull request 2110. Until then, avoid returning from inside a for loop that is nested two or more internal calls deep, and place the return after the loop instead.
Written with Claude Haiku 5.5 from the sources below · 2026-10-29
- Fix · GHSA-vg88-3v92-rjx2 vyper (PyPI) Fixed in 0.2.3 Advisory →
Timeline
- 2026-10-06 Threatist record created from GHSA-vg88-3v92-rjx2
References
Sources
This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences