Skip to content
XSS Write-up Beginner

Hunting A Zero Click Reflected Xss Breaking Out Of Attributes In Wordpress Search

The WordPress search input was reflected into an HTML attribute without proper escaping, allowing an attacker to break out of the value attribute and inject an autofocus/onfocus handler. A crafted search URL would execute JavaScript automatically on page load, enabling session theft, phishing overlays, or defacement.

Maverick Follow

Published on infosecwriteups.com

The original lives on infosecwriteups.com

We do not hold its text, 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

The search parameter was echoed into an HTML attribute without attribute-safe escaping, allowing an attacker to close the value attribute and inject new attributes and an event handler.

Impact

An attacker could execute arbitrary JavaScript in the site's origin, potentially stealing non-HttpOnly cookies or sessions, creating phishing overlays, keylogging, or defacing the page; the report notes the issue was on a marketing site and was deemed out-of-scope for the bounty programme.

What the attacker needed

Victim clicks a crafted link; WordPress search reflects input unescaped

The fix

The search input should be escaped with an attribute-safe function such as esc_attr() before being echoed into the value attribute; the report says the issue appears to have been fixed shortly after disclosure.

How it was found

  1. Craft a search URL where the s parameter contains a quote to close the value attribute, followed by autofocus and an onfocus handler, then a dummy attribute to balance the syntax.
  2. Send the crafted URL to a victim; when the victim loads the page, the injected input auto-focuses and the onfocus handler 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.

When you type a search term, the website often puts it back into the search box on the results page. If the site does not clean that text properly, an attacker can include special characters that trick the browser into treating part of the search term as code. Here, the attacker made the search box automatically focus itself and run a small script as soon as the page loaded, so the victim did not need to click anything.

What is XSS?

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

More by Maverick

View all

1 more disclosed report, best first.

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.