CVE-2025-29907: jsPDF Bypass Regular Expression Denial of Service (ReDoS)
Impact User control of the first argument of the addImage method results in CPU utilization and denial of service.
If given the possibility to pass unsanitized image urls to the addImage method, a user can provide a harmful data-url that results in high CPU utilization and denial of service.
Other affected methods are: html, addSvgAsImage.
Example payload: js import { jsPDF } from "jpsdf"
const doc = new jsPDF(); const payload = 'data:/charset=scharset=scharset=scharset=scharset=scharset=scharset=scharset=scharset=scharset=scharset=scharset=scharset=scharset=scharset=scharset=scharset=scharset=scharset=scharset=scharset=scharset=scharset=scharset=scharset=scharset=scharset=scharset=s\x00base64,undefined';
const startTime = performance.now()
try { doc.addImage(payload, "PNG", 10, 40, 180, 180, undefined, "SLOW"); } catch (err) { const endTime = performance.now() console.log(Call to doc.addImage took ${endTime - startTime} milliseconds) }
doc.save("a4.pdf");
Patches The vulnerability was fixed in jsPDF 3.0.1. Upgrade to jspdf@>=3.0.1
Workarounds Sanitize image urls before passing it to the addImage method or one of the other affected methods.
Credits Researcher: Aleksey Solovev (Positive Technologies)
Other sources
jsPDF is a library to generate PDFs in JavaScript. Prior to 3.0.1, user control of the first argument of the addImage method results in CPU utilization and denial of service. If given the possibility to pass unsanitised image urls to the addImage method, a user can provide a harmful data-url that results in high CPU utilization and denial of service. Other affected methods are html and addSvgAsImage. The vulnerability was fixed in jsPDF 3.0.1.
— MITRE
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
npm/jspdfto a version that resolves this vulnerability.Fixed in 3.0.1 - Upgrade
Upgrade
jspdfto a version that resolves this vulnerability.Fixed in 3.0.1 - Configuration
Sanitize image URLs before passing it to doc.addImage or one of the other affected methods (html and addSvgAsImage) to prevent attacker-supplied data URLs from causing high CPU utilization and denial of service.
jsPDF (addImage/html/addSvgAsImage) sanitize image URLs before calling addImage/html/addSvgAsImage = Sanitize/validate any user-controlled image URL or data URL before passing it as the first argument to doc.addImage (and other affected methods html and addSvgAsImage).
Event History
Frequently Asked Questions
What is the severity of CVE-2025-29907?
CVE-2025-29907 is classified as a denial of service vulnerability due to excessive CPU utilization.
How do I fix CVE-2025-29907?
To fix CVE-2025-29907, update jsPDF to version 3.0.1 or later.
What problem does CVE-2025-29907 cause in jsPDF?
CVE-2025-29907 allows an attacker to utilize unsanitized image URLs that can lead to denial of service.
Which versions of jsPDF are affected by CVE-2025-29907?
Versions of jsPDF prior to 3.0.1 are affected by CVE-2025-29907.
What methods in jsPDF are vulnerable due to CVE-2025-29907?
The addImage method in jsPDF is vulnerable to exploitation outlined in CVE-2025-29907.