Impact
An attacker can read sensitive local files from the server's filesystem by exploiting a path traversal vulnerability in the loadFile method [S1]. This occurs when an application using the Node.js build of jsPDF passes unsanitized user input into the first argument of this method [S1].
Root Cause
The root cause is a lack of input validation and sanitization in the loadFile method within the jsPDF Node.js build [S1]. Specifically, the method does not restrict the file path provided as the first argument, allowing directory traversal sequences (like ../) to escape the intended directory and access arbitrary files on the host system [S1]. This issue affects all versions of jsPDF prior to 4.0.0 [S1].
How FixVibe could detect it
FixVibe could detect this vulnerability through several scanning modes:
- Repository Scanning: By analyzing
package.jsonor lock files (e.g.,package-lock.json,yarn.lock), FixVibe can identify if a project is using a version ofjspdfearlier than 4.0.0 [S1]. - Static Analysis (SAST): FixVibe's code scanner could look for patterns where user-controlled data (from request parameters, headers, or database fields) is passed directly into the
loadFilemethod of a jsPDF instance without prior sanitization. - Active Probing: If an application exposes an endpoint that generates PDFs based on user-provided file paths or templates, FixVibe could attempt to inject path traversal sequences to verify if the server attempts to load unauthorized local files.
Remediation
To mitigate this vulnerability, developers should:
- Upgrade jsPDF: Update the
jspdfdependency to version 4.0.0 or later, where this issue has been addressed [S1]. - Sanitize Inputs: If upgrading is not immediately possible, ensure that any input passed to
loadFileis strictly validated against an allowlist or sanitized to remove traversal characters like..,/, and\[S1].
