The vulnerability analysis of CVE-2026-22691 in pypdf reveals three distinct denial-of-service vulnerabilities that were addressed in a single patch. The primary vulnerability, and the one highlighted in the advisory title, is due to an inefficient regular expression in the PdfReader._rebuild_xref_table method. This regex could be exploited by a crafted PDF containing excessive whitespace, leading to catastrophic backtracking and causing the application to hang.
In addition to the ReDoS vulnerability, the patch also fixes two other issues:
- An unbounded loop in the
PdfReader.root_object method, which could be triggered by a forged /Size attribute in the PDF trailer, leading to excessive CPU usage.
- An infinite recursion vulnerability in the
PdfDocCommon._flatten method, caused by a lack of checks for cyclic page references in the PDF structure.
All three vulnerabilities can be triggered when parsing a malicious PDF file in the default non-strict mode. The identified functions (PdfReader._rebuild_xref_table, PdfReader.root_object, and PdfDocCommon._flatten) are the direct locations of these vulnerabilities, and their corresponding fixes are clearly visible in the provided commit.