CVE-2021-23346: Regular expression denial of service (ReDoS) in html-parse-stringify

html-parse-stringify Updated 02 Oct 2025

Summary

18/03/2021
Yes i
Moderate
5.3

CVE-2021-23346: This affects the package html-parse-stringify before 2.0.1; all versions of package html-parse-stringify2. Affects html-parse-stringify versions < 2.0.1. Fixed in 2.0.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 Devnack Mobile apps built by Devnack Design, build and launch iOS and Android apps with a senior product team. From idea to store release Start a project

Background

html-parse-stringify is an npm package used for parsing and stringifying HTML. It provides functionality to parse HTML strings into a structured format and convert structured HTML back into a string. This vulnerability affects versions before 2.0.1 of the package html-parse-stringify and all versions of package html-parse-stringify2. The vulnerability arises from a regular expression used for parsing, which can cause the process to freeze when certain input is sent, leading to a denial of service (DoS) condition.

Vulnerability Detail

The vulnerability in html-parse-stringify and html-parse-stringify2 allows an attacker to exploit a regular expression denial of service (ReDoS) issue. By sending specific input, the regular expression used for parsing can backtrack excessively, causing the process to freeze. This can result in a DoS condition, impacting the availability of the affected application. The vulnerability has a CVSS score of 5.3, indicating a moderate severity.

How To Fix

Latest published version: 4.0.1 as of 22 Oct 2026

npm install html-parse-stringify@4.0.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.0.1

This is the first release that contains the fix.

npm install html-parse-stringify@2.0.1

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

If updating the package is not immediately feasible, a temporary workaround can be implemented by validating and sanitizing user input before passing it to the vulnerable parsing function. This can help mitigate the risk of triggering the ReDoS vulnerability. Here is an example of how input validation can be performed in JavaScript:

const input = getUserInput();
if (!/^[a-zA-Z0-9]+$/.test(input)) {
  throw new Error('Invalid input');
}

In this example, the regular expression /^[a-zA-Z0-9]+$/ is used to validate that the input consists only of alphanumeric characters. Adjust the regular expression according to the specific input requirements of your application.

Conclusion

In conclusion, the html-parse-stringify and html-parse-stringify2 packages are vulnerable to a regular expression denial of service (ReDoS) issue. This can be exploited by sending specific input, causing the parsing process to freeze and leading to a denial of service condition. To mitigate this vulnerability, it is recommended to update the affected packages to version 2.0.1 or later. In the meantime, implementing input validation and sanitization can provide a temporary workaround. For further support on vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for html-parse-stringify →

Share this vulnerability

FAQ

The vulnerability can lead to a denial of service (DoS) condition, causing the affected process to freeze and impacting the availability of the application.

Versions before 2.0.1 of html-parse-stringify and all versions of html-parse-stringify2 are affected by this vulnerability.

Yes, updating the affected packages to version 2.0.1 or later resolves the vulnerability.

Implementing input validation and sanitization can help mitigate the risk of triggering the vulnerability while an update is being applied.

The CVSS score of this vulnerability is 5.3, indicating a moderate severity.

How To Fix

Latest published version: 4.0.1 as of 22 Oct 2026

npm install html-parse-stringify@4.0.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.0.1

This is the first release that contains the fix.

npm install html-parse-stringify@2.0.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