ReDOS Vulnerability in Mpmath Package: Denial of Service Risk

mpmath Updated 02 Oct 2025

Summary

21/06/2021
N/A
No i
High
7.5

CVE-2021-29063: A Regular Expression Denial of Service (ReDOS) vulnerability was discovered in Mpmath v1.0.0 through v1.2.1 when the mpmathify function is called. Affects mpmath across 3 version ranges.

>= 8e21a638727567914536f4a4a63aa5fa204c40f0, <= c6a35f9ee7c294bcf4e0517bc76b268843db9499 < 46d44c3c8f3244017fe1eb102d564eb4ab8ef750 < b5c04506ef0cd4a1f1213f8389ee21c9c3551582

No fix is published. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Penetration testing for web, API and mobile Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

Mpmath is a Python library for arbitrary-precision arithmetic, allowing users to perform complex mathematical calculations with high precision. It is widely used in scientific computing and mathematical research. The library's functionality includes support for real and complex numbers, as well as various mathematical functions. However, versions 1.0.0 through 1.2.1 of Mpmath are susceptible to a Regular Expression Denial of Service (ReDOS) vulnerability, which can be exploited under specific conditions.

Vulnerability Detail

The vulnerability arises from the mpmathify function in Mpmath, which utilizes regular expressions that can be exploited to cause excessive backtracking. This can lead to a denial of service, as the function may consume significant CPU resources when processing specially crafted input. The impact of this vulnerability is particularly concerning in environments where Mpmath is used for real-time calculations, as it could lead to application unresponsiveness or crashes. The CVSS score for this vulnerability is 7.5, indicating a high severity level.

How To Fix

No fixed version is published for this vulnerability.

Tip — Not sure whether your app is affected? Vulert can check the versions your app actually runs. Scan free →

Workaround

If upgrading is not immediately possible, consider implementing input validation to sanitize user inputs before passing them to the mpmathify function. This can help mitigate the risk of exploitation by ensuring that only safe inputs are processed.

Conclusion

The ReDOS vulnerability in the Mpmath package poses a significant risk, particularly in environments that rely on real-time calculations. Users are strongly encouraged to upgrade to the latest version to mitigate this risk. Implementing input validation can serve as a temporary measure until an upgrade is feasible.

See every vulnerability recorded for mpmath →

Share this vulnerability

FAQ

ReDOS is a type of denial of service attack that exploits the backtracking behavior of regular expressions, causing excessive resource consumption and potentially crashing the application.

Mpmath versions 1.0.0 through 1.2.1 are affected by this vulnerability.

You can use the Vulert playground at Vulert Scanner to check if your application is affected by this vulnerability without needing to sign up.

Implement input validation to sanitize inputs before they reach the mpmathify function as a temporary workaround.

The CVSS score of this vulnerability is 7.5, indicating a high severity level.

Related vulnerabilities

Recent vulnerabilities recorded for mpmath.

How To Fix

No fixed version is published for this vulnerability.

Tip — Not sure whether your app is affected? Vulert can check the versions your app actually runs. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback