CriticalVulnerability

Critical jsPDF Vulnerability Lets Attackers Steal Server Files via Generated PDFs

A critical path traversal flaw in the popular jsPDF library allows attackers to read arbitrary files from servers and exfiltrate sensitive data by embedding it directly into generated PDF documents. With over 3.5 million weekly downloads, the impact could be massive.

Evan Mael
Evan Mael
16views
CVE IDCVE-2025-68428
CVSS Score9.8 Critical
Affected VersionsjsPDF < 3.0.1
NPM Impact45M+ weekly downloads

A critical security vulnerability has been discovered in jsPDF, one of the most popular JavaScript libraries for generating PDF documents. The flaw, tracked as CVE-2025-68428, allows attackers to read arbitrary files from server filesystems and exfiltrate their contents by embedding them directly into generated PDF documents.

Vulnerability Overview
CVE IDCVE-2025-68428
CVSS Score9.2 (Critical)
Weekly Downloads3.5 million+
Affected BuildsNode.js only
Fixed Version4.0.0

With over 3.5 million weekly downloads on npm, jsPDF is widely deployed across enterprise applications, SaaS platforms, and developer projects worldwide. Organizations using the Node.js build of this library should update immediately.

How the Attack Works

The vulnerability stems from insufficient input validation in the loadFile method within jsPDF's Node.js builds. When user-controlled input is passed as a file path argument, the library reads the specified file from disk and incorporates its contents verbatim into the generated PDF output.

Security researchers at Endor Labs, who published a detailed technical analysis, explain that multiple methods are affected beyond loadFile:

Affected MethodsInternal Behavior
addImageCalls vulnerable loadFile
htmlCalls vulnerable loadFile
addFontCalls vulnerable loadFile

All of these methods internally call the vulnerable loadFile function, meaning any unsanitized path passed to them becomes an attack vector.

Proof of Concept: A simple exploitation demonstrates the severity:

import { jsPDF } from "./dist/jspdf.node.js";
const doc = new jsPDF();
doc.addImage("../../../etc/passwd", "JPEG", 0, 0, 10, 10);
doc.save("output.pdf");
// The generated PDF now contains the server's /etc/passwd file

The file type parameter (e.g., "JPEG") does not prevent non-image files from being read. The library reads whatever file path is provided and embeds the raw content. Path traversal sequences like ../ allow attackers to navigate outside the intended directory.

What's at Risk

Successful exploitation could expose any file readable by the Node.js process:

Exposed Data TypeImpact
Configuration filesDatabase credentials exposed
Environment variablesAPI keys and secrets leaked
Application source codeIntellectual property theft
Private keys/certificatesComplete system compromise
System files/etc/passwd, /etc/shadow access

Stealth Exfiltration: The attack is particularly dangerous because the stolen data is exfiltrated through normal application output - the generated PDF itself. This makes detection challenging since no anomalous network connections are required.

Who Is Affected

Only the Node.js builds of jsPDF are vulnerable:

  • dist/jspdf.node.js
  • dist/jspdf.node.min.js

Browser-based implementations are not affected because browsers enforce strict sandbox policies that prevent JavaScript from directly accessing the local filesystem.

However, the vulnerability becomes exploitable in any scenario where:

  • User-controlled input reaches the affected methods
  • File paths are not explicitly sanitized
  • No allowlist restricts which files can be loaded

Patch and Mitigation

The vulnerability has been fixed in jsPDF version 4.0.0, released on January 3, 2026. This version restricts filesystem access by default and relies on Node.js permission mode for additional protection.

Immediate Actions Required

PriorityAction
CriticalUpdate to jsPDF 4.0.0 immediately
HighAudit all user input reaching affected methods
MediumImplement input validation as defense-in-depth
RecommendedEnable Node.js permission mode in production

For environments that cannot immediately upgrade, the following mitigations are recommended:

For Node.js v22.13.0+ / v23.5.0+ / v24.0.0+:

node --permission --allow-fs-read=/app/allowed-directory app.js

Warning: Endor Labs cautions that the --permission flag affects the entire Node.js process, not just jsPDF. Additionally, overly broad filesystem permissions in the --allow-fs-read configuration can negate the fix entirely.

For older Node.js versions: Rigorously sanitize all user-provided file paths before passing them to jsPDF functions. Implement strict allowlists for permitted files.

Security Recommendations

Organizations using jsPDF in Node.js environments should take immediate action:

StepDescriptionPriority
1Audit immediately - determine if affected versions are in useCritical
2Update to version 4.0.0 - patch as soon as possibleCritical
3Review code - check for user-controlled input reaching affected methodsHigh
4Implement input validation - defense-in-depth regardless of versionHigh
5Enable permission mode - for Node.js production deploymentsMedium

Credit

The vulnerability was discovered and responsibly disclosed by security researcher Kwangwoon Kim (kilkat). The jsPDF maintainers at Parallax delivered a prompt fix following the disclosure.

Bottom Line: Given jsPDF's widespread adoption and the CVSS 9.2 critical severity rating, CVE-2025-68428 is a strong candidate for active exploitation. Security teams should prioritize this patch immediately.

Incident Summary

Type
Vulnerability
Severity
Critical
Published
Jan 8, 2026

Comments

Want to join the discussion?

Create an account to unlock exclusive member content, save your favorite articles, and join our community of IT professionals.

Sign in