CVE-2021-23353: Regular Expression Denial of Service (ReDoS) in jspdf

jspdf Updated 02 Oct 2025

Summary

12/03/2021
Yes i
High
7.5

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 ↓

Free scan

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.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Lume, the Habilume companion Habilume Habit tracker with a companion that grows with you Complete habits, earn Lume Points, and watch your Lume grow as you stay consistent. App Store Google Play

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 →

Share this vulnerability

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.

Related vulnerabilities

Recent vulnerabilities recorded for jspdf.

Sponsored Lume, the Habilume companion Habilume Habit tracker with a companion that grows with you Complete habits, earn Lume Points, and watch your Lume grow as you stay consistent. App Store Google Play

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 →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback