Strored Xss
A blog comment function stored user input without sanitisation, allowing an attacker to inject a script that executed in other users' browsers. The attacker could steal session cookies, capture auto-filled passwords, or read CSRF tokens to change the victim's email address and take over the account.
medium.com
Published on medium.com
Stored XSS, where the malicious script comes from the website’s database, also known as second-order or persistent XSS.
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 application stored comment content and later inserted it into HTML responses without encoding or sanitising it, so script tags were treated as executable markup.
Impact
An attacker could fully compromise a victim's account by stealing cookies, capturing auto-filled passwords, or bypassing CSRF protections to change the email address and then reset the password.
What the attacker needed
Victim views the comment; attacker can post a comment; victim is logged in
The fix
The application should encode or sanitise stored user input before including it in HTML responses, and use a strict Content Security Policy to limit script execution.
How it was found
- Log in with the provided credentials and open the account page to find the email update form.
- Inspect the page source to see the POST request to the change-email endpoint and the hidden anti-CSRF token.
- Submit a simple script in the comment box to confirm the stored XSS triggers.
- Replace it with a script that fetches the account page, extracts the CSRF token, and sends a request to change the email address.
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.
Stored cross-site scripting (XSS) happens when a website saves something a user typed, like a comment, and later shows it to other people without cleaning it first. If the saved text contains code, the browser runs that code as if the website itself had written it. This lets an attacker act as the victim, for example by reading their cookies or changing their account details.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.