Oct 23, 2026·5 min read·15 visits
pypdf versions prior to 6.21.0 lack upper element bounds and cumulative token limits when deserializing PDF arrays, dictionaries, and streams. Attackers can submit malformed PDFs to trigger high CPU usage and out-of-memory process crashes.
A Denial of Service (DoS) vulnerability in pypdf versions prior to 6.21.0 allows remote attackers to cause high CPU and memory resource exhaustion by supplying PDF files containing oversized or deeply nested arrays, dictionaries, or content streams.
The Python PDF manipulation library pypdf is susceptible to uncontrolled resource consumption (CWE-400 / CWE-770) during PDF container deserialization. Prior to version 6.21.0, the library processed primitive PDF container structures sequentially without verifying upper bounds on element counts or enforcing a global token budget.
PDF documents structure raw metadata and stream data into three core collection mechanisms: Arrays, Dictionaries, and Content Streams. When parsing these entities, pypdf eagerly allocated Python objects for every token encountered within stream boundaries. An attacker can construct a compact, highly compressed PDF containing millions of small elements to induce memory exhaustion or execution loops.
This flaw impacts web applications, background document pipelines, and API services that ingest untrusted PDF uploads using vulnerable pypdf releases.
The root cause resides in the token parsing logic implemented within ArrayObject.read_from_stream, DictionaryObject.read_from_stream, and ContentStream._parse_content_stream. The library assumed stream content was bounded implicitly by file length or decompressed stream limits.
During stream processing, the parser reads consecutive tokens and instantiates corresponding Python wrapper types (NumberObject, NameObject, BooleanObject, NullObject). Because Python object creation incurs per-instance memory overhead, dense token streams demand memory disproportionate to file size on disk.
> [!NOTE]
> A PDF array containing 1,000,000 integer tokens requires minimal stream storage, but causes pypdf to allocate hundreds of megabytes of Python heap memory during deserialization.
Additionally, generic exception handlers inside structural parsing functions previously caught and suppressed underlying security exceptions. If a sub-routine encountered a parsing boundary error, the container parser suppressed the signal and continued consumption.
In commit 18bd2981a74479483a0b9507602c58a63d6c9b12 (Pull Request #4218), maintainers implemented global token tracking and safety thresholds in pypdf/_configuration.py and pypdf/generic/_data_structures.py.
The patch introduces explicit collection caps alongside a shared, mutable budget context (StreamParsingBudget):
# pypdf/_configuration.py snippet
array_maximum_element_count: int = 100_000
dictionary_maximum_element_count: int = 100_000
stream_parsing_work_maximum_count: int = 2_000_000The ArrayObject.read_from_stream method was modified to check remaining quotas before appending new elements:
# Patch diff in ArrayObject._check_limits
@staticmethod
def _check_limits(*, remaining_elements: int, parsing_budget: Optional[StreamParsingBudget]) -> int:
remaining_elements -= 1
if remaining_elements < 0:
raise LimitReachedError("Reached maximum array element count.")
if parsing_budget is not None:
parsing_budget.remaining_budget -= 1
if parsing_budget.remaining_budget < 0:
raise LimitReachedError("Reached maximum number of tokens.")
return remaining_elementsWhen LimitReachedError is raised, container parsers now propagate the exception directly rather than catching it in general exception handling clauses.
Exploitation requires sending a tailored PDF document to an application that invokes parsing methods on untrusted input. Authentication requirements depend entirely on the target application exposure.
An attacker constructs a document containing deeply nested collection structures or repetition patterns. For instance, a stream defining an array with millions of null tokens [ null null ... null ] causes pre-6.21.0 parsers to enter a long execution loop while repeatedly increasing heap memory usage.
%PDF-1.7
1 0 obj
<< /Type /Catalog /Pages 2 0 R >>
endobj
2 0 obj
<< /Type /Pages /Count 1 /Kids [3 0 R] >>
endobj
3 0 obj
<< /Type /Page /Parent 2 0 R /Contents 4 0 R >>
endobj
4 0 obj
<< /Length 50000 >>
stream
[ 0 0 0 0 ... <repeated 1,000,000 times> ... 0 ]
endstream
endobjWhen the application attempts to inspect or extract text from page content streams, the thread parsing the stream exhausts available memory, leading to an Out-Of-Memory (OOM) process termination.
The security impact is restricted to application availability. Unauthenticated users can trigger service disruptions by uploading crafted PDF documents to public endpoints.
Because Python handles memory allocation at the process level, exhaustion in a multi-threaded web worker (such as Gunicorn or uWSGI workers) results in worker termination by system kernel OOM killers, causing service degradation or total application outage.
CVSS v4.0 evaluates this issue with a base score of 6.0 (CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:P/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N). No confidentiality or integrity violations occur, and execution context boundaries prevent remote code execution through this bug class.
The primary remediation step is upgrading the pypdf dependency to version 6.21.0 or higher.
For applications requiring custom threshold definitions when handling untrusted documents, parameters can be customized dynamically using apply_configuration:
from pypdf import apply_configuration, PdfReader
from pypdf.errors import LimitReachedError
# Configure custom strict parsing limits
with apply_configuration(
array_maximum_element_count=10_000,
dictionary_maximum_element_count=10_000,
stream_parsing_work_maximum_count=500_000
):
try:
reader = PdfReader("untrusted_document.pdf")
text = reader.pages[0].extract_text()
except LimitReachedError:
# Gracefully drop or reject malformed inputs
raise ValueError("Uploaded file exceeded maximum parsing limits")Additionally, processing untrusted uploads inside isolated container environments with resource memory limits prevents host-wide Denial of Service.
CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:P/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N| Attribute | Detail |
|---|---|
| CWE ID | CWE-400 (Uncontrolled Resource Consumption) |
| CVSS v4.0 | 6.0 (Medium) |
| Attack Vector | Network (AV:N) |
| EPSS Score | 0.00317 (23.44th percentile) |
| Impact | Denial of Service (High Memory / CPU Resource Exhaustion) |
| Exploit Status | Proof of Concept / Test Suite Code Available |
| CISA KEV Status | Not Listed |
CVE-2026-126295 (also tracked as GHSA-fg9w-wfp5-j933) is a path confinement bypass vulnerability in the Natural Language Toolkit (NLTK) affecting versions 3.10.0 prior to 3.10.4. The flaw resides in nltk/parse/bllip.py within the BllipParser class and its factory method BllipParser.from_unified_model_dir(). Unlike sibling tool wrappers in NLTK that enforce data-root confinement via the nltk.pathsec module, BllipParser passes caller-supplied filesystem paths directly into the third-party bllipparser native C extension without validation. When an application passes untrusted input as model paths or directories to BllipParser, an attacker can force the native extension to open arbitrary files on the local filesystem. This leads to information disclosure through parser diagnostic oracles, local model tampering via shared directories, and denial of service by hanging worker threads on blocking special files (such as FIFOs or device nodes) or exhausting memory via oversized files.
CVE-2026-126300 (GHSA-ffr9-mgrr-wcvr) is an inefficient algorithmic complexity vulnerability (CWE-407) in the Natural Language Toolkit (NLTK) Python library affecting versions 3.2.5 prior to 3.10.4. The flaw resides in the quote-restoration routine of TreebankWordTokenizer.span_tokenize and NLTKWordTokenizer.span_tokenize, where repeated calls to list.pop(0) over matched quote tokens introduce quadratic O(n^2) time complexity. An unauthenticated remote attacker who supplies input containing long sequences of double-quote characters can exhaust CPU resources and degrade service availability.
The Natural Language Toolkit (NLTK) versions 3.6 through 3.10.3 contain an algorithmic complexity vulnerability in the LegalitySyllableTokenizer.tokenize method. When processing tokens composed of continuous runs of vowels, an unguarded string reversal and set membership lookup loop executes in quadratic time relative to the input token length. Remote attackers capable of submitting arbitrary text to applications utilizing this tokenizer can trigger sustained single-core CPU exhaustion and application-level denial of service.
CVE-2026-126304 is a symlink path traversal vulnerability (CWE-59) in the Natural Language Toolkit (NLTK) versions 3.10.0 prior to 3.10.4. The YCOECorpusReader class constructs internal sub-readers for the 'psd' and 'pos' subdirectories using FileSystemPathPointer.join(), which relies exclusively on lexical string-prefix validation rather than canonical path resolution. An attacker who supplies a crafted YCOE corpus containing symbolic links in place of the 'psd' or 'pos' subdirectories can bypass directory confinement and read arbitrary files from sibling corpora or sensitive directories within the NLTK data sandbox.
CVE-2026-128077 (GHSA-r99w-jh2x-3mg9) is an authorization bypass and interpretation conflict vulnerability affecting Nuxt and its underlying @nuxt/nitro-server package in versions 4.6.0 through 4.6.3. When an incoming HTTP request path begins with a double forward slash (e.g., //x/admin), the WHATWG URL parser within the Nuxt server-side page renderer interprets the initial segment as a network host/authority and resolves the remaining path (/admin) against the application's page router. Because Nitro server middleware, route-scoped serverHandlers, and Nitro routeRules evaluate the unparsed request path (//x/admin), path-based access controls, redirects, and security header policies configured for /admin fail to match and are bypassed.
Prior to version 2.10.2, the sqlite3-ruby gem explicitly cast 64-bit Ruby string lengths (long) to 32-bit signed integers (int) when invoking the underlying SQLite C API. On 64-bit platforms, providing a string of 4 GiB (2^32 bytes) or larger causes integer truncation, instructing SQLite to process only a prefix of the string. This flaw affects SQL query preparation, bound parameter values, and return values from custom Ruby-defined SQL functions and aggregates, allowing trailing SQL clauses such as WHERE restrictions to be silently dropped under specific conditions.