XSS: Bypassing Cloudflare WAF with a Simple Trick
A search field was vulnerable to cross-site scripting, but Cloudflare's web application firewall blocked common payloads. The author bypassed the filter by using mixed-case HTML tags and event handlers, allowing execution of JavaScript in the victim's browser.
medium.com
Published on medium.com
This write-up is short and focused — I used a little AI help just to clean up grammar and flow 😄. Here’s what happened and exactly how I bypassed Cloudflare’s WAF to trigger an XSS.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the web application firewall used case-sensitive pattern matching to block XSS payloads, and the application itself did not properly sanitise or encode user input.
Impact
An attacker could execute arbitrary JavaScript in a victim's browser, potentially stealing cookies or performing actions on behalf of the user.
What the attacker needed
Victim visits a crafted URL or page
The fix
The application should sanitise or encode user input, use proper HTML/JS parsing instead of pattern matching, block risky attributes server-side, and add a strict Content Security Policy.
How it was found
- Find a search field on the target site.
- Try common XSS payloads and observe that Cloudflare blocks them.
- Test which characters and tokens are blocked or allowed.
- Try mixed-case versions of blocked tokens and find that some pass.
- Craft a payload using mixed-case tags and event handlers that executes JavaScript.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
Cross-site scripting (XSS) is a bug where an attacker can make a website run their JavaScript code in another user's browser. Here, the site's search box didn't clean user input properly, and the firewall tried to block common attack patterns but missed variations in letter case.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.