Skip to content
XSS Write-up Intermediate

How do i bypass waf for xss in input tag?

A reflected cross-site scripting flaw existed in a product_name query parameter that was written into an input element's value attribute without proper encoding. The author found that a WAF blocked script and img tags but not event handlers, and could trigger script by making the input autofocus and fire an onfocus handler.

lyltvip Follow

Published on medium.com

I tried to use script tag, https://target.com/?productname=test"<script>alert(1)</script><

lanyi, on medium.com

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 parameter value was inserted into an HTML attribute without encoding, and the WAF only blocked specific tags rather than dangerous attributes.

Impact

An attacker could run JavaScript in a victim's browser by getting them to open a crafted link, though the first payloads needed the mouse to move over the input.

What the attacker needed

Victim opens a crafted link; WAF does not block event handlers

How it was found

  1. Request the product_name parameter with a test value and observe it reflected inside an input value attribute.
  2. Try a script tag and an img tag and see the WAF filter them.
  3. Use an onmouseover handler with a closing quote to break out of the value attribute.
  4. Add a style attribute to make the input cover the page so the mouse triggers the handler.
  5. Use autofocus and an onfocus handler so the payload fires without user interaction.

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.

A web page took text from the address bar and placed it inside an HTML input box without cleaning it. By adding extra HTML attributes, the author made the browser run JavaScript when the box received focus. A WAF is a filter that tries to block such attacks, but it only checked for some patterns.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.