Skip to content
Account takeover Write-up Advanced

WAF Bypass + XSS + Business Logic Flaw = Account Takeover

A business logic flaw allowed multiple accounts to share the same email address, and password reset tokens were issued to the account with the highest ID. Combined with a reflected XSS in an HTML comment and a WAF bypass, an attacker could change a victim's email to an attacker-controlled address and then reset the password to take over the account.

ghostxploiter Follow

Published on medium.com

During a penetration test of a SaaS-based e-commerce web application, a vulnerability chain was discovered that allows for complete account takeover. The attack combines a business logic flaw in the password reset mechanism with Cross-Site Scripting (XSS) and Web Application Firewall (WAF) bypass techniques.

Ali Hussain, 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 application did not enforce unique email addresses, the password reset query selected the account with the highest ID when duplicates existed, and the URL path was reflected into an HTML comment without output encoding.

Impact

An attacker could take over any user account, gaining access to personal information, order history, and payment details, and could modify account settings or place orders.

What the attacker needed

Victim clicks a crafted link; attacker has an account; victim is logged in

The fix

The application should enforce unique email addresses, require email verification for changes, and properly encode all user-controlled data reflected in HTML; the WAF should also be fixed.

How it was found

  1. Intercept the profile update request and add an email field to change the account's email to an existing account's email.
  2. Observe that the application accepts the change and both accounts now share the same email.
  3. Initiate a password reset for the shared email and note that the reset token is generated for the account with the highest ID.
  4. Discover that the URL path is reflected in an HTML comment and test breaking out of the comment with an image tag.
  5. Confirm JavaScript execution by injecting an image tag with an onerror handler that calls alert.
  6. Craft an XSS payload that makes an API call to change the victim's email to an attacker-controlled address, bypassing WAF filters.

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 describes how three separate weaknesses were combined. First, the website let two accounts use the same email address, and when a password reset was requested, the reset link went to the newest account with that email. Second, a part of the website echoed the URL back into the page inside an HTML comment without cleaning it, so an attacker could inject JavaScript. Third, the firewall could be bypassed. By chaining these, an attacker could make a victim's browser change the victim's email to the attacker's address, then request a password reset and receive the link, taking over the…

What is Account takeover?

Getting into someone else's account through a flaw in sign-in, password reset, second factor, single sign-on or session handling.

Similar reports

View all

Same bug class and techniques, clearest first.

Account takeover

The lesson behind this report.

Getting into someone else's account through a flaw in sign-in, password reset, second factor, single sign-on or session handling.