Exploiting Cross-Site Scripting to Capture Passwords
The blog comments function had a stored XSS vulnerability that allowed an attacker to inject fake login fields and a script. When a victim visited the comment, the script captured their username and password and posted them as a new comment, enabling the attacker to log in as the victim.
Published on medium.com
This lab contains a stored XSS vulnerability in the blog comments function. A simulated victim user views all comments after they are posted.
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 blog comments function did not properly sanitise user input, allowing HTML and JavaScript to be stored and executed when other users viewed the comment.
Impact
An attacker could capture a victim's username and password and use them to log in to the victim's account, but this only works if the victim's browser auto-fills the fake fields.
What the attacker needed
Victim views the comment; victim's browser auto-fills credentials
How it was found
- Navigate to a blog post and find the comment form.
- Inject HTML input fields for username and password, with an onchange event handler calling a function.
- Post the comment and verify the input fields appear.
- Craft a script that reads the values of the username and password fields and posts them as a comment.
- Post the complete payload as a comment.
- Wait for the simulated victim to visit the comment, then view the stolen credentials in a new comment and log in.
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.
The blog let people post comments that could include HTML and JavaScript code. The attacker posted a comment that looked like a login form and added a script that, when the victim typed into the form, sent their username and password back to the blog as another comment. The attacker could then read that comment and use the stolen details to log in as the victim.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.