GHSA-vg88-3v92-rjx2 CVE-2020-37288
Vyper: Return inside for loop more than 1 level deep
- Severity
- 0.0 / 10
- Low · CVSS 4.0
- Exploit chance (EPSS)
- 0.35%
- Chance of exploitation in the next 30 days. Higher than 28.31% of scored vulnerabilities.
- Known exploited
- No
- Not in CISA's catalog
- Weakness
- CWE-691 Insufficient Control Flow Management
- Fix
0.2.3- Upgrade vyper to this version or later
Description
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:
@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
Workarounds
Not returning inside a for loop nested 2+ internal calls deep works as is:
@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
- Open an issue in https://github.com/vyperlang/vyper
- Email us at security@vyperlang.org
Affected versions
PyPI
| Package | Vulnerable | Fixed in |
|---|---|---|
| vyper | >= 0.1.0b10, < 0.2.3 |
0.2.3 |
How to fix
Move to the fixed version or later with your package manager, update the lockfile, and run your tests. If the package only arrives through another dependency, upgrade that dependency first. If none of its releases pulls a fixed version yet, force the version with your package manager's override.
vyper PyPI → 0.2.3
- pip
pip install --upgrade "vyper>=0.2.3"- poetry
poetry add "vyper>=0.2.3"- uv
uv add "vyper>=0.2.3"
Severity breakdown
CVSS 4.0 0.0
CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N
- Attack vector
- Network
- Attack complexity
- Low
- Attack requirements
- Present
- Privileges required
- None
- User interaction
- None
- Confidentiality (vulnerable system)
- None
- Integrity (vulnerable system)
- None
- Availability (vulnerable system)
- Low
- Confidentiality (subsequent systems)
- None
- Integrity (subsequent systems)
- None
- Availability (subsequent systems)
- None
CVSS 3.1 3.7
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:L
- Attack vector
- Network
- Attack complexity
- High
- Privileges required
- None
- User interaction
- None
- Scope
- Unchanged
- Confidentiality
- None
- Integrity
- None
- Availability
- Low
Weakness
CWE-691: Insufficient Control Flow Management
The code does not sufficiently manage its control flow during execution, creating conditions in which the control flow can be modified in unexpected ways.
References
Packages
Other links
- github.com/vyperlang/vyper/security/advisories/GHSA-vg88-3v92-rjx2
- github.com/vyperlang/vyper/pull/2110
- github.com/vyperlang/vyper/commit/a1d92e5eb968a34a23850359656aee23334adb90
- github.com/vyperlang/vyper/releases/tag/v0.2.3
- vulncheck.com/advisories/vyper-0.1-0b10-before-0.2.3-invalid-jump-destination-via-…
Timeline
- Published
- Last updated by the source
- Latest EPSS score
Related advisories
| Advisory | Severity | Why it's related |
|---|---|---|
| GHSA-2r3x-4mrv-mcxf Vyper: Memory corruption using function calls within tuples / nested calls | Medium | Also affects vyper |
| GHSA-4v7v-gqf9-ww2g Vyper: Call stack corruption when passing complex type containing non-base type members as argument | Medium | Also affects vyper |
| GHSA-3vcg-j39x-cwfm Vyper's `slice()` may elide side-effects when output length is 0 | Low | Also affects vyper |
| GHSA-qhr6-mgqr-mchm Vyper's `concat()` builtin may elide side-effects for zero-length arguments | Low | Also affects vyper |
| GHSA-h33q-mhmp-8p67 Vyper has a double eval in For List Iter | High | Also affects vyper |
| GHSA-4w26-8p97-f4jp AugAssign evaluation order causing OOB write within the object in Vyper | Critical | Also affects vyper |
| GHSA-2p94-8669-xg86 Vyper's sqrt doesn't define rounding behavior | High | Also affects vyper |
| GHSA-vgf2-gvx8-xwc3 Vyper Does Not Check the Success of Certain Precompile Calls | High | Also affects vyper |
MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.
Check your repos with MergeHarbor