← Lab /Security & privacy

Custom tag names can execute JavaScript and bypass WAFs

Any JavaScript payload can be executed by embedding it in a custom HTML tag name, bypassing WAFs in all browsers.

Security & privacy PortSwigger Research 25 Aug 2026 Attack Prototype evidence

Published as “What's in a tag name? JavaScript, apparently”

Why it matters

Tag name parsing can be abused to inject executable JavaScript, allowing attackers to bypass WAF signatures that rely on tag or attribute whitelists.

Summary

The author experimented with HTML tag names, discovering that browsers preserve the original name in the element's localName property in lowercase. By crafting a tag whose name contains JavaScript code and using attributes like onfocus, tabindex, or contenteditable, the code can be executed when the element receives focus. The technique works across major browsers and can evade typical WAF blocklists that filter on known tags or attributes. Evidence consists of manually tested payloads demonstrated in the write-up.

What they found 2

  1. The technique works in every browser tested.

    “I'm sure you'll agree that it's pretty shocking, and it works in every browser.”

  2. An opening angle bracket can be part of the tag name.

    “An opening angle bracket can actually be part of the tag name.”

Caveats 3

  • Alphabetic characters, forward slashes, whitespace, and newlines get transformed, limiting which characters can be used directly.
  • The author notes that certain characters are transformed (alphabetic, '/', whitespace, newlines), which may restrict payload composition.
  • No systematic testing across all browsers or versions is reported.

What’s new here 4

  • Shows that arbitrary JavaScript can be placed in a tag name and later retrieved via localName.
  • Demonstrates multiple payload constructions using attributes[0].value, textContent, nodeValue, getAttributeNode, and setHTMLUnsafe.
  • Reveals that an opening angle bracket (<) is allowed in a tag name, enabling mixed markup XSS vectors.
  • Uses the part and classList attributes to build eval-based execution chains.