Understanding Percent EncodingCompTIA Security+ and CySA+ Exam Prep
Percent encoding, also known as URL encoding, is one of the most commonly encountered concepts in web application security, log analysis, threat hunting, and incident response. While CompTIA Security+ focuses on recognizing web-based attacks and secure application concepts, CySA+ expands into log analysis, SIEM investigations, threat hunting, and vulnerability assessment where percent encoding appears frequently.
Understanding percent encoding can help you identify:
- SQL injection attempts
- Cross-site scripting (XSS) attacks
- Directory traversal attacks
- Command injection attacks
- Obfuscated malware traffic
- Web server log anomalies
- WAF bypass attempts
What Is Percent Encoding?
Percent encoding is a method for representing characters in URLs using hexadecimal values.
The format is:
%HH
Where:
- % indicates encoding
- HH is the hexadecimal ASCII value
Example:
- Space = %20
Original URL:
- https://example.com/search?q=security plus
Encoded URL:
- https://example.com/search?q=security%20plus
Why Percent Encoding Exists
Certain characters have special meaning inside URLs.
Examples include:
1 /
2 ?
3 &
4 =
5 #
6 %
To prevent confusion, these characters may be encoded.
For example:
/
becomes:
%2F
Common Percent Encodings
Character Encoding
Space %20
! %21
" %22
# %23
$ %24
& %26
' %27
( %28
) %29
+ %2B
, %2C
/ %2F
: %3A
; %3B
< %3C
= %3D
> %3E
? %3F
@ %40
Why Security Analysts Care About Percent Encoding
Attackers rarely send attacks in plain text.
Instead, attackers encode payloads to:
- Avoid detection
- Bypass web filters
- Evade IDS/IPS rules
- Bypass WAF signatures
- Obfuscate malicious activity
Example:
Normal:
../../../etc/passwd
Encoded:
..%2F..%2F..%2Fetc%2Fpasswd
Or
%2E%2E%2F%2E%2E%2F%2E%2E%2Fetc%2Fpasswd
A web application firewall may miss poorly written detection rules that only search for:
../../../
Directory Traversal Examples
Security+ and CySA+ often test directory traversal attacks.
Attack:
../../../etc/passwd
Encoded version:
..%2F..%2F..%2Fetc%2Fpasswd
Or
%2E%2E%2F%2E%2E%2F%2E%2E%2Fetc%2Fpasswd
Double encoded:
..%252F..%252F..%252Fetc%252Fpasswd
Explanation:
%25 = %
Thus:
%252F
becomes:
%2F
which becomes:
/
This technique can defeat improperly configured web filters.
SQL Injection and Percent Encoding
Attackers frequently encode SQL injection payloads.
Normal payload:
' OR 1=1--
Encoded:
%27%20OR%201%3D1--
Breakdown:
' = %27
space = %20
= = %3D
Security analysts reviewing logs should recognize this immediately.
Example log:
GET /login.php?id=%27%20OR%201%3D1--
This indicates a possible SQL injection attempt.
Cross-Site Scripting (XSS)
XSS attacks often appear encoded.
Normal XSS:
<script>alert(1)</script>
Encoded:
%3Cscript%3Ealert%281%29%3C%2Fscript%3E
Breakdown:
1 < = %3C
2 > = %3E
3 ( = %28
4 ) = %29
5 / = %2F
Log review questions on CySA+ frequently include encoded XSS payloads.
Command Injection Examples
Original payload:
; cat /etc/passwd
Encoded:
%3B%20cat%20%2Fetc%2Fpasswd
Breakdown:
1 ; = %3B
2 space = %20
3 / = %2F
Analysts should immediately recognize:
cat /etc/passwd
as a Linux file disclosure attempt.
Identifying Attacks in Logs
Security analysts spend significant time reviewing logs.
Example:
192.168.1.100 - GET /index.php?page=..%2F..%2Fetc%2Fpasswd
Decoded:
../../etc/passwd
Potential attack:
Directory Traversal
Example:
GET /search?q=%3Cscript%3Ealert%281%29
Decoded:
<script>alert(1)
Potential attack:
Cross-Site Scripting
Example:
GET /login?id=%27%20OR%201%3D1--
Decoded:
' OR 1=1--
Potential attack:
SQL Injection
Double Encoding
More advanced attackers use double encoding.
Example:
../
becomes:
%2E%2E%2F
Double encoded:
%252E%252E%252F
The server decodes:
First pass:
%2E%2E%2F
Second pass:
../
The attack then executes.
CySA+ often includes questions involving obfuscated payloads like this.
WAF Evasion
Web Application Firewalls inspect incoming traffic.
Attackers frequently encode requests to evade detection.
Blocked:
<script>
Encoded variation:
%3Cscript%3E
Double encoded variation:
%253Cscript%253E
Poorly configured WAFs may miss these patterns.
Percent Encoding in Threat Hunting
Threat hunters frequently search SIEM data for encoded indicators.
Useful indicators include:
1 %2F
2 %252F
3 %3Cscript
4 %3E
5 %27
6 %20OR
Common hunting queries:
%2e%2e
%252e
%3cscript
%27%20or
These often reveal attack recon activity.
Exam-Relevant Attack Patterns
Directory Traversal
..%2F..%2F..%2F
Recognize:
Directory Traversal
SQL Injection
%27%20OR%201%3D1--
Recognize:
SQL Injection
Cross-Site Scripting
%3Cscript%3E
Recognize:
XSS
Command Injection
%3Bcat%20%2Fetc%2Fpasswd
Recognize:
Command Injection
Security+ Exam Tips
For Security+:
Know how to identify:
- SQL Injection
- XSS
- Command Injection
- Directory Traversal
Understand that percent encoding is commonly used to:
- Obfuscate attacks
- Bypass filters
- Exploit web applications
CySA+ Exam Tips
For CySA+:
Expect to:
- Analyze web logs
- Decode attack strings
- Investigate IDS alerts
- Interpret SIEM events
- Identify WAF bypass techniques