Skip to content
CSRF Write-up Intermediate

Stored HTML Injection leading to CSRF-based Account Takeover

A blog comment field allowed stored HTML injection, and the email-change endpoint lacked CSRF protection and accepted GET requests. An attacker could trick a logged-in user into clicking a link that silently changed their email, enabling account takeover via password reset.

medium.com

Published on medium.com

Recently, during a private bug bounty program in my country, I discovered a critical issue in a blog subdomain of a web application that led to Account Takeover (ATO).

Hossein Zarei, 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

Likely the email-change endpoint lacked a CSRF token and used a request method that accepted both GET and POST, while the comment feature allowed stored HTML links.

Impact

An attacker could silently change a victim's email and then reset the password to achieve full account takeover; the attack required the victim to click a link.

What the attacker needed

Victim is logged in; victim clicks a link in a comment; attacker can post comments

The fix

The endpoint should require a CSRF token and enforce the POST method, and the comment feature should properly sanitise HTML.

How it was found

  1. Post a comment containing an HTML anchor link to the email-change endpoint with the attacker's email as a parameter.
  2. Wait for a logged-in user to view the comment and click the link.
  3. The user's email is changed to the attacker's address.
  4. The attacker initiates a password reset to take over the account.

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 website let users post comments containing basic HTML, like links. The email-change feature did not check for a secret token and accepted a simple link click. So an attacker could post a comment with a link that, when clicked by a logged-in user, changed that user's email to the attacker's address. The attacker could then reset the password and take over the account.

What is CSRF?

Another site makes a signed-in user's browser perform an action they did not intend.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site request forgery (CSRF)

The lesson behind this report.

Another site makes a signed-in user's browser perform an action they did not intend.