JavaScriptSeverity: MediumStatus: Published

Deeply nested documents overflow the call stack during serialization

Applications that serialize untrusted documents with dom-serializer’s render() are affected (CWE-674). render() recursed once per level of the DOM tree, so a deeply nested HTML or XML document that parses successfully exhausts the JavaScript call stack during serialization and makes render() throw a RangeError. npm package dom-serializer versions <= 3.1.1 are affected, from 0.0.0 through 3.1.1. Fixed in 3.1.2. GitHub rates it medium, with CVSS 3.1 score 5.3. The advisory credits lenny-ts, Linus-Shyu and ucsurf as reporters. Fixed by Felix Boehm (@fb55).

Impact

Applications that serialize untrusted documents with dom-serializer’s render() are affected. render() recursed once per level of the DOM tree (CWE-674), so a deeply nested HTML or XML document that parses successfully exhausts the JavaScript call stack during serialization and makes render() throw a RangeError. If the application does not catch the error, it can fail the request or terminate the process.

Affected versions and fix

The npm package dom-serializer is affected in every release from 0.0.0 through 3.1.1 (<= 3.1.1). The patched release is 3.1.2.

The published advisory is GHSA-w993-rw2g-cjqj. GitHub rates it medium, with CVSS 3.1 score 5.3 (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L). Felix Boehm (@fb55) published the advisory on 2026-12-03. It was reported on 2026-10-05 through GitHub private vulnerability reporting, as part of a report filed on fb55/domutils. The advisory credits lenny-ts, Linus-Shyu and ucsurf as reporters.

The advisory says this was fixed in 3.1.2. On the repository, Felix Boehm merged pull request 1744 (“fix: serialize deeply nested DOMs iteratively”) on 2026-10-11. That change is in v3.1.2. The pull request is not ours.

The advisory suggests catching errors thrown by render() and treating the document as invalid, or rejecting documents nested deeper than the application needs, if an upgrade is not possible yet.

Timeline

  1. Found
  2. Reported via private vulnerability report
  3. Advisory published
  4. Entry last updated

Machine-readable: JSON · Markdown · ID security/javascript/cheeriojs__dom-serializer/2026-10-05-deeply-nested-documents-overflow-serialization

If this work is useful to you, you can support it on Buy Me a Coffee.