Executive brief
A vulnerability in Python's XML parsing library (pyexpat) can allow an attacker to crash an application by providing a specially crafted XML file. This occurs when the parser processes a document with deeply nested definitions, leading to a system memory error. This could result in a denial-of-service, impacting the availability of services that process untrusted XML data.
Technical details
A stack overflow vulnerability (CWE-674: Uncontrolled Recursion) exists in the `conv_content_model` function within `pyexpat.c`. When an Expat parser with a registered `ElementDeclHandler` processes an inline Document Type Definition (DTD) containing a deeply nested content model, it triggers unbounded C recursion. An unauthenticated remote attacker can exploit this by providing a malicious XML document, leading to a crash of the Python interpreter. Patches have been released across multiple Python branches (3.10 through 3.15) to limit recursion depth.
Affected products
- Python Software Foundation Python < 3.10.0, 3.13.0 to < 3.13.13, 3.14.0 to < 3.14.4, 3.15.0-alpha1 to 3.15.0-alpha7
Timeline
- 2026-03-14: other: Security fix prepared in CPython repository
- 2026-03-16: disclosed: Vulnerability disclosed and CVE assigned
- 2026-03-16: patched: Fixes merged into main CPython branches
- 2026-03-16: advisory: NVD published the advisory
References
- https://github.com/python/cpython/commit/196edfb06a7458377d4d0f4b3cd41724c1f3bd4a
- https://github.com/python/cpython/commit/642865ddf4b232da1f3b1f7abcfa3254c4bfe785
- https://github.com/python/cpython/commit/af856a7177326ac25d9f66cc6dd28b554d914fee
- https://github.com/python/cpython/commit/e0a8a6da90597a924b300debe045cdb4628ee1f3
- https://github.com/python/cpython/commit/eb0e8be3a7e11b87d198a2c3af1ed0eccf532768
- https://github.com/python/cpython/issues/145986
- https://github.com/python/cpython/pull/145987