PDF readers aren't just document viewers—they're full-blown execution environments. That harmless-looking invoice or resume you open could be running JavaScript code on your machine, and researchers just found 31 ways that code could go horribly wrong.
The Hidden Attack Surface in Your PDF Reader
The PDF specification supports embedded JavaScript, allowing interactive forms, dynamic content, and automated workflows. This functionality turns your PDF reader into a JavaScript runtime—complete with its own API for file system access, network requests, and system interaction.
That's exactly what makes it dangerous. When a malicious PDF executes JavaScript, it can potentially:
- Trigger memory corruption vulnerabilities
- Exfiltrate data from opened documents
- Execute arbitrary code on your system
- Launch network attacks against internal systems
Security researchers have long suspected this attack surface was underexplored. A recent academic project called PDFuzzer proved just how bad things really are.
PDFuzzer: Automated Discovery of PDF JavaScript Bugs
Researchers built PDFuzzer specifically to fuzz test the JavaScript engines embedded in PDF readers. Unlike traditional fuzzers that throw random data at software, PDFuzzer uses Large Language Models to understand the complex relationships between PDF JavaScript API calls.
The tool generated sophisticated test cases that chained multiple API calls together—exposing vulnerabilities that simple single-call tests would never find. The results were alarming.
Key Findings
- 31 unique zero-day vulnerabilities discovered across Adobe Acrobat Reader, Foxit PDF Reader, and PDF-XChange Editor
- 11 high-severity bugs that could lead to arbitrary code execution
- 48% more code coverage compared to previous fuzzing approaches
- Vulnerabilities include use-after-free, buffer overflows, and information leakage
Real-World Exploitation: CVE-2024-28888 and CVE-2024-34099
These aren't theoretical vulnerabilities. Real-world exploits have already been spotted in the wild:
- CVE-2024-28888 — JavaScript-based PDF exploitation observed in active attacks
- CVE-2024-34099 — Another in-the-wild PDF JavaScript vulnerability
These CVEs demonstrate that attackers are actively exploring this attack vector. The PDFuzzer research confirms what penetration testers have suspected: the PDF JavaScript API surface is riddled with holes.
Server-Side PDF Libraries Aren't Safe Either
If you process PDFs on a server—whether for document conversion, report generation, or PDF creation—there's more bad news. The popular jsPDF library has accumulated multiple CVEs in recent months:
- CVE-2025-68428 — Local file inclusion in Node.js builds (CVSS 9.8). Attackers could read server files and embed their contents in generated PDFs.
- CVE-2026-31938 — HTML injection in browser output methods
- CVE-2026-25755 — PDF object injection via addJS
- CVE-2026-24040 — Cross-user data leakage in concurrent PDF generation
If your web application accepts filenames, HTML content, or user-controlled paths for PDF generation, you could be exposed.
Electron Apps: From PDF XSS to Code Execution
Here's where things get really interesting. Applications built on Electron that use PDF.js aren't just vulnerable to document-based attacks—their own APIs can be weaponized.
Researchers demonstrated how a malicious PDF loaded in an Electron app (like Logseq or Slack) could:
- Exploit a PDF.js cross-site scripting vulnerability
- Use the injected JavaScript to call the Electron app's internal APIs
- Execute shell commands on the host system
The PDF was just the initial vector. The real prize was the privileged API surface of the Electron container.
How to Detect Malicious JavaScript in PDFs
Given the severity of these vulnerabilities, you need to inspect PDF files before opening them. Here's how:
1. Check for Embedded JavaScript
# Using pdfid (from Didier Stevens)
pdfid.py suspicious.pdf
# Look for /JS and /JavaScript counts
# Non-zero values indicate embedded scripts
2. Examine PDF Structure
# Use peepdf for detailed analysis
peepdf -f suspicious.pdf
# Look for:
# - /OpenAction entries
# - /AA (additional actions)
# - /JS streams
# - Suspicious object references
3. Extract and Analyze JavaScript
# Use pdf-parser to extract JS streams
pdf-parser.py --search=JavaScript suspicious.pdf
4. Test in a Sandbox
Always open suspicious PDFs in an isolated environment—virtual machines, sandboxes, or dedicated analysis environments. Monitor network traffic and file system activity.
Mitigation Strategies
- Disable JavaScript in your PDF reader settings
- Keep PDF readers updated—vendors are patching actively
- Block PDF execution in email gateways where possible
- Implement network segmentation for servers processing PDFs
For developers using jsPDF or similar libraries, update immediately. The maintainers have released patches, but the vulnerability history suggests more bugs likely exist in the complex PDF generation pipeline.
The Bigger Picture
What makes this research significant isn't just the 31 vulnerabilities—it's the methodology. PDFuzzer demonstrated that the PDF JavaScript API surface is largely unexplored territory. With over 30% of PDF reader functions undocumented, attackers and security researchers alike have plenty of room to discover new exploit techniques.
The PDF format was designed for portability, not security. Every feature that makes PDFs useful—JavaScript, embedded files, form actions—also creates potential attack vectors. As this research shows, we haven't seen the end of PDF-based vulnerabilities.
Stay vigilant, keep your PDF software updated, and treat unexpected PDF attachments with the same caution you'd give any executable file.