Skip to content
XSS Write-up Intermediate

Bypassing SameSite Protection: Chaining XSS and CSRF for Admin AT

An unrestricted file upload allowed an attacker to host an HTML file that executed JavaScript in the application's origin, and CSRF tokens were not tied to user sessions, so the attacker could reuse their own token in a victim's session. By chaining these, an attacker could make authenticated requests as the victim and change the admin's password, leading to account takeover.

he4am Follow

Published on he4am.medium.com

While testing an open-source project (RomM), I found a few bugs including IDORs, TOCTOU, XSS and CSRF. One of them was about chaining an arbitrary file upload vulnerability (leading to XSS) with a CSRF token reuse (tokens not tied to user sessions) vulnerability, bypassing SameSite=strict protection to achieve admin…

He4am, on he4am.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 allowed unrestricted file uploads served with an HTML content type, and CSRF tokens were validated only by matching a cookie and header value without binding them to the user session.

Impact

An attacker could change the password of any user, including the default admin (ID 1), leading to account takeover; the SameSite=strict cookie and CORS preflight would normally block CSRF, but the same-origin XSS bypasses them.

What the attacker needed

Attacker has an account; victim visits attacker's uploaded file link; victim is logged in

The fix

The vulnerabilities were fixed according to the CVE and GitHub advisory referenced in the text.

How it was found

  1. Upload a malicious HTML file as the avatar.
  2. Victim visits the uploaded file link.
  3. JavaScript runs in RomM’s context (Same-Origin).
  4. Makes authenticated requests using their session + Attacker’s CSRF token.
  5. Bypasses all protections in-place because requests originate from the same origin.

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 application let users upload any file type, including HTML pages that run JavaScript when opened. It also had a protection against cross-site request forgery (CSRF) where the secret token was not linked to a specific user session, so one user's token worked for another user. By combining these, an attacker could trick an admin into opening a malicious file that then used the admin's session to change their 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 he4am

View all

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