XSS due to Content-Disposition being ignored in multipart/x-mixed-replace response
Firefox ignores the Content-Disposition: attachment header when the response Content-Type is multipart/x-mixed-replace, so a user-uploaded file served with that MIME type can execute JavaScript instead of being downloaded. An attacker could achieve XSS on sites that host user files with user-controlled MIME types.
Originally disclosed on Mozilla
- Fixed in 40 days
- Paid in 47 days
- Disclosed after 40 days
Created attachment 9420466
fx_x-mixed-replace_content-disposition.php
In the multipart/x-mixed-replace response, `Content-Disposition: attachment` sent in the original response header is not respected and does not force a download. e.g.:
'''
HTTP/1.1 200 OK
Date: Fri, 23 Aug 2024 00:14:12 GMT
Server: Apache
Content-Disposition: attachment <-------------- This is ignored
Content-Length: 92
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: multipart/x-mixed-replace;boundary=BOUNDARY
foo
--BOUNDARY
Content-Type: text/html
<script>alert(document.domain)</script>
--BOUNDARY--
'''
This is not good because it is common for web apps to host user-uploaded files with user-specified MIME type and `Content-Disposition: attachment` header. Normally, the download is forced by the `Content-Disposition: attachment` header, so XSS does not occur no matter what `Content-Type` response header is used. However, in Firefox, since the `Content-Disposition` header is not respected when `Content-Type: multipart/x-mixed-replace` is used, XSS could occur. I have actually confirmed that multiple apps' file hosting feature is affected by this issue.
Steps to reproduce:
1. Open https://vulnerabledoma.in/fx_x-mixed-replace_content-disposition.php with Firefox.
2. Confirm that JavaScript is exeucted even though the original response header includes `Content-Disposition: attachment`.
I attached the PHP script used in PoC above.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely, Firefox does not enforce Content-Disposition: attachment for responses with Content-Type multipart/x-mixed-replace, allowing embedded HTML parts to be rendered and script to execute.
Impact
On sites that host user-uploaded files with user-specified MIME types, an attacker could execute JavaScript in the site's origin, leading to XSS; the report confirms multiple apps' file hosting features are affected.
What the attacker needed
Firefox browser; Site hosts user files with user-controlled MIME type
How it was found
- Open the proof-of-concept URL in Firefox.
- Observe that JavaScript executes even though the response includes Content-Disposition: attachment.
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 report has not been written yet. The Original tab links to the source.
When a website lets people upload files, it usually tells the browser to download the file instead of showing it, using a header called Content-Disposition: attachment. This report found that Firefox ignores that instruction if the file is labelled as a special streaming format called multipart/x-mixed-replace, so the file's HTML and JavaScript run in the browser. That means an uploaded file could run code in the context of the website.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.