Reflected XSS in HTML Context with Most Tags and Attributes Blocked
The application reflected user input into an HTML page without proper escaping, and although most tags and attributes were blocked, the <body> tag and onresize event handler were allowed. An attacker could craft a payload that executes JavaScript (print()) automatically when the victim's browser resizes, potentially stealing session cookies if not HttpOnly.
Published on bashoverflow.medium.com
In this scenario, the application features a search functionality that reflects user input into the HTML page. Normally, reflected XSS occurs when user input is returned without proper sanitization or escaping, allowing malicious scripts to execute in the victim’s browser.
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
Impact
Attackers could execute JavaScript to steal session cookies or tokens if cookies are not HttpOnly, and bypass WAF protections that block common tags.
What the attacker needed
Victim visits attacker-controlled page; victim's browser resizes
The fix
The application should properly escape or sanitize user input before reflecting it into HTML, rather than relying on an incomplete blocklist of tags and attributes.
How it was found
- Access the lab environment and locate the search form.
- Test a basic XSS payload and observe it is rejected with 'Tag is not allowed'.
- Use Burp Intruder to enumerate allowed tags and find that <body> is allowed.
- Enumerate allowed event handler attributes and find that onresize is allowed.
- Craft a payload using <body onresize=print()> and verify it works by resizing the browser.
- Host an exploit page with an iframe that loads the vulnerable URL with the payload and triggers onresize automatically, then deliver to victim.
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.
This is a reflected cross-site scripting (XSS) bug. The search box puts whatever you type directly into the web page without cleaning it. Even though the site blocks many dangerous HTML tags, it missed a few, so an attacker can still sneak in code that runs in the victim's browser.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.