{"id":"GHSA-3px3-54cx-rmw9","summary":"xmldom: Creation-time XML Name/QName validation is bypassable via an embedded line terminator, allowing injection on the default serialization path","details":"## Summary\n\nAn embedded line terminator bypasses xmldom's always-on, WHATWG-mandated creation-time name\nvalidation. `createElementNS`, `createAttributeNS`, `createDocumentType`, and `createAttribute` should\nreject a malformed qualified name with `InvalidCharacterError`, but a name whose first line is\nwell-formed slips through and enters the DOM. On serialization it is emitted verbatim, so the\ncharacters after the line terminator inject markup into the output. The injection reaches the default\nserialization path, and enabling `requireWellFormed` does not prevent it.\n\n## Details\n\n`createElementNS`, `createAttributeNS`, and `createDocumentType` route through `validateQualifiedName`,\nand `createAttribute` performs the analogous check; each validates the name with\n`g.QName_exact.test(name)`. `QName_exact = reg('^', QName, '$')` inherits the `m` flag from xmldom's\nshared regexp builder, so the matcher accepts any name whose first line is a valid `QName` and leaves\nthe remaining lines unconstrained (see Root Cause).\n\n### Root Cause\n\n1. A shared regexp builder compiles anchored productions with the `m` flag.\n2. `^…$` under `m` are line anchors, not string anchors.\n3. `validateQualifiedName` / `createAttribute` validate with `.test()` against such a production, so a\n   line terminator followed by breakout markup passes and the malformed name is stored.\n\nThe triggering line terminators are the ECMAScript `LineTerminator` set: U+000A, U+000D, U+2028, U+2029.\n\n## Proof of Concept\n\n```js\nconst { DOMImplementation, XMLSerializer } = require('@xmldom/xmldom');\nconst impl = new DOMImplementation();\n\nconst doc = impl.createDocument('urn:x', 'root', null);\nconst el = doc.createElementNS('urn:x', 'a\\n\u003e\u003cscript\u003ex\u003c/script');  // ACCEPTED (no throw)\ndoc.documentElement.appendChild(el);\n\n// DEFAULT serialization — requireWellFormed NOT set:\nconsole.log(new XMLSerializer().serializeToString(doc));\n// Observed: \u003croot xmlns=\"urn:x\"\u003e\u003ca\n// \u003e\u003cscript\u003ex\u003c/script/\u003e\u003c/root\u003e          \u003c-- injected element on the default path\n// Control: createElementNS('urn:x', 'bad\u003ename') throws InvalidCharacterError, confirming the check is\n// active and specifically bypassed by the line terminator.\n```\n\n## Impact\n\n- **Bypass of the always-on WHATWG creation-time name validation** (`InvalidCharacterError`): a\n  malformed name the standard requires be rejected at creation is instead admitted to the DOM.\n- **Markup / structure injection.** An application relying on the `create*` APIs to reject malformed\n  names (the standard behavior) as a trust boundary is exposed; where the serialized output reaches an\n  HTML context, downstream XSS.\n- **No serializer option mitigates it.** The admitted name is emitted verbatim under *both* the default\n  path and `requireWellFormed: true` — the strict serializer shares the same `m`-flagged blind spot\n  (the subject of the sibling serializer advisories) — so the bypassed creation-time check was the only\n  layer that could have stopped it. Demonstrated for all four `create*` sites in\n  `poc_creation_strict_serialization_bypass.cjs`.\n\n## Fix Applied\n\n`createElementNS`, `createAttributeNS`, `createDocumentType`, and `createAttribute` now reject a name\ncontaining a line terminator with `InvalidCharacterError` — the same result they already give for\nother malformed names — because name validation now applies to the whole string. The\n`requireWellFormed` serializer's name checks are corrected by the same change. The fix is\nnon-breaking: such a name was already invalid, and no previously-accepted well-formed name is affected.","aliases":["CVE-2026-83609"],"modified":"2026-09-08T21:15:03.928359851Z","published":"2026-09-08T21:02:33Z","database_specific":{"severity":"HIGH","github_reviewed":true,"github_reviewed_at":"2026-09-08T21:02:33Z","nvd_published_at":"2026-09-01T15:17:38Z","cwe_ids":["CWE-625","CWE-91"]},"references":[{"type":"WEB","url":"https://github.com/xmldom/xmldom/security/advisories/GHSA-3px3-54cx-rmw9"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-83609"},{"type":"WEB","url":"https://github.com/xmldom/xmldom/pull/1071"},{"type":"WEB","url":"https://github.com/xmldom/xmldom/commit/7b2ec67e1750daadd0bb06c92e875e726544a362"},{"type":"PACKAGE","url":"https://github.com/xmldom/xmldom"},{"type":"WEB","url":"https://github.com/xmldom/xmldom/releases/tag/0.9.12"}],"affected":[{"package":{"name":"@xmldom/xmldom","ecosystem":"npm","purl":"pkg:npm/%40xmldom/xmldom"},"ranges":[{"type":"SEMVER","events":[{"introduced":"0.9.0"},{"fixed":"0.9.12"}]}],"database_specific":{"last_known_affected_version_range":"\u003c= 0.9.11","source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/09/GHSA-3px3-54cx-rmw9/GHSA-3px3-54cx-rmw9.json"}}],"schema_version":"1.9.0","severity":[{"type":"CVSS_V4","score":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:H/VA:N/SC:N/SI:N/SA:N"}]}