jsPDF Denial of Service Vulnerability: Bypass Regular Expression (ReDoS)
Summary
CVE-2025-29907: jsPDF Bypass Regular Expression Denial of Service (ReDoS). Affects jspdf versions < 3.0.1. Fixed in 3.0.1. How to fix ↓
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
jsPDF is a popular JavaScript library used for generating PDF documents in web applications. It allows developers to create PDFs programmatically, offering features such as adding text, images, and SVG graphics. However, a vulnerability has been identified in the library that allows users to exploit certain methods, leading to potential denial of service due to excessive CPU utilization.
Vulnerability Detail
The vulnerability arises from user control over the first argument of the 'addImage' method in jsPDF. Unsanitized image URLs can be passed to this method, allowing an attacker to provide a malicious data URL that triggers high CPU usage, effectively causing a denial of service. Other affected methods include 'html' and 'addSvgAsImage'. This issue can be exploited by crafting specific payloads that cause the library to enter a state of excessive processing, leading to application unresponsiveness.
How To Fix
Latest published version: 4.2.1 as of 23 Oct 2026
npm install jspdf@4.2.1
Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.
If you need the minimum change
3.0.1
This is the first release that contains the fix.
npm install jspdf@3.0.1
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
As a temporary measure, sanitize image URLs before passing them to the 'addImage' method or any other affected methods. Here is an example of how to sanitize an image URL:
function sanitizeUrl(url) {
const validUrlPattern = /^data:image\/[^;]+;base64,[A-Za-z0-9+/=]+$/;
return validUrlPattern.test(url) ? url : ''; // Returns empty string if invalid
}
const sanitizedPayload = sanitizeUrl(payload);
if (sanitizedPayload) {
doc.addImage(sanitizedPayload, 'PNG', 10, 40, 180, 180, undefined, 'SLOW');
}
Conclusion
The jsPDF library has a vulnerability that can lead to denial of service through the exploitation of certain methods. It is crucial to upgrade to the patched version and implement sanitization of image URLs to protect your application from potential attacks.
See every vulnerability recorded for jspdf →
FAQ
jsPDF is a JavaScript library that allows developers to generate PDF documents directly in the browser or server-side environments.
The vulnerability allows attackers to exploit certain methods in jsPDF by passing unsanitized image URLs, leading to high CPU usage and potential denial of service.
You can use Vulert, which monitors open-source vulnerabilities in your software. By checking your package-lock.json file, Vulert can alert you in real-time about any vulnerabilities, including this one.
Upgrade your jsPDF package to version 3.0.1 or later. Additionally, sanitize any image URLs before using them in the affected methods.
You can find detailed information about this vulnerability in the GitHub advisory database or by visiting the jsPDF repository.
References
Related vulnerabilities
Recent vulnerabilities recorded for jspdf.