Vulnerabilities in pkg:npm/ansi2html

PACKAGE
Advisory Identifier: GHSA-c2v2-7rcg-2ch7
Advisory Summary

CVE-2015-9239 is a HIGH denial of service vulnerability (CWE-400: Uncontrolled Resource Consumption) affecting Ansi2html libraries in the npm ecosystem. The issue involves regular expression denial of service in ansi2html. Remediation is available in the latest vendor maintenance releases.

1 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:npm/ansi2html

1 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:npm/ansi2html. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-c2v2-7rcg-2ch7 CVE-2015-9239 HIGH Regular Expression Denial of Service in ansi2html

CVE-2015-9239 at a Glance

CVE Identifier CVE-2015-9239
GHSA Identifier GHSA-c2v2-7rcg-2ch7
Severity HIGH
CVSS v3.1 Base Score N/A
CWE Classification CWE-400: Uncontrolled Resource Consumption
Affected Product Ansi2html
Package Ecosystem npm
Published Date
Last Updated

How to Fix CVE-2015-9239

To remediate this vulnerability, upgrade all affected Ansi2html dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

ansi2html fixed: Latest secure release
npm install ansi2html@Latest secure release
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls ansi2html

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2015-9239, inspect your project dependencies using npm:

npm ls ansi2html

Analyze the terminal output to locate any version of Ansi2html in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than the patched release), your application is affected.

Note: The npm ls ansi2html command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-400: Uncontrolled Resource Consumption, where the product does not properly control the allocation and maintenance of a limited resource. In Ansi2html, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

The `ansi2html` package is affected by a regular expression denial of service vulnerability when certain types of user input is passed in. ## Proof of concept ``` var ansi2html = require('ansi2html') var start = process.hrtime(); ansi2html("[1111111111111111111111;0000000000000000000000"); console.log(process.hrtime(start)); start = process.hrtime(); ansi2html("[1111111111111111111111;00000000000000000000000"); console.log(process.hrtime(start)); start = process.hrtime(); ansi2html("[1111111111111111111111;000000000000000000000000"); console.log(process.hrtime(start)); start = process.hrtime(); ansi2html("[1111111111111111111111;0000000000000000000000000000"); console.log(process.hrtime(start)); ``` Results of the above ``` 00:29:53-adam_baldwin~/tmp$ node test [ 0, 119615367 ] [ 0, 149934565 ] [ 0, 233325677 ] [ 3, 46582479 ] ``` ## Recommendation At the time of this writing, February 2018, all versions of `ansi2html` remain vulnerable, and the package has not been updated for 4 years. In order to use this package safely, it is necessary to avoid passing user input to the package, or to limit the size of the input string to a size with a parse time you find acceptable. Unfortunately, the match time grows at quite a small character count, so it is unlikely for it to both allow strings of a useful size while protecting against the denial of service attack. In the case that user input of significant length must be parsed by ansi2html, the best mitigation is to use an alternative module that is actively maintained and provides similar functionality. There are [multiple modules fitting this criteria available on npm.][available on npm](https://www.npmjs.com/search?q=ansi+html)

CVE-2015-9239 Affected Ansi2html Versions

1 component(s)
Product / Package Ecosystem Affected Versions Fixed Version
ansi2html
npm
≥ 0.0.0

References

Frequently Asked Questions

What is CVE-2015-9239?
CVE-2015-9239 is a security vulnerability in Ansi2html involving Regular Expression Denial of Service in ansi2html under CWE-400: Uncontrolled Resource Consumption.
Which Ansi2html versions are affected?
Affected versions include releases prior to current release patches across affected packages: ansi2html.
What version fixes CVE-2015-9239?
Upgrading to current release patches (or the latest patched release for your respective branch) resolves the vulnerability.
Is ansi2html affected?
Yes, ansi2html is affected in releases prior to Latest secure release. Upgrade your dependency to Latest secure release or later.
What CWE is associated with CVE-2015-9239?
CVE-2015-9239 is classified under CWE-400: Uncontrolled Resource Consumption (The product does not properly control the allocation and maintenance of a limited resource.).
How can I check npm dependencies for CVE-2015-9239?
Run the dependency tree command: 'npm ls ansi2html'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-c2v2-7rcg-2ch7",
  "modified" : "2021-01-14T15:58:08Z",
  "published" : "2020-09-01T15:17:48Z",
  "aliases" : [ "CVE-2015-9239" ],
  "summary" : "Regular Expression Denial of Service in ansi2html",
  "details" : "The `ansi2html` package is affected by a regular expression denial of service vulnerability when certain types of user input is passed in.\n\n\n## Proof of concept\n```\nvar ansi2html = require('ansi2html')\n\nvar start = process.hrtime();\nansi2html(\"[1111111111111111111111;0000000000000000000000\");\nconsole.log(process.hrtime(start));\n\nstart = process.hrtime();\nansi2html(\"[1111111111111111111111;00000000000000000000000\");\nconsole.log(process.hrtime(start));\n\nstart = process.hrtime();\nansi2html(\"[1111111111111111111111;000000000000000000000000\");\nconsole.log(process.hrtime(start));\n\nstart = process.hrtime();\nansi2html(\"[1111111111111111111111;0000000000000000000000000000\");\nconsole.log(process.hrtime(start));\n```\n\nResults of the above\n```\n00:29:53-adam_baldwin~/tmp$ node test\n[ 0, 119615367 ]\n[ 0, 149934565 ]\n[ 0, 233325677 ]\n[ 3, 46582479 ]\n```\n\n\n## Recommendation\n\nAt the time of this writing, February 2018, all versions of `ansi2html` remain vulnerable, and the package has not been updated for 4 years. \n\nIn order to use this package safely, it is necessary to avoid passing user input to the package, or to limit the size of the input string to a size with a parse time you find acceptable. Unfortunately, the match time grows at quite a small character count, so it is unlikely for it to both allow strings of a useful size while protecting against the denial of service attack. \n\nIn the case that user input of significant length must be parsed by ansi2html, the best mitigation is to use an alternative module that is actively maintained and provides similar functionality. There are [multiple modules fitting this criteria available on npm.][available on npm](https://www.npmjs.com/search?q=ansi+html)",
  "severity" : [ ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "ansi2html"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0.0.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2015-9239"
  }, {
    "type" : "WEB",
    "url" : "https://www.npmjs.com/advisories/51"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-400" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2020-08-31T18:09:20Z",
    "nvd_published_at" : null
  }
}