2026-02-03 — HtmlSanitizer bypass via <template> tag (GHSA-j92c-7v7g-gj3f)¶
What happened: HtmlSanitizer had an XSS sanitization bypass involving the <template> tag.
Why it matters: HTML sanitizers are notoriously hard to get right; bypasses often appear via: - overlooked elements (template, svg, math) - parser differentials between sanitizer and browser - attribute/namespace edge-cases
Durable guidance (defensive)¶
- Prefer context-aware output encoding over sanitization
-
If you can render as text, do that.
-
If you must accept rich HTML:
- Use a well-maintained sanitizer and keep it updated.
-
Apply a strict allowlist (tags + attributes) and ban high-risk elements (
script,style,template,svg,math). -
Backstop with CSP
-
Content-Security-Policywithscript-srcnonces/hashes reduces exploitability. -
Test bypasses in real browsers
- Add regression tests with known payloads.
References¶
- GitHub Advisory Database: https://github.com/advisories/GHSA-j92c-7v7g-gj3f
Consolidation note¶
This is the canonical page for this topic. During the 2026-05-22 redundancy pass, overlapping pages were reduced to compatibility pointers:
alerts/2026-02-05-htmlsanitizer-template-tag-bypass-ghsa-j92c-7v7g-gj3f.md