Vulnerabilities |
7 via 27 paths |
|---|---|
Dependencies |
26 |
Source |
GitHub |
Find, fix and prevent vulnerabilities in your code.
high severity
new
- Vulnerable module: domutils
- Introduced through: cheerio@1.2.0
Detailed paths
-
Introduced through: open-graph-scraper@jshemas/openGraphScraper › cheerio@1.2.0 › domutils@3.2.2
-
Introduced through: open-graph-scraper@jshemas/openGraphScraper › cheerio@1.2.0 › cheerio-select@2.1.0 › domutils@3.2.2
-
Introduced through: open-graph-scraper@jshemas/openGraphScraper › cheerio@1.2.0 › htmlparser2@10.1.0 › domutils@3.2.2
-
Introduced through: open-graph-scraper@jshemas/openGraphScraper › cheerio@1.2.0 › cheerio-select@2.1.0 › css-select@5.2.2 › domutils@3.2.2
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: cheerio@1.2.0
Detailed paths
-
Introduced through: open-graph-scraper@jshemas/openGraphScraper › cheerio@1.2.0 › domutils@3.2.2
-
Introduced through: open-graph-scraper@jshemas/openGraphScraper › cheerio@1.2.0 › cheerio-select@2.1.0 › domutils@3.2.2
-
Introduced through: open-graph-scraper@jshemas/openGraphScraper › cheerio@1.2.0 › htmlparser2@10.1.0 › domutils@3.2.2
-
Introduced through: open-graph-scraper@jshemas/openGraphScraper › cheerio@1.2.0 › cheerio-select@2.1.0 › css-select@5.2.2 › domutils@3.2.2
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
high severity
new
- Vulnerable module: parse5
- Introduced through: cheerio@1.2.0
Detailed paths
-
Introduced through: open-graph-scraper@jshemas/openGraphScraper › cheerio@1.2.0 › parse5@7.3.0
-
Introduced through: open-graph-scraper@jshemas/openGraphScraper › cheerio@1.2.0 › parse5-htmlparser2-tree-adapter@7.1.0 › parse5@7.3.0
-
Introduced through: open-graph-scraper@jshemas/openGraphScraper › cheerio@1.2.0 › parse5-parser-stream@7.1.2 › parse5@7.3.0
Overview
Affected versions of this package are vulnerable to Uncaught Exception in the Preprocessor class, whose _processSurrogate method pairs a code unit with a following low surrogate without confirming the first unit is a high surrogate. Two consecutive low surrogates such as U+DC00 U+DC00 decode to the out-of-range code point 0x110000, and String.fromCodePoint throws a RangeError that propagates out of parse, parseFragment, and the SAX and streaming parsers. An attacker who can supply HTML to an application that parses it, directly or through a dependent such as cheerio or jsdom, can crash the Node.js process with a few bytes of input. This affects parse5 built on the TypeScript tokenizer, where characters are emitted with String.fromCodePoint.
Remediation
Upgrade parse5 to version 8.1.1 or higher.
References
medium severity
new
- Vulnerable module: domutils
- Introduced through: cheerio@1.2.0
Detailed paths
-
Introduced through: open-graph-scraper@jshemas/openGraphScraper › cheerio@1.2.0 › domutils@3.2.2
-
Introduced through: open-graph-scraper@jshemas/openGraphScraper › cheerio@1.2.0 › cheerio-select@2.1.0 › domutils@3.2.2
-
Introduced through: open-graph-scraper@jshemas/openGraphScraper › cheerio@1.2.0 › htmlparser2@10.1.0 › domutils@3.2.2
-
Introduced through: open-graph-scraper@jshemas/openGraphScraper › cheerio@1.2.0 › cheerio-select@2.1.0 › css-select@5.2.2 › domutils@3.2.2
Overview
Affected versions of this package are vulnerable to Inefficient Algorithmic Complexity via find() and findAll() in src/querying.ts, which maintain stacks of child-node arrays using unshift() and shift() at the front of the array. Because these operations shift every existing entry on each call, traversing a deeply nested document takes time quadratic in its nesting depth. An attacker can supply a deeply nested HTML or XML document to any API built on these functions - including filter(), getElements(), getElementsByTagName(), getElementsByClassName(), and getElementsByTagType() - to block the Node.js event loop. A document of 100,000 nested <b> tags (approximately 300 KB) causes findAll() to run for about 2 seconds.
Workaround
Reject documents nested deeper than the application requires before searching them, or run the search in a worker thread that is terminated after a time limit.
PoC
import { parseDocument } from "htmlparser2";
import { findAll } from "domutils";
const doc = parseDocument("<b>".repeat(100_000));
console.time("findAll");
findAll(() => false, doc.children); // about 2 s with domutils 4.0.2
console.timeEnd("findAll");
Remediation
Upgrade domutils to version 4.1.0 or higher.
References
medium severity
new
- Vulnerable module: domutils
- Introduced through: cheerio@1.2.0
Detailed paths
-
Introduced through: open-graph-scraper@jshemas/openGraphScraper › cheerio@1.2.0 › domutils@3.2.2
-
Introduced through: open-graph-scraper@jshemas/openGraphScraper › cheerio@1.2.0 › cheerio-select@2.1.0 › domutils@3.2.2
-
Introduced through: open-graph-scraper@jshemas/openGraphScraper › cheerio@1.2.0 › htmlparser2@10.1.0 › domutils@3.2.2
-
Introduced through: open-graph-scraper@jshemas/openGraphScraper › cheerio@1.2.0 › cheerio-select@2.1.0 › css-select@5.2.2 › domutils@3.2.2
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: cheerio@1.2.0
Detailed paths
-
Introduced through: open-graph-scraper@jshemas/openGraphScraper › cheerio@1.2.0 › domutils@3.2.2
-
Introduced through: open-graph-scraper@jshemas/openGraphScraper › cheerio@1.2.0 › cheerio-select@2.1.0 › domutils@3.2.2
-
Introduced through: open-graph-scraper@jshemas/openGraphScraper › cheerio@1.2.0 › htmlparser2@10.1.0 › domutils@3.2.2
-
Introduced through: open-graph-scraper@jshemas/openGraphScraper › cheerio@1.2.0 › cheerio-select@2.1.0 › css-select@5.2.2 › domutils@3.2.2
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: cheerio@1.2.0
Detailed paths
-
Introduced through: open-graph-scraper@jshemas/openGraphScraper › cheerio@1.2.0 › domutils@3.2.2
-
Introduced through: open-graph-scraper@jshemas/openGraphScraper › cheerio@1.2.0 › cheerio-select@2.1.0 › domutils@3.2.2
-
Introduced through: open-graph-scraper@jshemas/openGraphScraper › cheerio@1.2.0 › htmlparser2@10.1.0 › domutils@3.2.2
-
Introduced through: open-graph-scraper@jshemas/openGraphScraper › cheerio@1.2.0 › cheerio-select@2.1.0 › css-select@5.2.2 › domutils@3.2.2
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.