Bidirectional Text and Control Characters
What You'll Learn
You'll discover how invisible Unicode bidirectional override characters can flip text display to hide malicious code in plain sight.
The Hidden Text Direction Trick
Unicode supports languages that read right-to-left (like Arabic and Hebrew) through special bidirectional control characters. These invisible characters tell your browser or editor which direction to render text—but attackers can weaponize them to disguise malicious content.
The most dangerous characters are:
- U+202E (Right-to-Left Override) — forces following text to display backward
- U+202D (Left-to-Right Override)
- U+200E and U+200F (directional marks)
The Visual Deception Attack
Imagine reviewing code where a filename appears to be report.pdf, but contains a hidden U+202E character. What actually gets processed might be report_fdp.exe — an executable disguised through reversed display!
In source code comments or string literals, an attacker could write what looks like:
// Safe comment about data.txt
But contains hidden characters that reverse part of the text, so the actual underlying characters spell something completely different—perhaps containing injection payloads or hiding the true nature of a command.
Why This Matters for Input Validation
These control characters:
- Are invisible to human reviewers
- Survive copy-paste operations
- Can bypass keyword filters that only check the visual representation
- Work in filenames, URLs, comments, and user-submitted text
Users or even developers might unknowingly introduce malicious content that looks benign but executes something entirely different.
Defense Strategy
Your validation layer must strip or reject bidirectional override characters unless you have a specific, legitimate need for multilingual text. Never trust what text looks like—validate the actual character sequence.
Key Takeaway: Unicode bidirectional control characters can invisibly reverse displayed text, allowing attackers to hide malicious filenames, code, or commands in plain sight—always validate the actual byte sequence, not just the visual appearance.