Skip to content
XSS Write-up Intermediate

From a Simple Image Upload to Account Takeover: Stored XSS via Fi

A profile image upload accepted a JPG whose EXIF metadata contained JavaScript, and the file was served as HTML so the script ran. By sharing the same file through the chat feature, the script executed in another user's browser and sent their cookies to an attacker-controlled server.

Kanishkakhandelwal Follow

Published on cyber-tech-by-kk.medium.com

Hi, let me introduce myself — I’m Kanishka Khandelwal. I’m currently working as an Associate Security Engineer, and apart from my day job, I spend most of my time doing bug bounty.

Kanishkakhandelwal, on cyber-tech-by-kk.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 upload endpoint trusted the client-supplied content type and served the stored file as HTML without sanitising metadata or encoding output.

Impact

The stored script could run in another user's browser and exfiltrate their cookies, which could lead to session hijacking and account takeover depending on cookie protections such as HttpOnly and SameSite.

What the attacker needed

Ability to upload a profile image; chat feature to share files; victim opens the shared attachment

The fix

The application should validate the real file type, serve uploads as safe media rather than HTML, sanitise metadata and encode output when rendering files; the author says the issue was silently fixed.

How it was found

  1. Create a JPG with JavaScript embedded in its EXIF metadata.
  2. Intercept the profile image upload and change the content type from image/jpeg to text/html.
  3. Forward the request; the application accepts and stores the file.
  4. Open the chat with another user and upload the same file as an attachment, again changing the content type to text/html.
  5. The victim opens the attachment and the script runs in their browser.
  6. The script sends the victim's cookies to an attacker-controlled endpoint.

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 pictures. The uploader did not check what the file really was, and the site showed the file back as a web page instead of a picture. Because of that, hidden code inside the picture's extra information ran in the browser of anyone who opened it, and that code could steal their login session.

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 Kanishkakhandelwal

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.