Baja

Vyper's sqrt doesn't define rounding behavior

  • Publicada: 21.02.2025
  • Actualizado: 11.10.2026 12:19

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.

the fix is tracked in https://github.com/vyperlang/vyper/pull/4486

Vulnerability Details

Vyper injects the following code to handle calculation of decimal sqrt. x is the input provided by user.

python
assert x >= 0.0
z: decimal = 0.0

if x == 0.0:
    z = 0.0
else:
    z = x / 2.0 + 0.5
    y: decimal = x

    for i: uint256 in range(256):
        if z == y:
            break
        y = z
        z = (x / z + z) / 2.0

Notably, the terminal condition of the algorithm is either z_cur == z_prev, or the algorithm runs for 256 rounds.

However, 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.

The 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.

vyper
@external
def test():
    d: decimal = 0.9999999998
    r: decimal = sqrt(d)    #this will be 0.9999999999

Note that sqrt() diverges from isqrt() here -- isqrt() consistently rounds down, so it is not subject to the same issue.

Impact Details

Since 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.

Software afectado

Haz clic en una tecnología para ver todas sus vulnerabilidades.

PlataformaPaqueteVersiones vulnerablesCorregida en
Python (PyPI) vyper < 0.4.1 0.4.1

Referencias

Puntuación CVSS -
Vector CVSS
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
Debilidad (CWE)
CWE-682
Plataforma
Python (PyPI)
Paquete
vyper
Publicada
21.02.2025
Actualizado
11.10.2026 12:19

Fuentes y licencias

OSV / GitHub Advisory Database - PYSEC-2025-29 - PyPA Advisory Database; CC BY 4.0

OSV / GitHub Advisory Database - GHSA-2p94-8669-xg86 - CC BY 4.0

Historial de vulnerabilidades: vyper

Todas las vulnerabilidades publicadas de este paquete (Python (PyPI)), de la más reciente a la más antigua. Muestra si es un fallo aislado o un paquete que hay que vigilar.

Todas (47) en el archivo
Entradas en total
47
Primera → última
03.2020 10.2026
Sin corrección
5
Explotada en ataques
0

Distribución por gravedad

  • Crítica 3
  • Alta 14
  • Media 20
  • Baja 10

Divulgaciones por año

  1. 2020: 1
  2. 2021: 5
  3. 2022: 4
  4. 2023: 14
  5. 2024: 14
  6. 2025: 6
  7. 2026: 3
Gravedad:
  1. Vyper's sqrt doesn't define rounding behavior esta entrada
    Baja CVE-2025-26622 < 0.4.1 0.4.1
  2. Crítica · 9.8 CVE-2024-24563 < 0.4.0 0.4.0
  3. Crítica · 9.8 CVE-2024-24561 < 0.4.0 0.4.0
  4. Alta · 7.3 CVE-2024-22419 >= 0.3.0, < 0.4.0 0.4.0
  5. Alta · 7.5 CVE-2023-46247 < 0.3.8 0.3.8
  6. Alta · 8.1 CVE-2023-42443 >= 0.3.4, < 0.3.10 0.3.10
  7. Crítica · 8.7 CVE-2023-39363 >= 0.2.15, < 0.3.1 0.3.1
  8. Alta · 7.5 CVE-2023-32058 < 0.3.8 0.3.8
  9. Alta · 7.5 CVE-2023-30837 < 0.3.8 0.3.8
  10. Alta · 7.5 CVE-2023-30629 >= 0.3.1, < 0.3.8 0.3.8
  11. Alta · 7.5 CVE-2022-29255 < 0.3.4 0.3.4
  12. Alta · 7.1 CVE-2022-24788 < 0.3.2 0.3.2
  13. Alta · 7.5 CVE-2022-24787 < 0.3.2 0.3.2
  14. Alta ghsa-7f92-rr6w-cq64 >= 0.2.13, < 0.2.15 0.2.15

Identifica las vulnerabilidades de tu aplicación

Con la integración de DockRay y el inventario de software activado, DockRay compara las versiones notificadas de los componentes con las vulnerabilidades conocidas y avisa de las coincidencias confirmadas. La cobertura depende de la tecnología compatible y de los avisos disponibles.

Conectar tu aplicación
Newsletter DockRay

La seguridad de tus aplicaciones en tu correo

Vulnerabilidades importantes, recomendaciones concretas y consejos prácticos para tus aplicaciones. Elige tus tecnologías y sigue lo que importa para tu proyecto.

  • Un resumen diario de nuevas vulnerabilidades, también las críticas.
  • Avisos sobre actualizaciones importantes.
  • Consejos prácticos sobre seguridad y monitorización de aplicaciones.

Déjalo vacío para recibir avisos de todas las tecnologías.

Suscripción gratuita. Date de baja con un clic en cualquier correo.