CVE-2015-9239: Ansi2html Denial of Service Vulnerability
HIGHCVE-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.
CVE-2015-9239 at a Glance
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.
npm install ansi2html@Latest secure release
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
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?
Which Ansi2html versions are affected?
What version fixes CVE-2015-9239?
Is ansi2html affected?
What CWE is associated with CVE-2015-9239?
How can I check npm dependencies for CVE-2015-9239?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"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
}
}