Zero-Width and Invisible Characters
What you'll learn: How attackers use invisible Unicode characters to sneak past input validation and hide malicious payloads in plain sight.
The Hidden Threat in Plain Text
Unicode includes characters that are completely invisible to users but present in the actual text data. These include zero-width joiners (ZWJ), zero-width non-joiners (ZWNJ), zero-width spaces (ZWSP), and other invisible control characters. While designed for legitimate linguistic purposes (like connecting emoji or shaping complex scripts), attackers exploit them to bypass security filters that look for visible patterns.
How Attackers Exploit Invisibility
Imagine a validation rule that blocks the string <script>. An attacker inserts invisible characters:
<script> // Contains a zero-width space between 'c' and 'r'
To human eyes, it looks identical. To naive validators checking string equality, it's different—so it passes through. Later processing might strip these characters, reassembling the dangerous payload.
Common Attack Scenarios
Bypassing keyword filters: Inserting ZWSP into SQL keywords (SELECT), command names, or restricted function calls.
Hiding data exfiltration: Embedding invisible characters in seemingly innocent text fields to encode secrets.
Username spoofing: Creating accounts like admin (with ZWSP) that visually impersonate admin but are technically different strings.
Payload concealment: Hiding XSS or injection attacks that validators miss because they don't normalize invisible characters before checking.
The Normalization Gap
This ties directly back to the previous lessons on Unicode normalization—invisible characters often survive improper normalization. Robust validation must strip or reject all zero-width and invisible Unicode characters before any pattern matching or business logic validation occurs.
Key Takeaway: Zero-width and invisible Unicode characters allow attackers to hide payloads from visual inspection and bypass validation filters that don't normalize input—always strip or explicitly reject these characters during canonicalization.