Course contentsShow
← Security
Lesson 608 of 3,05213. Web Security - Injection AttacksFree lesson

Filter Bypass and Obfuscation

Evading blacklists and weak filters using encoding, variable expansion, wildcards, and command substitution.

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/passwd becomes c\141t /etc/passwd (octal) or cat%20/etc/passwd (URL encoding)

Variable Expansion: Break up blocked words using shell variables:

  • cat /etc/passwd becomes c$()at /etc/passwd or ca''t /etc/passwd

Wildcards: Use globbing patterns to match commands without typing them:

  • cat /etc/passwd becomes /bin/c?t /etc/passwd or /???/c*t /etc/passwd

Command Substitution: Nest commands to hide intent:

  • $(printf 'cat') /etc/passwd or 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.