CVE-2025-26622: Vyper Vyper's Sqrt Doesn't Define Rounding Vulnerability
LOWCVE-2025-26622 is a LOW vyper's sqrt doesn't define rounding vulnerability (CWE-682: Incorrect Calculation) affecting Vyper libraries in the PyPI ecosystem. The issue involves vyper's sqrt doesn't define rounding behavior. Remediation is available by upgrading affected packages to version 0.4.1.
CVE-2025-26622 at a Glance
How to Fix CVE-2025-26622
To remediate this vulnerability, upgrade all affected Vyper dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
pip install vyper>=0.4.1
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show vyper
How to Check if You Are Affected
To determine whether your Python environment is affected by CVE-2025-26622, inspect your installed packages using pip:
pip show vyper
Analyze the terminal output to locate any version of Vyper in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.4.1), your application is affected.
Note: The pip show vyper command checks currently installed packages in your active Python environment.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-682: Incorrect Calculation, where the product performs a calculation that generates incorrect or unintended results that are later used in security-critical decisions or resource management. In Vyper, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2025-26622 Affected Vyper Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
vyper
|
PyPI |
< 0.4.1
|
0.4.1
|
References
Frequently Asked Questions
What is CVE-2025-26622?
Which Vyper versions are affected?
What version fixes CVE-2025-26622?
Is vyper affected?
What CWE is associated with CVE-2025-26622?
How can I check PyPI dependencies for CVE-2025-26622?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-2p94-8669-xg86",
"modified" : "2025-04-09T20:11:26Z",
"published" : "2025-02-21T22:43:30Z",
"aliases" : [ "CVE-2025-26622" ],
"summary" : "Vyper's sqrt doesn't define rounding behavior",
"details" : "Vyper's `sqrt()` builtin uses the babylonian method to calculate square roots of decimals. Unfortunately, improper handling of the oscillating final states may lead to sqrt incorrectly returning rounded up results.\n\nthe fix is tracked in https://github.com/vyperlang/vyper/pull/4486\n\n### Vulnerability Details\n\nVyper injects the following code to handle calculation of decimal sqrt. x is the input provided by user.\n```python\nassert x >= 0.0\nz: decimal = 0.0\n\nif x == 0.0:\n z = 0.0\nelse:\n z = x / 2.0 + 0.5\n y: decimal = x\n\n for i: uint256 in range(256):\n if z == y:\n break\n y = z\n z = (x / z + z) / 2.0\n```\nNotably, the terminal condition of the algorithm is either `z_cur == z_prev`, or the algorithm runs for 256 rounds.\n\nHowever, for certain inputs, `z` might actually oscillate between `N` and `N + epsilon`, where `N ** 2 <= x < (N + epsilon) ** 2`. This means that the current behavior does not define whether it will round up or down to the nearest epsilon.\n\nThe example snippet here returns 0.9999999999, the rounded up result for sqrt(0.9999999998). This is due to the oscillation ending in N + epsilon instead of N.\n```vyper\n@external\ndef test():\n d: decimal = 0.9999999998\n r: decimal = sqrt(d) #this will be 0.9999999999\n```\n\nNote that `sqrt()` diverges from `isqrt()` here -- `isqrt()` consistently rounds down, so it is not subject to the same issue.\n\n### Impact Details\n\nSince `sqrt()` can be used for determining boundary conditions, rounding down is preferred. However, since `sqrt()` is used very rarely in the wild, this advisory has been assigned an impact of `low`.",
"severity" : [ {
"type" : "CVSS_V4",
"score" : "CVSS:4.0/AV:N/AC:H/AT:P/PR:L/UI:N/VC:L/VI:L/VA:N/SC:N/SI:N/SA:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "vyper"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "0.4.1"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "<= 0.4.0"
}
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/vyperlang/vyper/security/advisories/GHSA-2p94-8669-xg86"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2025-26622"
}, {
"type" : "WEB",
"url" : "https://github.com/vyperlang/vyper/pull/4486"
}, {
"type" : "WEB",
"url" : "https://github.com/pypa/advisory-database/tree/main/vulns/vyper/PYSEC-2025-29.yaml"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/vyperlang/vyper"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-682" ],
"severity" : "LOW",
"github_reviewed" : true,
"github_reviewed_at" : "2025-02-21T22:43:30Z",
"nvd_published_at" : "2025-02-21T22:15:13Z"
}
}