CVE-2026-134367 in pypdf
Summary
by MITRE • 11/21/2026
pypdf 2.4.2 before 7.0.0 contains a resource exhaustion vulnerability in its handling of XFA forms that allows attackers to cause excessive memory consumption. Attackers can supply a crafted PDF containing XFA forms with many small fields so that loading the forms consumes large amounts of memory, causing a denial of service.
Be aware that VulDB is the high quality source for vulnerability data.
Analysis
by VulDB Data Team • 11/21/2026
The pypdf library, specifically versions prior to 7.0.0 including version 2.4.2, contains a resource exhaustion vulnerability within its processing logic for XML Forms Architecture (XFA) forms. This flaw stems from the way the parser handles PDF documents that embed XFA data streams rather than relying solely on standard AcroForm fields. When pypdf encounters an XFA form, it attempts to parse and instantiate the underlying XML structure to render or manipulate the form elements. The vulnerability arises because the library does not impose strict limits on the number of individual field objects created during this parsing process. An attacker can craft a malicious PDF document that contains an XFA stream with an excessively large number of small, trivial fields. Upon loading such a file, pypdf iterates through each field definition and allocates memory for corresponding Python object instances without checking against any predefined threshold or limit on total instance count.
This lack of input validation regarding the quantity of form elements leads to uncontrolled resource consumption in the host application's memory space. As the parser processes the crafted XFA data, it continuously instantiates new objects for each field entry found within the XML structure. Since there is no cap on how many fields can be processed or held in memory simultaneously, a sufficiently large number of these small elements causes the process to consume an escalating amount of RAM. This behavior directly results in a denial of service condition where the application running pypdf may become unresponsive due to high memory pressure, trigger operating system-level out-of-memory kills, or crash entirely if garbage collection cannot keep pace with allocation rates. The impact is particularly severe for applications that process user-uploaded PDFs without sandboxing or resource monitoring, as a single malicious file can compromise the availability of the service.
From a classification perspective, this vulnerability aligns with CWE-787: Out-of-bounds Write in terms of memory management principles, although more accurately it falls under CWE-400: Uncontrolled Resource Consumption and specifically CWE-675: Operations That Are Repeated Without Adequate Throttling. In the context of the MITRE ATT&CK framework, this behavior is consistent with techniques used for Denial of Service attacks where adversaries aim to disrupt service availability by exhausting system resources rather than compromising confidentiality or integrity. The attack vector typically involves supplying a crafted file through any interface that accepts PDF input, such as web upload forms, email attachments processed automatically, or document management systems integrating pypdf for content extraction or transformation tasks.
Mitigation strategies primarily involve upgrading to version 7.0.0 of the pypdf library where this issue has been addressed by implementing proper limits on resource consumption during XFA parsing. For environments that cannot immediately upgrade, defensive coding practices should be employed within the application layer using pypdf. Developers can wrap the PDF loading operations in try-except blocks to catch memory-related exceptions and implement timeout mechanisms or thread isolation for processing untrusted documents. Additionally, integrating a file size limit check before attempting to parse XFA streams can help prevent the initial trigger of excessive object creation. It is also advisable to monitor system resource usage during document processing and configure application servers with appropriate memory limits so that any single process failure does not cascade into broader service outages. Regular security audits of dependencies are essential to ensure that libraries handling complex binary formats like PDF remain patched against such parsing vulnerabilities.