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.
jsPDF versions prior to 4.0.0 contain a local file inclusion vulnerability in the Node.js build that allows attackers to read arbitrary files from the system through unsanitized path parameters in loadFile, addImage, html, and addFont methods. The vulnerability enables disclosure of sensitive file contents that are embedded in generated PDFs.
تؤثر هذه الثغرة على مكتبة jsPDF المستخدمة لإنشاء ملفات PDF في بيئات Node.js. يمكن للمهاجمين الذين لديهم القدرة على التحكم في معاملات المسار قراءة أي ملف على النظام وتضمين محتوياته في ملفات PDF المُنشأة. تم إصلاح المشكلة في الإصدار 4.0.0 الذي يقيد الوصول إلى نظام الملفات بشكل افتراضي.
إصدارات jsPDF السابقة للإصدار 4.0.0 تحتوي على ثغرة تضمين ملفات محلية في بناء Node.js تسمح للمهاجمين بقراءة ملفات عشوائية من النظام. يمكن للمهاجمين استخدام معاملات المسار غير المعقمة في طرق مختلفة لكشف محتويات الملفات الحساسة.
Upgrade jsPDF to version 4.0.0 or later immediately. If immediate upgrade is not possible, implement input validation and sanitization for all file paths passed to loadFile, addImage, html, and addFont methods. Use Node.js permission flags (--permission) to restrict file system access. Avoid passing user-controlled input directly to these methods without validation.
قم بترقية jsPDF إلى الإصدار 4.0.0 أو أحدث فوراً. إذا لم يكن الترقية الفورية ممكنة، قم بتطبيق التحقق من صحة المدخلات وتعقيم جميع مسارات الملفات. استخدم أعلام أذونات Node.js لتقييد الوصول إلى نظام الملفات. تجنب تمرير المدخلات التي يتحكم بها المستخدم مباشرة إلى هذه الطرق.