CVE-2021-29510
Use of "infinity" as an input to datetime and date fields causes infinite loop in pydantic
Check your servers for CVE-2021-29510
The Vulnpocalypse collector sends the package list of each Linux server and of its container images once a day. Vulnpocalypse shows every server where CVE-2021-29510 affects pydantic, with the command that installs the fix. The free plan covers one server and one domain and does not need a credit card.
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.
Severity (CVSS)
CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:L
- Attack vector
- local: the attacker needs local access, or a user has to open a prepared file
- Attack complexity
- low: an attack works without special conditions
- Privileges required
- none: the attacker does not need an account
- User interaction
- required: a user has to do something, such as open a link or a file
- Scope
- unchanged: the damage stays inside the vulnerable component
- Impact
- confidentiality none, integrity none, availability low: what an attacker can read (confidentiality), change (integrity) or stop (availability)
Exploitation
EPSS 0.98%: the probability of exploitation activity in the next 30 days, from the EPSS model of FIRST. The score is higher than 63.0% of all scored CVEs. Scores of 1 Dec 2026.
Weakness
- CWE-835 Loop with Unreachable Exit Condition
Affected products
As the CNA lists them.
| Product | Versions |
|---|---|
| pydantic |
affected >= 1.8.0, < 1.8.2 affected >= 1.7.0, < 1.7.4 affected < 1.6.2
|
Is my server affected?
Find the installed version of pydantic and compare it with the fixed version of your distribution. Distributions often fix a CVE in a package version of their own, so the version number of the upstream project can mislead.
Debian, Ubuntu
dpkg -l | grep -i pydantic
# packages whose changelog names the CVE (fixed in the installed version)
zgrep -l CVE-2021-29510 /usr/share/doc/*/changelog.Debian.gz
# Ubuntu
pro fix CVE-2021-29510RHEL, Rocky, Alma, Fedora
rpm -q pydantic
# lists the advisory while the fix is not installed
dnf updateinfo list --cve CVE-2021-29510Alpine
apk list --installed | grep -i pydanticWith Trivy, on the host and for a container image. When a package is affected, it prints the installed and the fixed version:
trivy rootfs --scanners vuln / | grep CVE-2021-29510
trivy image --scanners vuln IMAGE | grep CVE-2021-29510
Vulnpocalypse makes this comparison every day for the package lists of your servers and container images, including language packages (npm, PyPI, Go, Maven and others), and sends the command that installs the fix. Start free with one server and one domain or read how to install the collector.
References
Advisories
- https://github.com/samuelcolvin/pydantic/security/advisories/GHSA-5jqp-qgf6-3pvh github.com
- FEDORA-2021-f8bb3ba3ec lists.fedoraproject.org · vendor advisory
- FEDORA-2021-4d3de3183f lists.fedoraproject.org · vendor advisory
- FEDORA-2021-e7fabd81fb lists.fedoraproject.org · vendor advisory
Other references
Source: the record CVE-2021-29510 of the CVE List (CVE Program), CVE Terms of Use; EPSS of FIRST; the CWE catalog of MITRE, CWE Terms of Use. The text of the record is shown as published. Data sources and licences.
Vulnpocalypse