Listen to this Post

Introduction
Web Application Firewalls (WAFs) are critical security measures designed to block malicious payloads, including Stored Cross-Site Scripting (XSS) attacks. However, attackers often find creative ways to bypass these protections. This article explores a simple yet effective WAF bypass technique involving HTTP headers and provides actionable insights for both penetration testers and defenders.
Learning Objectives
- Understand how WAFs detect and block Stored XSS payloads.
- Learn a verified bypass technique using `Content-Encoding` header manipulation.
- Discover mitigation strategies to protect web applications from such bypasses.
1. WAF Bypass via `Content-Encoding` Header
Verified Command/Code Snippet
POST /vulnerable-endpoint HTTP/1.1 Host: target.com Content-Type: application/x-www-form-urlencoded Content-Encoding: random_text name=<script>alert(1)</script>&submit=true
Step-by-Step Guide
- Identify a Stored XSS Entry Point β Find a form or input field where user-supplied data is stored and later rendered.
- Craft a Malicious Payload β Use a basic XSS payload like
<script>alert(1)</script>. - Add a Bogus `Content-Encoding` Header β Some WAFs fail to decode or inspect payloads when this header is present.
- Submit the Request β If the WAF misinterprets the encoding, the payload may bypass detection and execute upon rendering.
2. Alternative Bypass: Obfuscated JavaScript
Verified Payload
<img src=x onerror="\u0061\u006c\u0065\u0072\u0074(1)">
Step-by-Step Guide
- Use Unicode Escape Sequences β Convert JavaScript functions (
alert) into escaped characters. - Embed in HTML Event Handlers β Use attributes like `onerror` or
onload. - Test Against WAF Rules β Some WAFs fail to normalize Unicode, allowing execution.
3. Bypassing WAFs with Broken Parsing
Verified Technique
GET /search?q=<scr<script>ipt>prompt(1)</script> HTTP/1.1
Step-by-Step Guide
- Nested Tags β Insert redundant characters (
<scr<script>ipt>) to confuse WAF parsers. - Test for Filter Evasion β Some WAFs remove only the first `