Skip to content
XSS Write-up Intermediate

XSS : Bypass default-src ‘self’

A member username was rendered as HTML on an admin page without sanitisation, but a CSP with default-src 'self' blocked inline script. By chaining an unrestricted file upload, the author hosted a script on the same origin and loaded it through the username, then used a redirect to send the admin's cookie to an attacker server.

medium.com

Published on medium.com

Content Security Policy (CSP) adalah fitur keamanan di web yang membatasi sumber konten yang boleh dimuat oleh browser. Ini membantu mencegah serangan XSS dan menjaga aplikasi web tetap aman.

Kaz Research, 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 username value was rendered as HTML without sanitisation, and the upload feature accepted script files served from the same origin, so the 'self' CSP allowed the attacker's own uploaded script.

Impact

An attacker could run script in an admin's browser and steal the admin's cookie, which could then be used for privilege escalation; a fetch to an external domain was blocked by the CSP, so a redirect was used instead.

What the attacker needed

Member account; admin views the avatars page; upload accepts script files

How it was found

  1. Change a member username to an HTML payload and confirm it renders on the admin page but the script does not run.
  2. Check the browser console and response headers to find the CSP.
  3. Upload a JavaScript file and confirm it is publicly reachable under the uploads path.
  4. Set the username to a script tag pointing at the uploaded file and load the admin page to see the alert.
  5. Replace the script with one that redirects the page to an attacker server carrying the cookie, and read the cookie from that server.

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 website can tell the browser which places it may load scripts and images from; this rule set is called a Content Security Policy. Here the rule only allowed files from the site's own domain, so a script typed directly into a page was refused. The author instead uploaded a script file to the same site and pointed the page at it, which the rule allowed, and the script then ran in the admin's browser.

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.