Skip to content
XSS Write-up Beginner

The Day Our Customer Portal Got Hacked: My XSS Nightmare and How

A community forum stored user-supplied HTML without proper sanitisation, allowing an attacker to inject a script that stole session cookies and replaced the billing page's payment form with one that sent card details to an external site. The attacker could then hijack sessions and harvest payment information from other users.

Sanh Doan Follow

Published on medium.com

It was a regular Tuesday morning when our customer support team started receiving frantic calls. “I’m seeing someone else’s account information when I log in!” “There’s a weird pop-up asking for my credit card details!” “Your website keeps redirecting me to some gambling site!”

Sanh Doan, 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

The application trusted a third-party rich text editor's built-in sanitisation and inserted user content directly into the page without additional encoding or sanitisation.

Impact

Attackers could steal session cookies to hijack accounts and harvest credit card details via a cloned payment form; the text does not mention any defence that limited the exploit.

What the attacker needed

A free account on the forum; victim views the malicious post; victim visits the billing page

The fix

The application was fixed by adding strict server-side HTML sanitisation, switching to a template engine with auto-escaping, implementing a Content Security Policy, securing cookies, and adding automated security scanning.

How it was found

  1. The attacker created a forum account two weeks before the incident and studied how the site worked.
  2. The attacker posted a normal-looking question with a hidden script embedded in the content.
  3. The rich text editor's basic sanitisation was bypassed because the script was wrapped in a hidden div.
  4. When other users viewed the forum post, the script executed in their browsers, stealing session cookies.
  5. The script also replaced the billing page's payment form with one that sent card details to an external site.

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.

Cross-Site Scripting (XSS) is when a website lets a user's input contain code that other visitors' browsers then run. Here, the forum saved posts without cleaning them, so a malicious post could run a script in every reader's browser, steal their login cookie (a small file that keeps you signed in), and swap the payment form for a fake one.

What is XSS?

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

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.