CVE-2021-29510 Use of "infinity" as an input to datetime and date fields causes infinite loop in pydantic

Low 3.3 Published Updated

Attackers can cause infinite loops and high CPU usage in applications using Pydantic by passing infinity values to date fields.

Exploited in the wild
Not known
Login needed
Not needed
Attackable
Local or same network only
Victim action needed
A user has to click or open something
Fix
Available

What is CVE-2021-29510?

CVE-2021-29510 is a low-severity denial of service vulnerability in Fedoraproject Fedora, published on 13 May 2021. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.

Official description

Pydantic is a data validation and settings management using Python type hinting. In affected versions passing either `'infinity'`, `'inf'` or `float('inf')` (or their negatives) to `datetime` or `date` fields causes validation to run forever with 100% CPU usage (on one CPU). Pydantic has been patched with fixes available in the following versions: v1.8.2, v1.7.4, v1.6.2. All these versions are available on pypi(https://pypi.org/project/pydantic/#history), and will be available on conda-forge(https://anaconda.org/conda-forge/pydantic) soon. See the changelog(https://pydantic-docs.helpmanual.io/) for details. If you absolutely can't upgrade, you can work around this risk using a validator(https://pydantic-docs.helpmanual.io/usage/validators/) to catch these values. This is not an ideal solution (in particular you'll need a slightly different function for datetimes), instead of a hack like this you should upgrade pydantic. If you are not using v1.8.x, v1.7.x or v1.6.x and are unable to upgrade to a fixed version of pydantic, please create an issue at https://github.com/samuelcolvin/pydantic/issues requesting a back-port, and we will endeavour to release a patch for earlier versions of pydantic.

Weakness: CWE-835

Which versions are affected by CVE-2021-29510?

7 open source packages ship an affected version, including pydantic. It affects 2 products.

PackageAffectedFixed in
pydantic PyPIAll versions1.6.2, 1.7.4, 1.8.2
pydantic PyPIAll versions1.6.2
pydantic PyPIAll versions1.6.2
pydantic PyPIFrom 1.71.7.4
pydantic PyPIFrom 1.71.7.4
pydantic PyPIFrom 1.81.8.2
1 more packages
pydantic PyPIFrom 1.81.8.2

Products include Fedoraproject Fedora, Pydantic Pydantic.

How do I fix CVE-2021-29510?

Upgrade pydantic to a fixed version for your release line: 1.6.2, 1.7.4 or 1.8.2.

Upgrade, then put limits on request size, rate and nesting depth so one client cannot exhaust the service. More about Denial of service.

Is CVE-2021-29510 being exploited?

There is no known exploitation of CVE-2021-29510 in the wild and no public exploit code.

All Fedoraproject Fedora vulnerabilities

Sources

Also known as DEBIAN-CVE-2021-29510, GHSA-5jqp-qgf6-3pvh, PYSEC-2021-47, UBUNTU-CVE-2021-29510, USN-6553-1, openSUSE-SU-2024:11254-1.

Is CVE-2021-29510 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free