CVE-2024-32481

vyper's range(start, start + N) reverts for negative numbers

Published Apr 25, 2024 CVSS 3.1 · 5.3 Medium EPSS < 1% KEV · Not listed
Description
Vyper is a pythonic Smart Contract Language for the Ethereum virtual machine. Starting in version 0.3.8 and prior to version 0.4.0b1, when looping over a `range` of the form `range(start, start + N)`, if `start` is negative, the execution will always revert. This issue is caused by an incorrect assertion inserted by the code generation of the range `stmt.parse_For_range()`. The issue arises when `start` is signed, instead of using `sle`, `le` is used and `start` is interpreted as an unsigned integer for the comparison. If it is a negative number, its 255th bit is set to `1` and is hence interpreted as a very large unsigned integer making the assertion always fail. Any contract having a `range(start, start + N)` where `start` is a signed integer with the possibility for `start` to be negative is affected. If a call goes through the loop while supplying a negative `start` the execution will revert. Version 0.4.0b1 fixes the issue.

Analysis

No analysis available yet

Remediation

No remediation available yet

Tracking

Sign in to view the affected projects.

Advisories

Source ID Title
EUVD EUVD EUVD-2024-1269 Vyper is a pythonic Smart Contract Language for the Ethereum virtual machine. Starting in version 0.3.8 and prior to version 0.4.0b1, when looping over a `range` of the form `range(start, start + N)`, if `start` is negative, the execution will always revert. This issue is caused by an incorrect assertion inserted by the code generation of the range `stmt.parse_For_range()`. The issue arises when `start` is signed, instead of using `sle`, `le` is used and `start` is interpreted as an unsigned integer for the comparison. If it is a negative number, its 255th bit is set to `1` and is hence interpreted as a very large unsigned integer making the assertion always fail. Any contract having a `range(start, start + N)` where `start` is a signed integer with the possibility for `start` to be negative is affected. If a call goes through the loop while supplying a negative `start` the execution will revert. Version 0.4.0b1 fixes the issue.
Github GHSA Github GHSA GHSA-ppx5-q359-pvwj vyper's range(start, start + N) reverts for negative numbers
History
Type Values Removed Values Added
First Time appeared Vyperlang
Vyperlang vyper
CPEs cpe:2.3:a:vyperlang:vyper:*:*:*:*:*:python:*:*
cpe:2.3:a:vyperlang:vyper:0.4.0:-:*:*:*:python:*:*
Vendors & Products Vyperlang
Vyperlang vyper
Weaknesses
  • CWE-681

    Incorrect Conversion between Numeric Types

Sources

Status
PUBLISHED
Assigner
GitHub_M
Published
Updated
Aug 2, 2024, 2:13 AM
Reserved
Apr 12, 2024, 7:41 PM
Status
Analyzed
Published
Apr 25, 2024, 5:15 PM
Modified
Jun 17, 2026, 7:29 AM