REDHAT-BUG-2427236: Path Traversal
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.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
jsPDFto a version that resolves this vulnerability.Fixed in 4.0.0 - Configuration
Before passing any user-provided path into jsPDF methods that accept paths (loadFile, addImage, html, addFont), sanitize the path to prevent local file inclusion/path traversal in the node.js builds (dist/jspdf.node.js and dist/jspdf.node.min.js).
jsPDF node.js build (dist/jspdf.node.js / dist/jspdf.node.min.js) loadFile: sanitize user-provided paths = Use a whitelist/normalization-based sanitization for any user-supplied path before calling loadFile, addImage, html, and addFont in node builds
Event History
Frequently Asked Questions
What is the severity of REDHAT-BUG-2427236?
The severity of REDHAT-BUG-2427236 is classified as high, with a score of 7.
How do I fix REDHAT-BUG-2427236?
To fix REDHAT-BUG-2427236, upgrade the jsPDF library to version 4.0.0 or later to mitigate the local file inclusion/path traversal vulnerability.
What security risk does REDHAT-BUG-2427236 present?
REDHAT-BUG-2427236 presents a risk of local file inclusion/path traversal, allowing unauthorized access to potentially sensitive files.
Which version of jsPDF is affected by REDHAT-BUG-2427236?
Versions of jsPDF prior to 4.0.0 are affected by REDHAT-BUG-2427236.
What type of vulnerability is REDHAT-BUG-2427236 classified as?
REDHAT-BUG-2427236 is classified as a Path Traversal vulnerability.