CVE-2025-68428: jsPDF has Local File Inclusion/Path Traversal vulnerability
Impact User control of the first argument of the loadFile method in the node.js build allows local file inclusion/path traversal.
If given the possibility to pass unsanitized paths to the loadFile method, a user can retrieve file contents of arbitrary files in the local file system the node process is running in. The file contents are included verbatim in the generated PDFs.
Other affected methods are: addImage, html, addFont.
Only the node.js builds of the library are affected, namely the dist/jspdf.node.js and dist/jspdf.node.min.js files.
Example attack vector:
js import { jsPDF } from "./dist/jspdf.node.js";
const doc = new jsPDF();
doc.addImage("./secret.txt", "JPEG", 0, 0, 10, 10); doc.save("test.pdf"); // the generated PDF will contain the "secret.txt" file
Patches The vulnerability has been fixed in jsPDF@4.0.0. This version restricts file system access per default. This semver-major update does not introduce other breaking changes.
Workarounds With recent node versions, jsPDF recommends using the --permission flag in production. The feature was introduced experimentally in v20.0.0 and is stable since v22.13.0/v23.5.0/v24.0.0. See the node documentation for details.
For older node versions, sanitize user-provided paths before passing them to jsPDF.
Credits Researcher: kilkat (Kwangwoon Kim)
Other sources
jsPDF is a library to generate PDFs in JavaScript. Prior to version 4.0.0, user control of the first argument of the loadFile method in the node.js build allows local file inclusion/path traversal. If given the possibility to pass unsanitized paths to the loadFile method, a user can retrieve file contents of arbitrary files in the local file system the node process is running in. The file contents are included verbatim in the generated PDFs. Other affected methods are addImage, html, and addFont. Only the node.js builds of the library are affected, namely the dist/jspdf.node.js and dist/jspdf.node.min.js files. The vulnerability has been fixed in jsPDF.0. This version restricts file system access per default. This semver-major update does not introduce other breaking changes. Some workarounds areavailable. With recent node versions, jsPDF recommends using the --permission flag in production. The feature was introduced experimentally in v20.0.0 and is stable since v22.13.0/v23.5.0/v24.0.0. For older node versions, sanitize user-provided paths before passing them to jsPDF.
— Red Hat
jsPDF is a library to generate PDFs in JavaScript. Prior to version 4.0.0, user control of the first argument of the loadFile method in the node.js build allows local file inclusion/path traversal. If given the possibility to pass unsanitized paths to the loadFile method, a user can retrieve file contents of arbitrary files in the local file system the node process is running in. The file contents are included verbatim in the generated PDFs. Other affected methods are addImage, html, and addFont. Only the node.js builds of the library are affected, namely the dist/jspdf.node.js and dist/jspdf.node.min.js files. The vulnerability has been fixed in jsPDF@4.0.0. This version restricts file system access per default. This semver-major update does not introduce other breaking changes. Some workarounds areavailable. With recent node versions, jsPDF recommends using the --permission flag in production. The feature was introduced experimentally in v20.0.0 and is stable since v22.13.0/v23.5.0/v24.0.0. For older node versions, sanitize user-provided paths before passing them to jsPDF.
— NVD
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
npm/jspdfto a version that resolves this vulnerability.Fixed in 4.0.0 - Upgrade
Upgrade
jsPDFto a version that resolves this vulnerability.Fixed in 4.0.0 - Compensating control
For production on recent Node.js versions, run the jsPDF node.js build with the Node.js `--permission` flag (per node documentation referenced in the material) to restrict file system access.
Event History
Frequently Asked Questions
What is the severity of CVE-2025-68428?
CVE-2025-68428 has been classified as a significant vulnerability due to its potential for local file inclusion and path traversal.
How do I fix CVE-2025-68428?
To remediate CVE-2025-68428, upgrade the jsPDF package to version 4.0.0 or later.
What software is affected by CVE-2025-68428?
CVE-2025-68428 affects the jsPDF package, specifically versions up to 3.0.4.
What are the potential risks of CVE-2025-68428?
The risks of CVE-2025-68428 include unauthorized access to sensitive local files and potential data breaches.
How can I determine if my application is vulnerable to CVE-2025-68428?
To check if your application is vulnerable to CVE-2025-68428, verify if it uses jsPDF version 3.0.4 or below.