Skip to content
XSS Write-up Intermediate

Image Upload Bypass Leading to Stored XSS

The image upload endpoint accepted a file whose name contained an HTML extension followed by a null-byte sequence and a .png suffix, and whose body began with a GIF signature followed by HTML. The uploaded file was served as an HTML page, allowing stored cross-site scripting, though a Content Security Policy initially blocked script execution until the author loaded AngularJS from an allowed CDN.

medium.com

Published on medium.com

My name is Ignacio Jose Riva, and I am a full-time Bug Bounty Hunter actively working in platforms like Bugcrowd, Intigriti, Hackerone, etc hunting for all kinds of vulnerabilities.

Cyx, 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 upload validation trusted the filename extension and a leading file signature rather than verifying the whole file and serving it with a safe content type.

Impact

An attacker could store a script that runs in the context of the site when a victim opens the uploaded file, though the CSP required loading an allowed library to execute code.

What the attacker needed

Ability to upload a profile image; victim opens the uploaded file URL

How it was found

  1. Send a POST request to the image upload endpoint with a filename containing an HTML extension, a null-byte sequence, and a .png suffix.
  2. Set the Content-Type to text/html and begin the request body with a GIF89a signature followed by HTML.
  3. Access the uploaded file directly at its /files/images/ path to see it rendered as HTML.
  4. Observe that the Content Security Policy blocks inline script execution.
  5. Load AngularJS from the allowed CDN and use an Angular expression to execute JavaScript.

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 let people upload profile pictures. The check on the file was fooled by giving the file a name that looked like an image but also ended in .html, and by starting the file with image bytes before the HTML. When someone opened the uploaded file, the browser treated it as a web page and ran the attacker's script, which is called stored cross-site scripting because the malicious page is saved on the server.

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.