Course contentsShow
← Security
Lesson 650 of 3,05214. Web Security - XSS and Content InjectionFree lesson

Case Manipulation and Alternative Syntax

Exploiting case-insensitive parsing, mixed case tags, and alternative JavaScript syntax to bypass case-sensitive filters.

Case Manipulation and Alternative Syntax

What you'll learn: How attackers use mixed-case tags and creative JavaScript syntax to slip past filters that only look for exact text matches.

The Core Idea

Many early XSS filters work by searching for dangerous strings like <script> or alert() exactly as written. But HTML and JavaScript parsers are case-insensitive in many contexts, while naive filters often aren't. An attacker can exploit this mismatch by writing <ScRiPt> or aLeRt() instead—the browser understands it perfectly, but the filter misses it entirely.

Think of it like a guard who's been told to stop anyone wearing a "RED shirt"—but you walk past wearing a "rEd ShIrT" and they don't recognize it's the same thing.

How Case Manipulation Works

HTML tags are case-insensitive: <script>, <SCRIPT>, and <ScRiPt> all execute identically in browsers. JavaScript function names like alert, Alert, and aLeRt also work the same way.

Attackers combine this with alternative JavaScript syntax:

  • Instead of alert(1), try (alert)(1) or [1].map(alert)
  • Use different quote types: ', ", or backticks
  • Exploit whitespace tolerance: < script > or <script/src=x>

Defeating Simple Filters

If a filter blocks <script>alert(1)</script>, you might bypass it with:

  • <ScRiPt>alert(1)</ScRiPt>
  • <SCRIPT>alert(1)</SCRIPT>
  • <sCrIpT>alert(1)</sCrIpT>

The browser normalizes these during parsing, but string-matching filters see completely different text patterns.

Key Takeaway: Case-insensitive parsing and flexible JavaScript syntax create huge evasion opportunities against filters that rely on exact pattern matching—defenders must normalize input before validation, not just search for lowercase strings.