Skip to content
XSS Write-up Intermediate

Reflected XSS To Account Takeover Without Stealing Session Cookie

A reflected XSS in the redirect_uri parameter of a forgot-password flow allowed script execution in the victim's browser. Because the session cookie was HttpOnly, the attacker instead stole a non-HttpOnly CSRF token cookie and used it to change the victim's password without knowing the current one, achieving account takeover.

rifqihz Follow

Published on medium.com

Hello everyone, I’m Rifqihz a college student, certified Google ACE, BSCP, bug hunter and pentester. This is my first article since 1,5 years ago :’)

Rifqi Hilmy Zhafrant, 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 redirect_uri parameter was reflected into a JSON response without proper encoding, and the password-change endpoint accepted a CSRF token from a readable cookie while not requiring the current password.

Impact

An attacker could take over a victim's account by changing their password without knowing the current one, provided the victim opens the crafted link.

What the attacker needed

Victim clicks a crafted link; attacker-controlled server

How it was found

  1. Open the forgot-password page with a crafted redirect_uri value and observe the parameter reflected in the response.
  2. Submit the forgot-password form and follow the redirect to the password-sent page.
  3. On the password-sent page, inject a quote into redirect_uri to break the JSON and confirm reflection.
  4. Use a payload that calls Function with a base64-encoded script to execute JavaScript.
  5. The script reads the CSRF token cookie, fetches the victim's profile, and sends a password-change request.
  6. The script notifies the attacker's server with the victim's email so the attacker can log in with the new password.

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.

A reflected cross-site scripting (XSS) bug lets an attacker's JavaScript run in another user's browser when they open a crafted link. Normally an attacker would steal the login cookie, but here that cookie was marked HttpOnly, meaning scripts cannot read it. Instead, the attacker read a different cookie holding a CSRF token (a secret value meant to stop forged requests) and used it to change the victim's password.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

More by rifqihz

View all

4 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.