/

CVE-2025-68428

Severity:

HIGH RISK

(7.5)

Path Traversal / Local File Inclusion in jsPDF Node.js

CVE-2025-68428

Modified

Vulnerability type

Category:

Path Traversal / Local File Inclusion

CWE:

CWE-35, CWE-73, CWE-22

Impact:

Local File Disclosure / Information Exposure

Severity:

HIGH RISK

(7.5)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A path traversal and local file inclusion issue in jsPDF's Node.js builds allows user-controlled paths to be passed into file-loading methods such as loadFile, addImage, html, and addFont.

When untrusted input is used as the first argument to these APIs, an attacker can cause jsPDF to read arbitrary files from the local filesystem and embed their contents directly into generated PDFs.

Affected context

This vulnerability affects applications that:

  • Use jsPDF in a Node.js environment (specifically dist/jspdf.node.js or dist/jspdf.node.min.js)
  • Allow user input to influence the file path argument of loadFile, addImage, html, or addFont
  • Run jsPDF with filesystem access in the same privilege context as the Node.js process

The risk is elevated in multi-user or internet-facing services where end users can indirectly or directly control file paths used by jsPDF.

Exploit preconditions

  • Attack surface: Server-side jsPDF usage in Node.js where PDFs are generated dynamically based on user input
  • Required access: Ability to supply or influence path-like data passed into jsPDF methods (loadFile, addImage, html, addFont)
  • Trigger point: Invocation of these methods with unsanitized, attacker-controlled path values
  • Why exploitation is possible: The Node.js build of jsPDF accesses the local filesystem using caller-supplied paths without enforcing strict path normalization, directory whitelisting, or permission boundaries, enabling traversal outside intended directories.

Why this happens

The underlying issue is the direct use of untrusted input as filesystem paths in the Node.js build of jsPDF, without robust validation or restriction.

This behavior maps primarily to CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), because user-supplied paths can escape the intended directory.

It also relates to CWE-35/CWE-73, where external inputs control resource names and configuration, allowing access to arbitrary local files.

Conceptually, the bug stems from treating user data as trusted file identifiers in a context where the runtime has broad filesystem privileges, and then embedding whatever is read directly into the generated PDF.

Potential impact

  • Disclosure of sensitive local files (e.g., application logs, configuration files, access tokens) via generated PDFs
  • Exposure of secrets or credentials stored alongside the application (API keys, database passwords)
  • Leakage of source code or proprietary business logic present on the server
  • Indirect assistance to further attacks (privilege escalation, lateral movement) by revealing environment details

General mitigation guidance

Effective mitigation focuses on constraining file access and reducing trust in user-controlled paths:

  • Introduce a strict allowlist of directories or file identifiers that can be used with jsPDF, rejecting any input outside these sets
  • Normalize and validate paths before use, ensuring they remain within an approved base directory and disallowing patterns that indicate traversal
  • Avoid passing raw user input as filesystem paths; instead, map user-selectable options to internal identifiers that resolve to safe, predefined files
  • Run the Node.js process with the minimum required filesystem permissions and limit access to sensitive directories where possible
  • Use runtime controls (such as Node.js permission flags where available) to restrict file system access by default

How teams detect issues like this

Detection typically involves both code-centric and runtime-focused approaches:

  • Static analysis: Search for calls to jsPDF's loadFile, addImage, html, and addFont where arguments derive from request data, query parameters, form fields, or other user-controlled sources without intermediate validation
  • Code review signals: Flag any code that concatenates or forwards user-provided strings into file paths, especially when used within PDF generation or image/font loading logic
  • Automated checks: Configure SAST tools or custom linters to alert on use of unvalidated paths passed to filesystem-related APIs or jsPDF wrapper functions
  • Runtime monitoring: Instrument logging around file access calls used during PDF generation, looking for unexpected directories, traversal sequences, or unusual file names being read

Sources

SourceLink
github.comgithub.com/parallax/jsPDF/commit/a688c8f479929b24a6543b1fa2d6364abb03066d
github.comgithub.com/parallax/jsPDF/releases/tag/v4.0.0
github.comgithub.com/parallax/jsPDF/security/advisories/GHSA-f8cm-6447-x5h2
access.redhat.comaccess.redhat.com/errata/RHSA-2026:1517
access.redhat.comaccess.redhat.com/errata/RHSA-2026:2350
access.redhat.comaccess.redhat.com/errata/RHSA-2026:2568
access.redhat.comaccess.redhat.com/security/cve/CVE-2025-68428
bugzilla.redhat.combugzilla.redhat.com/show_bug.cgi?id=2427236
security.access.redhat.comsecurity.access.redhat.com/data/csaf/v2/vex/2025/cve-2025-68428.json

Frequently asked

questions

Yes, if jsPDF is used in a server-side Node.js context and remote users can influence the file path arguments passed to vulnerable methods. In such setups, an attacker can cause the server to read local files and embed their contents into PDFs returned over the network.

The attacker needs the ability to provide or manipulate the parameters that eventually become the path arguments to loadFile, addImage, html, or addFont. They do not need shell access; control over HTTP request fields or similar inputs may be sufficient.

The safest pattern is to avoid using raw user input as filesystem paths. Instead, define a closed set of allowed resources (files, templates, fonts) and map user choices to these internal identifiers, combined with strict path normalization and directory whitelisting.

Establish a consistent file-access pattern across the codebase: treat all external input as untrusted, validate or map it before it influences filesystem operations, enforce least-privilege at the OS and runtime level, and incorporate checks for path traversal and resource access misuse into code review and automated security testing.

Find out what's already
exploitable in your codebase.