CVE-2021-23353: Regular Expression Denial of Service (ReDoS) in jspdf
Summary
CVE-2021-23353: jspdf vulnerable to Regular Expression Denial of Service (ReDoS). Affects jspdf versions < 2.3.1. Fixed in 2.3.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 an npm package that provides a JavaScript library for generating PDF files. It is widely used for creating PDF documents dynamically in web applications. The package offers various features, including the ability to add images to the PDF files. However, prior to version 2.3.1, jspdf is vulnerable to a Regular Expression Denial of Service (ReDoS) attack in the addImage function.
Vulnerability Detail
The vulnerability allows an attacker to perform a ReDoS attack by exploiting the addImage function in jspdf. ReDoS attacks occur when a regular expression pattern is crafted in such a way that it takes a significant amount of time to match certain inputs. This can lead to a denial of service condition, where the application becomes unresponsive or crashes. In the case of jspdf, an attacker can send a specially crafted image file that triggers the ReDoS vulnerability, causing the application to consume excessive CPU resources and potentially leading to a denial of service.
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
2.3.1
This is the first release that contains the fix.
npm install jspdf@2.3.1
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
There is no known workaround for this vulnerability. It is essential to upgrade to the fixed version of the jspdf package to mitigate the risk.
Conclusion
The vulnerability in jspdf allows for a ReDoS attack, which can lead to a denial of service condition in applications using the package. To mitigate this risk, it is recommended to upgrade to version 2.3.1 or later of the jspdf package. For further assistance or support in vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for jspdf →
FAQ
jspdf is an npm package that provides a JavaScript library for generating PDF files. It is commonly used in web applications to dynamically create PDF documents.
A ReDoS (Regular Expression Denial of Service) attack occurs when a regular expression pattern is crafted in such a way that it takes a significant amount of time to match certain inputs. This can lead to a denial of service condition in the targeted application.
The vulnerability in jspdf allows an attacker to perform a ReDoS attack by exploiting the addImage function. This can lead to a denial of service condition in applications that use jspdf for generating PDF files.
Yes, the vulnerability can be fixed by upgrading to version 2.3.1 or later of the jspdf package. This version includes a fix for the ReDoS vulnerability in the addImage function.
There are no known workarounds for this vulnerability. It is crucial to upgrade to the fixed version of the jspdf package to mitigate the risk.
References
Related vulnerabilities
Recent vulnerabilities recorded for jspdf.