CVE-2021-29510: Pydantic - Denial of Service (DoS) via Infinite Loop

pydantic Updated 02 Oct 2025

Summary

13/05/2021
Yes i
Moderate
3.3

CVE-2021-29510: Pydantic is a data validation and settings management using Python type hinting. Affects pydantic across 4 version ranges.

< 1.6.2 >= 1.7, < 1.7.4 >= 1.8, < 1.8.2 < 7e83fdd2563ffac081db7ecdf1affa65ef38c468

Fixed in 1.6.2, 1.7.4 or 1.8.2, depending on the release line you run. How to fix ↓

Also tracked for

The same CVE-2021-29510 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.

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

Sponsored Devnack Mobile apps built by Devnack Design, build and launch iOS and Android apps with a senior product team. From idea to store release Start a project

Background

Pydantic is a Python library used for data validation and settings management. It leverages Python type hinting to provide robust data validation capabilities. The library is widely used in various Python applications and frameworks. However, certain versions of Pydantic are vulnerable to a Denial of Service (DoS) attack that can be triggered by passing specific values to datetime or date fields. This vulnerability can lead to an infinite loop, causing 100% CPU usage on one CPU core. Pydantic versions 1.8.x, 1.7.x, and 1.6.x are affected by this issue.

Vulnerability Detail

The vulnerability in Pydantic arises when 'infinity', 'inf', float('inf'), or their negatives are passed to datetime or date fields. When these values are encountered, the validation process enters an infinite loop, consuming excessive CPU resources. This can result in a Denial of Service (DoS) condition, impacting the availability of the affected application. The vulnerability has been assigned CVE-2021-29510 and has been addressed in Pydantic versions 1.8.2, 1.7.4, and 1.6.2.

How To Fix

Latest published version: 2.14.1 as of 23 Oct 2026

pip install --upgrade "pydantic==2.14.1"

Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.

If you can't move to the latest

The minimum fixed version depends on the release line you run.

  • < 1.6.2 1.6.2
    pip install --upgrade "pydantic==1.6.2"
  • >= 1.7, < 1.7.4 1.7.4
    pip install --upgrade "pydantic==1.7.4"
  • >= 1.8, < 1.8.2 1.8.2
    pip install --upgrade "pydantic==1.8.2"

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Workaround

If upgrading Pydantic is not immediately feasible, a temporary workaround can be implemented using a validator to catch the problematic values. The Pydantic documentation provides guidance on using validators (https://pydantic-docs.helpmanual.io/usage/validators/). However, it is important to note that this workaround is not ideal and upgrading to a fixed version of Pydantic is strongly recommended.

Conclusion

The vulnerability in Pydantic can be mitigated by upgrading to one of the fixed versions: v1.8.2, v1.7.4, or v1.6.2. It is important to promptly address this issue to prevent potential Denial of Service (DoS) attacks. For further assistance or support in vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for pydantic →

Share this vulnerability

FAQ

Pydantic is a Python library used for data validation and settings management. It leverages Python type hinting to provide robust data validation capabilities.

The vulnerability allows an attacker to trigger an infinite loop in Pydantic, leading to 100% CPU usage on one CPU core. This can result in a Denial of Service (DoS) condition, impacting the availability of the affected application.

Pydantic versions 1.8.x, 1.7.x, and 1.6.x are affected by this vulnerability.

To fix the vulnerability, it is recommended to upgrade Pydantic to one of the patched versions: v1.8.2, v1.7.4, or v1.6.2.

A temporary workaround can be implemented using a validator to catch the problematic values. However, upgrading to a fixed version of Pydantic is strongly recommended.

Related vulnerabilities

Recent vulnerabilities recorded for pydantic.

How To Fix

Latest published version: 2.14.1 as of 23 Oct 2026

pip install --upgrade "pydantic==2.14.1"

Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.

If you can't move to the latest

The minimum fixed version depends on the release line you run.

  • < 1.6.2 1.6.2
    pip install --upgrade "pydantic==1.6.2"
  • >= 1.7, < 1.7.4 1.7.4
    pip install --upgrade "pydantic==1.7.4"
  • >= 1.8, < 1.8.2 1.8.2
    pip install --upgrade "pydantic==1.8.2"

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. 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