Safeguard
Vulnerability Analysis•

CVE-2024-3651: High Denial of Service in Python idna

CVE-2024-3651 is a high severity denial of service in the Python idna library 3.6, fixed in 3.7. Upgrade idna and bound the length of hostnames you encode.

Safeguard Security Team
3 min read

CVE-2024-3651 is a high severity denial of service (CVSS 7.5) in the Python idna library. In version 3.6, crafted input to idna.encode() takes quadratic time, so a short stream of requests can tie up a service. It is fixed in idna 3.7, released 11 April 2024. Upgrade, and cap the length of hostnames you accept.

Weakness class: CWE-1333.

What's affected

  • Product: kjd/idna, the Internationalized Domain Names in Applications library for Python, installed from PyPI as idna.
  • Affected: version 3.6, per the record description.
  • Fixed: 3.7. The release commit history entry is dated 11 April 2024 and names CVE-2024-3651.
  • Component: the idna.encode() function.
  • Severity: High, CVSS 7.5, per the record. The KEV flag is false.
  • Debian and Fedora published their own advisories, so distribution packages may carry backported fixes with different version numbers.

How to check if you're exposed

  1. Run pip show idna in each environment, or pip list | grep -i idna.
  2. For a project with a lock file, search requirements.txt, poetry.lock and Pipfile.lock for idna.
  3. In containers, run pip show idna inside the container image with docker run.
  4. The library is a transitive dependency of requests and many other packages, so check lock files, not only direct requirements.
  5. Scan with the free in-browser dependency scan to list every environment with idna 3.6.

What to do now

  1. Upgrade idna to 3.7 or later: use pip to install idna 3.7 or newer.
pip install --upgrade "idna>=3.7"
  1. Regenerate lock files and rebuild container images, so the fix reaches production.
  2. For Debian or Fedora system packages, install the distribution update that references the CVE.
  3. Add input limits: reject hostnames longer than 253 characters before they reach encode().
  4. Add a timeout or rate limit on endpoints that accept user supplied URLs.

Why it matters

The class is CWE-1333, inefficient regular expression complexity, which in practice means an algorithm whose cost grows faster than the input. Quadratic behavior is small for normal hostnames and expensive for crafted ones. Doubling the input size multiplies the work by four.

This is a useful reminder that denial of service bugs in widely shared libraries matter because of where the library sits. idna runs underneath HTTP clients, so any service that fetches user supplied URLs may be exposed through a dependency its authors never chose directly.

Dependency inventory is the main control. If you cannot list where idna 3.6 is installed, you cannot say whether you are exposed.

Try it yourself

Click through it at your own pace, or open it full screen.

Quick check

Which idna version fixes CVE-2024-3651?

Version 3.7.

Does my project use idna directly?

Often not. It is commonly pulled in by requests and other packages, so check your full dependency tree.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.