Character Encoding Bypasses
What you'll learn: How attackers use different character encodings to disguise malicious payloads and slip past basic XSS filters.
The Core Problem
Imagine a security guard checking IDs at a door who only recognizes English names. If someone shows up with their name written in Greek letters or spelled phonetically, the guard might wave them through—even though it's the same person on the banned list.
Similarly, basic XSS filters often look for exact string matches like <script> or alert(. But the browser understands many different ways to represent the same characters. Attackers exploit this mismatch between what filters check and what browsers execute.
Common Encoding Techniques
HTML Entities: Instead of <script>, use <script> or numeric forms like <script>. Browsers decode these back to <script>.
URL Encoding: Transform characters into percent-encoded forms: %3Cscript%3E becomes <script> when processed by the browser.
Unicode Variations: Some Unicode characters look identical or similar to ASCII. For example, Cyrillic 'а' (U+0430) appears like Latin 'a' (U+0061), potentially bypassing keyword filters.
Mixed Encodings: Combine techniques: <script%3E mixes HTML entity and URL encoding. Layered decoding can defeat simple pattern matching.
Double Encoding: Encode twice—%253C becomes %3C after one decode, then < after the second. Useful when input passes through multiple decoding stages.
Why It Works
Basic filters use simple string matching (if input contains "<script>"). They don't account for the browser's parsing process, which normalizes various encodings into executable code after the filter check.
Key Takeaway: Attackers bypass basic XSS filters by exploiting character encoding variations—HTML entities, URL encoding, Unicode alternatives, and mixed schemes—that filters miss but browsers decode and execute. Robust defenses must decode input through all layers before validation.