CVE-2021-23424: Uncontrolled Resource Consumption in ansi-html

ansi-html Updated 02 Oct 2025

Summary

02/09/2021
Yes i
High
7.5

CVE-2021-23424: Uncontrolled Resource Consumption in ansi-html. Affects ansi-html versions < 0.0.8. Fixed in 0.0.8. 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 Your last release was probably never penetration tested Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

The package under scrutiny is ansi-html, an npm package. It is responsible for converting ANSI escape codes into HTML. This package is widely used in various applications and libraries to display colored and formatted text in the terminal. The vulnerability identified in ansi-html allows an attacker to provide a malicious string that can cause the package to consume excessive resources, leading to a denial-of-service (DoS) condition. This vulnerability affects all versions of the package up to and including 0.0.7.

Vulnerability Detail

The vulnerability arises from ansi-html's inability to handle malicious input strings efficiently. When an attacker supplies a specially crafted string, the package gets stuck processing the input for an extended period, resulting in uncontrolled resource consumption. This can lead to a significant impact on the availability and performance of the affected system. The Common Vulnerabilities and Exposures (CVE) identifier for this vulnerability is CVE-2021-23424. The vulnerability has a CVSS v3 score of 7.5, indicating a high severity level.

How To Fix

Latest published version: 0.0.9 as of 22 Oct 2026

npm install ansi-html@0.0.9

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

0.0.8

This is the first release that contains the fix.

npm install ansi-html@0.0.8

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

Workaround

As a temporary workaround, if updating the package is not immediately feasible, developers can consider implementing input validation and sanitization mechanisms in their code to filter out potentially malicious input strings. By carefully validating and sanitizing user-supplied input, the risk of triggering the vulnerability can be reduced. Here is an example of how input validation can be performed in JavaScript:

const ansiHTML = require('ansi-html');

function sanitizeInput(input) {
  // Perform input validation and sanitization
  // ... your code here ...
  return input;
}

const maliciousString = '...';
const sanitizedString = sanitizeInput(maliciousString);
const htmlOutput = ansiHTML.ansiHTML(sanitizedString);

It is important to note that this workaround is not a complete solution and should be considered temporary until the package is updated.

Conclusion

In conclusion, the ansi-html package is vulnerable to uncontrolled resource consumption, which can be exploited by providing a malicious string. This can lead to a denial-of-service (DoS) condition. It is crucial to update the package to version 0.0.8 or later to mitigate this vulnerability. In the meantime, implementing input validation and sanitization mechanisms can serve as a temporary workaround. For further support on vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for ansi-html →

Share this vulnerability

FAQ

ansi-html is an npm package that converts ANSI escape codes into HTML. It is commonly used to display colored and formatted text in the terminal.

The vulnerability allows an attacker to cause uncontrolled resource consumption in the ansi-html package, leading to a denial-of-service (DoS) condition. This can impact the availability and performance of the affected system.

All versions of ansi-html up to and including 0.0.7 are affected by this vulnerability.

The CVSS v3 score of this vulnerability is 7.5, indicating a high severity level.

To fix this vulnerability, it is recommended to update the ansi-html package to version 0.0.8 or later. This update includes the necessary fixes to prevent uncontrolled resource consumption.

How To Fix

Latest published version: 0.0.9 as of 22 Oct 2026

npm install ansi-html@0.0.9

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

0.0.8

This is the first release that contains the fix.

npm install ansi-html@0.0.8

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