Vulnerabilities |
5 via 5 paths |
|---|---|
Dependencies |
17 |
Source |
GitHub |
Find, fix and prevent vulnerabilities in your code.
high severity
new
- Vulnerable module: domutils
- Introduced through: node-html-parser@5.4.2
Detailed paths
-
Introduced through: mmm-fuel@fewieden/mmm-fuel › node-html-parser@5.4.2 › css-select@4.3.0 › domutils@2.8.0
Overview
Affected versions of this package are vulnerable to Allocation of Resources Without Limits or Throttling via getFeed() in src/feeds.ts, when parsing RSS or Atom feeds containing nested item or entry elements. Because getFeed() collected item and entry elements at any depth below the feed root, an item nested inside another item was treated as an independent item, and its media elements were collected again for every enclosing item. This causes N nested items around M media:content elements to produce N × M media objects, exhausting the Node.js heap and terminating the process in a way that try/catch cannot prevent.
PoC
import { parseDocument } from "htmlparser2";
import { getFeed } from "domutils";
const n = 400;
const xml = "<rss><channel>" + "<item>".repeat(n) +
'<media:content url="x"/>'.repeat(n) + "</item>".repeat(n) +
"</channel></rss>";
const feed = getFeed(parseDocument(xml, { xmlMode: true }).children);
console.log(feed.items.reduce((sum, item) => sum + item.media.length, 0));
// 160000 with domutils 4.0.2 (15 KB of input)
Remediation
Upgrade domutils to version 4.1.0 or higher.
References
high severity
new
- Vulnerable module: domutils
- Introduced through: node-html-parser@5.4.2
Detailed paths
-
Introduced through: mmm-fuel@fewieden/mmm-fuel › node-html-parser@5.4.2 › css-select@4.3.0 › domutils@2.8.0
Overview
Affected versions of this package are vulnerable to Inefficient Algorithmic Complexity via an inefficient algorithm in removeSubsets() that exhibits O(n² × depth) time complexity. When processing documents with many nested or sibling nodes, an attacker can submit HTML or XML input processed by css-select selectAll() or cheerio .find() to exhaust CPU and block the Node.js event loop for seconds.
PoC
import { parseDocument } from "htmlparser2";
import { getElementsByTagName, removeSubsets } from "domutils";
const doc = parseDocument("<b>".repeat(5_000) + "<i></i>".repeat(5_000));
const nodes = getElementsByTagName("i", doc);
console.time("removeSubsets");
removeSubsets(nodes); // about 15 s with domutils 4.0.2
console.timeEnd("removeSubsets");
Remediation
Upgrade domutils to version 4.1.0 or higher.
References
medium severity
new
- Vulnerable module: domutils
- Introduced through: node-html-parser@5.4.2
Detailed paths
-
Introduced through: mmm-fuel@fewieden/mmm-fuel › node-html-parser@5.4.2 › css-select@4.3.0 › domutils@2.8.0
Overview
Affected versions of this package are vulnerable to Inefficient Algorithmic Complexity via compareDocumentPosition(), which builds each node's ancestor chain using unshift(), causing every existing entry in the chain to be shifted on each insertion and making the comparison take time quadratic in the nesting depth of the nodes. An attacker can supply an HTML or XML document with deeply nested elements and trigger a comparison or sort via uniqueSort() to block the Node.js event loop.
Workaround
Reject documents nested deeper than the application requires before comparing or sorting their nodes.
PoC
import { parseDocument } from "htmlparser2";
import { compareDocumentPosition } from "domutils";
let parent = parseDocument("<b>".repeat(100_000) + "<i></i><u></u>");
while (parent.children.length === 1) parent = parent.children[0];
console.time("compare");
compareDocumentPosition(parent.children[0], parent.children[1]); // about 1 s with domutils 4.0.2
console.timeEnd("compare");
Note: The PoC states it takes about 1 second with domutils 4.0.2 on Node.js.
Remediation
Upgrade domutils to version 4.1.0 or higher.
References
medium severity
new
- Vulnerable module: domutils
- Introduced through: node-html-parser@5.4.2
Detailed paths
-
Introduced through: mmm-fuel@fewieden/mmm-fuel › node-html-parser@5.4.2 › css-select@4.3.0 › domutils@2.8.0
Overview
Affected versions of this package are vulnerable to Uncontrolled Recursion via getText(), textContent(), and innerText() in src/stringify.ts, which call themselves once per level of nesting. An attacker can supply an HTML or XML document with approximately 10,000 nested elements to exhaust the JavaScript call stack, triggering a RangeError that fails the request or terminates the Node.js process.
PoC
import { parseDocument } from "htmlparser2";
import { getText } from "domutils";
getText(parseDocument("<b>".repeat(10_000) + "x").children);
// RangeError: Maximum call stack size exceeded
Remediation
Upgrade domutils to version 4.1.0 or higher.
References
medium severity
new
- Vulnerable module: domutils
- Introduced through: node-html-parser@5.4.2
Detailed paths
-
Introduced through: mmm-fuel@fewieden/mmm-fuel › node-html-parser@5.4.2 › css-select@4.3.0 › domutils@2.8.0
Overview
Affected versions of this package are vulnerable to Uncontrolled Recursion via findOne(), existsOne(), and getElementById(), which recurse once per level of nesting in a document. An attacker can supply HTML or XML with approximately 20,000 nested elements to exhaust the JavaScript call stack, causing a RangeError that results in request failures or process termination.
PoC
import { parseDocument } from "htmlparser2";
import { findOne } from "domutils";
findOne(() => false, parseDocument("<b>".repeat(20_000)).children);
// RangeError: Maximum call stack size exceeded
Remediation
Upgrade domutils to version 4.1.0 or higher.