CVE-2015-9239: Regular Expression Denial of Service in ansi2html

ansi2html Updated 02 Oct 2025

Summary

01/09/2020
No i
High
Not published

CVE-2015-9239: Regular Expression Denial of Service in ansi2html. Affects ansi2html versions >= 0.0.0. No fix is published. 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 ansi2html package is a Node.js module that converts ANSI escape codes to HTML. It has been widely used for formatting and displaying colored text in terminal applications. However, the package is vulnerable to a regular expression denial of service (ReDoS) attack when certain types of user input are passed in.

Vulnerability Detail

The regular expression used in the ansi2html package is susceptible to ReDoS, which occurs when an attacker provides specially crafted input that causes the regular expression matching to take an excessive amount of time. This can lead to a denial of service (DoS) condition, where the application becomes unresponsive or crashes.

The vulnerability affects all versions of ansi2html and has not been addressed for four years. To mitigate the risk, it is recommended to avoid passing user input to the package or limit the size of the input string. However, even with input size limitations, the match time can still grow significantly, making it challenging to find a balance between usability and protection against the attack.

As a workaround, it is advised to consider using an alternative module that is actively maintained and provides similar functionality. Several alternative modules are available on npm.

How To Fix

No fixed version is published for this vulnerability.

Tip — Not sure whether your app is affected? Vulert can check the versions your app actually runs. Scan free →

Workaround

To mitigate the vulnerability in ansi2html, it is advised to avoid passing user input to the package or limit the size of the input string. However, this may impact the usability of the application, as the match time of the regular expression grows significantly even with small increases in input size. As a more robust solution, consider using an alternative module that is actively maintained and provides similar functionality. Here's an example of how to use the ansi-html module as an alternative:

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

var input = '[1111111111111111111111;0000000000000000000000';
var output = ansiHTML(input);
console.log(output);

This code snippet demonstrates the usage of the ansi-html module to convert ANSI escape codes to HTML. It is important to note that the ansi-html module is just one of the available alternatives and may require additional configuration or adjustments depending on the specific use case.

Conclusion

The ansi2html package is vulnerable to a regular expression denial of service (ReDoS) attack, which can lead to a denial of service (DoS) condition in applications using the package. To mitigate the risk, it is advised to avoid passing user input to the package or limit the size of the input string. However, the match time of the regular expression grows significantly even with small increases in input size, making it challenging to find a balance between usability and protection against the attack. It is recommended to transition to an alternative module that is actively maintained and provides similar functionality. Thorough testing and validation should be performed when integrating the new module into the existing codebase.

For further support on vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for ansi2html →

Share this vulnerability

FAQ

The ansi2html package is a Node.js module used for converting ANSI escape codes to HTML. It is commonly used in terminal applications to format and display colored text.

Regular expression denial of service (ReDoS) is a type of attack where an attacker provides input that causes a regular expression to take an excessive amount of time to process. This can lead to a denial of service (DoS) condition, where the application becomes unresponsive or crashes.

The vulnerability in ansi2html can be exploited by an attacker to launch a regular expression denial of service (ReDoS) attack. This can result in the application becoming unresponsive or crashing, leading to a degraded user experience or potential downtime.

Yes, all versions of ansi2html are vulnerable to the regular expression denial of service (ReDoS) attack. The package has not been updated for four years, leaving it exposed to this security issue.

If you are currently using ansi2html in your application, it is recommended to transition to an alternative module that is actively maintained and provides similar functionality. This will help ensure that your application is not vulnerable to the regular expression denial of service (ReDoS) attack and other potential security issues.

How To Fix

No fixed version is published for this vulnerability.

Tip — Not sure whether your app is affected? Vulert can check the versions your app actually runs. 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