# Unvalidated attribute names in serialized markup

User-controlled attribute names or setter paths reaching serializers without QName/name validation

_Area: Web injection and code execution. Seen in 3 disclosed reports; latest 2026-11-13. Updated 2026-12-01._

## How it works
Serializers and sanitizers assume attribute *names* are trusted and only escape attribute *values*. When an attacker controls a name — directly via a setter, or indirectly when a filter re-expands text into markup — the name is emitted verbatim. A quote or space in the name breaks out of the attribute and injects new ones (e.g. `onclick`), turning data into executable markup. The broken assumption: "names come from code, values come from users."

## Where it shows up
- A public validating API (`createAttribute`) beside a private unvalidated helper (`_createAttribute`) that the common setter actually calls [E3](https://bugbountylibrary.com/r/ghsa%3AGHSA-4w3w-2rp5-g8jm.md).
- Filters that re-run pattern substitution (`gsub`) over already-rendered `inner_html`, not just the original input [E1](https://bugbountylibrary.com/r/h1%3A2257080.md).
- Prefix checks (`link_pattern_start`) that validate the start but replace all occurrences [E1](https://bugbountylibrary.com/r/h1%3A2257080.md).
- Server trusting client-supplied HTML fragments (e.g. `bc-attachment.content`) once an id resolves [E2](https://bugbountylibrary.com/r/h1%3A4175245.md).
- Sanitizers that allow `data-*` attributes later consumed by legacy `innerHTML` sinks [E2](https://bugbountylibrary.com/r/h1%3A4175245.md).
- Serializers that escape values but emit names raw [E3](https://bugbountylibrary.com/r/ghsa%3AGHSA-4w3w-2rp5-g8jm.md).

## How to review
Find every path where a name reaches the serializer and confirm it is validated against a QName/name grammar (no quotes, spaces, `>`, `=`). The invariant: **no attribute name is emitted unless it passed the same validation as the public API.** Check which helper the convenience method calls, not just that a validating one exists [E3](https://bugbountylibrary.com/r/ghsa%3AGHSA-4w3w-2rp5-g8jm.md). For filters, confirm substitution runs on raw input, not on rendered markup, and that a prefix check covers every replaced occurrence [E1](https://bugbountylibrary.com/r/h1%3A2257080.md). For stored HTML, confirm the server re-validates client fragments and that allowed `data-*` attributes are not later assigned to `innerHTML` [E2](https://bugbountylibrary.com/r/h1%3A4175245.md).

## How finders spotted it
- Noticed `link_pattern_start` only checks the prefix while `gsub` replaces all occurrences in `inner_html`; hypothesized attribute expansion inside nested anchors, then probed quote handling and parser differentials [E1](https://bugbountylibrary.com/r/h1%3A2257080.md).
- Noticed the server preserves client-supplied `bc-attachment.content` when the sgid is valid; tested invalid `select>option>div` nesting to see what the sanitizer let through [E2](https://bugbountylibrary.com/r/h1%3A4175245.md).
- Noticed a two-tier validation asymmetry: public `createAttribute()` validates QName but the common `setAttribute()` routes through an unvalidated private helper; tested quote/space in the name [E3](https://bugbountylibrary.com/r/ghsa%3AGHSA-4w3w-2rp5-g8jm.md).

## Variants seen
- Direct name injection through an unvalidated setter [E3](https://bugbountylibrary.com/r/ghsa%3AGHSA-4w3w-2rp5-g8jm.md).
- Indirect injection: filter re-expansion lands reference text inside an attribute [E1](https://bugbountylibrary.com/r/h1%3A2257080.md).
- Stored fragment re-parsed by an editor, normalizing invalid nesting into live elements exposing `data-*` [E2](https://bugbountylibrary.com/r/h1%3A4175245.md).

## Impact and severity
All three yielded XSS. E1 required chaining three primitives (gsub injection, href quote bypass, HTML4/HTML5 mXSS) [E1](https://bugbountylibrary.com/r/h1%3A2257080.md). E2 escalated to persistent administrator takeover via nonce propagation and CSRF-token reuse [E2](https://bugbountylibrary.com/r/h1%3A4175245.md). E3 is a library-level bypass affecting every consumer [E3](https://bugbountylibrary.com/r/ghsa%3AGHSA-4w3w-2rp5-g8jm.md). Severity rises with reach (library vs app) and with chaining to privileged actions.

## Seen in real software
Open-source packages and projects, and products, where this pattern was found. If the target runs one, compare the version it runs with the fix.
- **@xmldom/xmldom (npm)** >= 0.9.0, <= 0.9.10, fixed in 0.9.11: xmldom: Attribute name injection via setAttribute() bypasses requireWellFormed (CVE-2026-83605). Report: https://bugbountylibrary.com/r/ghsa%3AGHSA-4w3w-2rp5-g8jm.md. Fix: https://github.com/xmldom/xmldom/commit/cba1321218b069182695813fa7565653708e172e
- **GitLab**: Stored-XSS injected in Wiki page via Banzai pipeline. Report: https://bugbountylibrary.com/r/h1%3A2257080.md

## Evidence
- E1: https://bugbountylibrary.com/r/h1%3A2257080.md
- E2: https://bugbountylibrary.com/r/h1%3A4175245.md
- E3: https://bugbountylibrary.com/r/ghsa%3AGHSA-4w3w-2rp5-g8jm.md
