Skip to content
XSS Write-up Intermediate

Self-XSS + CSRF Leading to Account Takeover (50-Character Payload

A reflected input field was vulnerable to self-XSS and the form saving it lacked CSRF protection, so an attacker could force a victim's browser to store a short script tag. Because session cookies lacked the HttpOnly flag, the external script could read them and send them to the attacker, leading to account takeover.

CANITEY Follow

Published on canitey.medium.com

Today I’m sharing an interesting chain: Self-XSS + CSRF that results in full account takeover, with one tricky constraint — the vulnerable field only accepted a maximum of 50 characters.

CANITEY, on canitey.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 input was reflected without sanitisation, the saving form had no CSRF token or SameSite protection, and session cookies were not marked HttpOnly.

Impact

An attacker could take over a victim's account by stealing their session cookie, provided the victim loads the malicious page.

What the attacker needed

Victim is logged in; victim loads attacker's page; external script host reachable

The fix

The input should be properly sanitised or encoded, the form should require a CSRF token and SameSite cookies, and session cookies should be marked HttpOnly.

How it was found

  1. Find an input field that reflects unsanitised input and confirm script execution.
  2. Check that the form saving the report list name has no CSRF protection.
  3. Host a short script externally and shorten its URL to fit the 50-character limit.
  4. Build a page that auto-submits the form with a short script tag as the list name.
  5. Get the victim to load the page so the script is stored and runs in their session.
  6. The script reads document.cookie and sends it to the attacker.

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.

Self-XSS is a script that only runs in your own browser, so on its own it is harmless to others. CSRF is when a malicious page makes your logged-in browser send a request you did not intend, here saving the script into your account. Since the login cookie could be read by JavaScript, the script could steal it and the attacker could 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.

More by CANITEY

View all

3 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.