JavaScriptSeverity: MediumStatus: Published
Deeply nested documents overflow the call stack in findOne(), existsOne() and getElementById()
Applications that search untrusted HTML or XML documents with domutils’ findOne(), existsOne() or getElementById() are affected (CWE-674). These functions recursed once per level of the document, so a deeply nested document exhausts the JavaScript call stack and makes them throw a RangeError. npm package domutils versions >= 1.0.0 and <= 4.0.2 are affected: getElementById() from 1.0.0, findOne() from 1.1.3 and existsOne() from 1.4.0. Fixed in 4.1.0. GitHub rates it medium, with CVSS 3.1 score 5.3. The advisory credits ucsurf as reporter. Fixed by Felix Boehm (@fb55).
Impact
Applications that search untrusted HTML or XML documents with domutils’ findOne(), existsOne() or getElementById() are affected. These functions recursed once per level of the document (CWE-674), so a deeply nested document exhausts the JavaScript call stack and makes them 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 domutils is affected in versions >= 1.0.0 and <= 4.0.2: getElementById() from 1.0.0, findOne() from 1.1.3 and existsOne() from 1.4.0. The patched release is 4.1.0.
The published advisory is GHSA-5pwf-qwq7-cwxj. 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. The advisory credits ucsurf as reporter.
The advisory says this was fixed in 4.1.0, which bounds the recursion and continues deeper searches with an explicit stack. On the repository, Felix Boehm merged pull request 2406 (“fix: keep tree queries linear and stack-safe on deep documents”) on 2026-12-03. That change is in v4.1.0. The pull request is not ours.
The advisory suggests catching errors thrown by these functions and treating the document as invalid, or rejecting documents nested deeper than the application needs, if an upgrade is not possible yet.
Timeline
- Found
- Reported via private vulnerability report
- Advisory published
- Entry last updated
Machine-readable: JSON · Markdown · ID security/javascript/fb55__domutils/2026-10-05-findone-existsone-stack-overflow
If this work is useful to you, you can support it on Buy Me a Coffee.