CVE-2025-26622: Vyper sqrt improper rounding behavior in decimal calculations

CVE-2025-26622 · Severity: medium · CVSS 4 · Published 2025-02-21

Vyper is a smart contract programming language used to write blockchain applications. The sqrt() function uses an iterative algorithm that may incorrectly round up square root results for certain decimal inputs, potentially causing boundary condition checks in contracts to produce wrong answers. While sqrt() is rarely used, this inconsistency could lead to logical errors in contracts relying on precise mathematical calculations.

Technologies: vyper (PyPI). Vendors: PyPI.

Quick answers

Is CVE-2025-26622 exploited in the wild?
No. Junglewise Threat Intelligence has no report of CVE-2025-26622 being exploited in the wild.
How severe is CVE-2025-26622?
Medium severity, with a CVSS score of 4, published 21 February 2025.
Which products and versions are affected?
vyper (PyPI) ECOSYSTEM:introduced=0,fixed=0.4.1.
Is there a fix for CVE-2025-26622?
Yes. vyper (PyPI): upgrade to 0.4.1 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is CVE-2025-26622 attacked?
It is attacked over the network, in a software library.
Am I affected by CVE-2025-26622?
Check whether you run vyper (PyPI) 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

  • vyper (PyPI): upgrade to 0.4.1 or later
    pip install "vyper>=0.4.1"

Technical details

Vyper's sqrt() builtin function implements the babylonian method to compute square roots of decimal numbers. The algorithm terminates when consecutive iterations are equal or after 256 iterations; however, for certain inputs, the result may oscillate between two values N and N+epsilon (where N² ≤ x < (N+epsilon)²), and the termination condition does not guarantee consistent rounding behavior. An attacker or deployed contract using sqrt() could encounter rounded-up results when rounded-down results are expected, affecting boundary conditions. The function diverges from the isqrt() integer variant, which consistently rounds down. The fix is tracked in pull request #4486 and patched in version 0.4.1.

Affected products

  • Vyper Vyper <=0.4.0

Identifiers

  • CVE-2025-26622
  • GHSA-2p94-8669-xg86
  • PYSEC-2025-29

Timeline

  • 2025-02-21: disclosed
  • 2025-02-21: patched: Fixed in version 0.4.1

References

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