jsPDF Flaw Lets Attackers Embed Local Files in PDFs
CVE-2025-68428 enables path traversal in the popular JavaScript PDF library, allowing attackers to read arbitrary files from Node.js servers and exfiltrate them via generated documents.
A critical path traversal vulnerability in jsPDF, a JavaScript library downloaded 3.5 million times weekly from npm, allows attackers to read arbitrary files from servers running Node.js applications. The flaw enables embedding sensitive data—configuration files, environment variables, credentials—directly into generated PDF documents.
Security researcher Kwangwoon Kim (kilkat) discovered CVE-2025-68428 and reported it through GitHub's security advisory process. The vulnerability affects all versions through 3.0.4 and carries a CVSS 4.0 score of 9.2.
How CVE-2025-68428 Works
The vulnerability exists in jsPDF's loadFile method within Node.js builds. When an application passes user-controlled input as a file path argument, the library reads that file from disk and incorporates its contents into the generated PDF output. There's no path sanitization—attackers can use directory traversal sequences like ../ to access files outside the intended directory.
Multiple methods are vulnerable:
loadFileaddImagehtmladdFont
Consider a web application that lets users generate PDF reports with custom images. If the application passes user input directly to addImage without sanitization, an attacker could submit a path like ../../../etc/passwd and receive a PDF containing the server's password file.
The attack doesn't stop at reading files. Because the stolen data embeds in a PDF the application generates and returns, the attacker receives the exfiltrated information through the application's normal output channel. No separate data exfiltration infrastructure required.
Real-World Attack Scenarios
The vulnerability is most dangerous in applications that:
- Generate PDFs with user-supplied content - Invoice generators, report builders, certificate creators
- Allow custom images, fonts, or HTML - Any application accepting file paths from users
- Run Node.js on the server side - Browser-based jsPDF usage is not affected
An attacker exploiting CVE-2025-68428 could steal:
.envfiles containing API keys and database credentials- SSH private keys
- Cloud provider credentials
- Internal configuration files revealing architecture details
- Source code and intellectual property
Why This Matters
jsPDF appears in dependency trees across countless Node.js applications. The npm package itself shows 3.5 million weekly downloads, but the true exposure includes every application and package that depends on it. Developers often include jsPDF to generate invoices, reports, or certificates without realizing the security implications of combining file system access with user input.
The vulnerability is particularly insidious because it doesn't crash the application or generate obvious errors. A successful attack produces a valid PDF document—it just contains additional content the developer never intended to include.
Affected Versions
- Vulnerable: jsPDF versions 0.0.1 through 3.0.4
- Fixed: jsPDF version 4.0.0 and later
The fix restricts filesystem access by default in Node.js builds. Applications requiring file system access must explicitly enable it and implement their own path validation.
Remediation Steps
- Upgrade to jsPDF 4.0.0 or later - This is the primary fix
- Enable Node.js permission mode - Use the
--permissionflag when running Node.js applications (stable since Node.js 22.13.0/23.5.0/24.0.0) - Sanitize user input - Never pass user-controlled strings directly to jsPDF file methods
- Review dependencies - Check if any packages in your dependency tree include vulnerable jsPDF versions
For applications that cannot immediately upgrade, implement strict input validation on any paths passed to jsPDF methods. Reject inputs containing .., absolute paths, or characters that could enable traversal attacks.
Detection Guidance
Monitor for:
- Unusual file access patterns from Node.js processes
- PDF generation requests containing path traversal sequences
- Generated PDFs with unexpectedly large file sizes (may indicate embedded sensitive data)
Applications logging PDF generation requests should audit logs for path traversal attempts in file parameters.
The Broader Pattern
CVE-2025-68428 joins a growing list of vulnerabilities in popular npm packages that affect millions of applications through dependency chains. The LangChain secret theft vulnerability we covered recently demonstrated similar risks from AI framework dependencies.
JavaScript's npm ecosystem enables rapid development but distributes security risks across thousands of packages. When a foundational library like jsPDF contains a vulnerability, the blast radius extends to every application built on top of it. Security teams should prioritize dependency scanning and consider tools that track transitive dependencies for known vulnerabilities.
Related Articles
12 Critical Flaws in vm2 Node.js Sandbox Enable Host Takeover
Security researchers disclosed 12 sandbox escape vulnerabilities in vm2, including three with CVSS 10.0 scores. The popular JavaScript isolation library can no longer be trusted to contain untrusted code.
May 8, 2026Protobuf.js RCE Flaw Threatens 50 Million Weekly npm Downloads
Critical code injection vulnerability (GHSA-xq3m-2v4x-88gg, CVSS 9.9) in protobuf.js allows arbitrary JavaScript execution via malicious schemas. Patch now.
Apr 18, 2026AzuraCast Patches Two High-Severity Flaws: RCE and Account Takeover
Two vulnerabilities in AzuraCast radio automation software enable authenticated RCE via path traversal and unauthenticated account takeover through password reset poisoning. Upgrade to 0.23.6 now.
May 10, 2026CrowdStrike LogScale Path Traversal Lets Attackers Read Any File
CVE-2026-40050 exposes CrowdStrike LogScale servers to unauthenticated file access via path traversal. CVSS 9.8—here's who's affected and how to patch.
Apr 25, 2026