Filter Evasion Fundamentals
You'll learn how attackers bypass XSS filters using encoding tricks, obfuscation, and context switching to slip malicious payloads past defensive barriers.
What Are XSS Filters?
XSS filters are security mechanisms—built into browsers, web application firewalls (WAFs), or application code—that scan input for dangerous patterns like <script> tags or javascript: protocols. Think of them as security guards checking everyone's bags at an entrance: if they see something suspicious, they block it.
Why Filters Aren't Perfect
Filters typically use pattern matching—looking for specific keywords or character sequences. But attackers can transform their payloads while keeping them functionally identical, much like rephrasing a sentence so it says the same thing but looks completely different.
Common Bypass Techniques
Encoding transforms characters into alternative representations that filters don't recognize but browsers still interpret:
- HTML entities:
<script>becomes<script> - URL encoding:
javascript:becomesjava%73cript: - Unicode encoding: Using unusual character sets
Obfuscation disguises malicious code by making it harder to pattern-match:
- Case mixing:
<ScRiPt>instead of<script> - Comment insertion:
<scr<!--comment-->ipt> - String concatenation: Building payloads dynamically
Context switching exploits where your payload lands in the page. If a filter blocks <script> in HTML context, but your input goes into an HTML attribute, you might use " onload="alert(1)" instead—no script tags needed.
The Cat-and-Mouse Game
Filter evasion is a constant arms race. Attackers find creative ways to rephrase attacks, defenders update filters, and the cycle continues. Understanding these fundamentals helps you both test defenses and build better ones.
Key Takeaway: XSS filters rely on pattern recognition, but encoding, obfuscation, and context awareness let attackers transform malicious payloads to slip past detection while remaining executable.