Filter Bypass and Obfuscation
What You'll Learn
You'll learn how attackers evade weak input filters and blacklists by encoding, manipulating, or disguising their command injection payloads.
The Core Problem
Many applications try to block command injection by filtering "dangerous" characters or commands—like blocking semicolons, pipes, or the word cat. But simple blacklists are notoriously easy to bypass. Attackers use obfuscation (disguising the attack) and encoding tricks to make malicious payloads look innocent to filters while still executing as intended.
Think of it like a bouncer checking IDs at a club: if they only reject people wearing red shirts, you just wear blue and walk right in.
Common Bypass Techniques
Encoding: Use hex, octal, or URL encoding to hide characters:
cat /etc/passwdbecomesc\141t /etc/passwd(octal) orcat%20/etc/passwd(URL encoding)
Variable Expansion: Break up blocked words using shell variables:
cat /etc/passwdbecomesc$()at /etc/passwdorca''t /etc/passwd
Wildcards: Use globbing patterns to match commands without typing them:
cat /etc/passwdbecomes/bin/c?t /etc/passwdor/???/c*t /etc/passwd
Command Substitution: Nest commands to hide intent:
$(printf 'cat') /etc/passwdor backticks like`echo cat` /etc/passwd
Case Manipulation: In some systems, mix uppercase/lowercase or use alternate command paths.
Why This Matters
Blacklist-based filters fail because attackers have infinite creativity. Defenders must use whitelists (only allow known-good patterns) and proper input validation instead of trying to block every bad thing.
Key Takeaway:
Attackers bypass weak filters through encoding, variable tricks, wildcards, and command substitution—never rely on blacklists alone for security.