Exploiting XSS to Bypass CSRF Defenses: Change Victim’s Email
A stored XSS vulnerability in a blog comment section allowed an attacker to execute JavaScript in a victim's browser, steal their CSRF token, and use it to change the victim's email address. This bypassed CSRF protections that would normally prevent such an action.
infosecwriteups.com
Published on infosecwriteups.com
The PortSwigger lab, “Exploiting cross-site scripting to perform CSRF”, demonstrates a real-world scenario where a stored XSS vulnerability in a blog comment section can be leveraged to bypass CSRF protections.
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 comment feature failed to sanitise user input, allowing stored JavaScript to execute, and the CSRF token was accessible to that script.
Impact
An attacker could impersonate the victim and perform sensitive actions such as changing the victim's email address, potentially leading to privilege escalation through admin hijacking.
What the attacker needed
Victim views the malicious comment; victim is logged in
How it was found
- Open a blog article and scroll to the comment section.
- Submit a simple XSS payload to confirm the comment feature is vulnerable.
- Observe the email change request in Burp Suite to understand the mechanism.
- Generate a CSRF PoC form from the captured request.
- Capture the CSRF token using JavaScript by fetching the account page and parsing the HTML.
- Log out of the test account, then submit the final exploit payload in a comment on a different blog post.
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.
This report shows how a comment box that lets you post JavaScript can be abused. When someone views the comment, the script runs in their browser, reads a secret code (CSRF token) that protects forms, and uses it to change their email without permission.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.