How I Found a Reflected XSS Bug in 45 Minutes Using ChatGPT — and Earned $800
A search parameter was reflected inside a JavaScript string without proper escaping, allowing an attacker to inject code. By using a delayed execution payload, the attacker could execute JavaScript in a logged-in user's browser and steal session cookies.
Published on theindiannetwork.medium.com
Bug bounty isn’t always about months of recon or complex 0-days. Sometimes, a well-placed payload in the right context can pay off fast.
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
An attacker could steal session cookies, modify the page for phishing, or exfiltrate data if a logged-in user clicked a malicious link; no CSP was present and cookies were not HttpOnly.
What the attacker needed
Victim clicks a crafted link; victim is logged in
The fix
The application should use context-aware output encoding for JavaScript strings and add a Content-Security-Policy header.
How it was found
- Log into the app and use the search feature with a test string.
- Observe that the input is reflected inside a JavaScript string in the page source.
- Try a simple JavaScript injection payload, but it does not execute due to a later script overwriting the variable.
- Use a delayed execution payload (setTimeout) to run code after the overwriting script.
- Confirm the alert pops up, proving code execution.
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 a website puts user input directly into a script without cleaning it, an attacker can add their own code. This is called cross-site scripting (XSS). If a victim clicks a crafted link, the attacker's code runs in the victim's browser and can steal their login session.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.