Skip to content
XSS Write-up Intermediate

Hunting for Bugs When the Low-Hanging Fruit is Forbidden: A Deep Dive into Finding Reflected XSS

The blog search parameter was reflected unencoded into the page's title, meta description, JSON-LD structured data and body, because the site used dangerouslySetInnerHTML to render JSON-LD. An attacker could craft a link that runs JavaScript in a victim's browser, enabling phishing or session theft.

priyanshbhadoria5 Follow

Published on medium.com

Bug bounty is often romanticized as running automated scanners, waiting for the green text to pop up on your terminal, and collecting a bounty. But what happens when the target explicitly forbids reporting the exact things scanners are best at finding?

Priyansh, 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

The application used dangerouslySetInnerHTML to render JSON-LD structured data and concatenated the user-supplied search term into that JSON without encoding or sanitising it.

Impact

An attacker could craft a malicious URL that, when clicked, executes JavaScript in the victim's browser, allowing page rewriting for phishing or theft of session cookies if an admin is logged in.

What the attacker needed

Victim clicks a crafted link

The fix

The site should avoid dangerouslySetInnerHTML for user input and instead encode or sanitise the search term before rendering it, for example with a library like DOMPurify.

How it was found

  1. Crawl the site and extract the bundle-graph.json file to find dynamic routes.
  2. Identify the blog search route that takes a parameter.
  3. Send a unique marker string in the search path and check the response.
  4. Observe the marker reflected unencoded in the title, meta description, JSON-LD and body.
  5. Inspect the server payload and find dangerouslySetInnerHTML used for JSON-LD.
  6. Craft a payload that breaks out of the title tag and injects a script tag, then confirm it appears in the response.

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 something into a search box, the website often shows it back to you. If the site puts your text into the page without cleaning it first, an attacker can put code instead of normal text. That code then runs in the browser of anyone who clicks a specially made link, which is called cross-site scripting.

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 priyanshbhadoria5

View all

2 more disclosed reports, 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.