Inefficient Algorithmic Complexity Affecting domutils package, versions >=3.1.0 <4.1.0


Severity

Recommended
0.0
medium
0
10

CVSS assessment by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of Concept

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
  • Snyk IDSNYK-JS-DOMUTILS-23745866
  • published4 Dec 2026
  • disclosed4 Dec 2026
  • creditUgur Celik (ucsurf)

Introduced: 4 Dec 2026

NewCVE-2026-145168  (opens in a new tab)
CWE-407  (opens in a new tab)

How to fix?

Upgrade domutils to version 4.1.0 or higher.

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");

CVSS Base Scores

version 4.0
version 3.1