URL Encoding Attacks and Bypasses
You'll learn: How attackers use creative URL encoding variations to slip malicious input past validation filters that only check for obvious patterns.
The Core Problem
URL encoding (percent-encoding) converts special characters into %XX format. For example, a space becomes %20, and a slash becomes %2F. Attackers exploit this by encoding malicious payloads in unexpected ways that filters don't recognize—but the underlying system still decodes and executes.
The danger multiplies when dealing with overlong UTF-8 sequences and mixed encoding schemes. These are technically invalid representations that some decoders accept anyway, creating bypass opportunities.
How Attackers Exploit It
Basic bypass example: A filter blocks ../ to prevent path traversal. An attacker sends %2e%2e%2f instead—same meaning after decoding, but the filter misses it.
Overlong UTF-8: The forward slash / should be encoded as %2F, but attackers might use %c0%af (an invalid two-byte sequence). Vulnerable decoders accept this, bypassing filters looking for legitimate encodings.
Mixed encoding: Attackers combine URL encoding with other schemes. For instance, double-encoding: %252e (which is %2e encoded again) decodes twice to .—if your filter only decodes once, it won't detect the pattern.
Think of it like this: You have a doorman checking guest names against a "no entry" list. Attackers show up with their names spelled backwards, in ALL CAPS, or phonetically. If the doorman only checks exact matches, they walk right in—even though it's still the same person.
Defense Strategy
Always canonicalize input before validation: decode all encoding layers until you have the simplest form, then validate. Never validate before decoding, and use strict decoders that reject invalid sequences like overlong UTF-8.
Key Takeaway: Attackers use percent-encoding variations, overlong UTF-8 sequences, and mixed encoding schemes to disguise malicious input; always canonicalize to the simplest form before validating.