Duplicate application/xml and text/plain Content-Type headers with nosniff pick second mimetype (text/plain) on initial load but the first (XML) when cached and retrieved via 304 (even if 304 response contains only 1 mimetype)
Firefox executed JavaScript embedded in an XML document even when the server sent it as text/plain with nosniff, so a site that safely displays user-uploaded XML as plain text could be attacked with script execution. Chrome and Safari showed the same file as plain text without running anything.
Originally disclosed on Mozilla
- Fixed in 2 months
- Paid in 3 months
- Disclosed after 2 months
Created attachment 9530579
WhatsApp_Image_2025-11-30_at_16.40.02.jpeg
Summary:
Firefox executes JavaScript in XML files even when served with Content-Type: text/plain. This allows XSS attacks on websites that rely on this header for safely displaying user-uploaded XML content. While Chrome and Safari handle this correctly, Firefox (both Desktop and Android versions) remains vulnerable.
Steps To Reproduce:
Create test file: poc.xml with the following content:
Code
•
184 Bytes
'''html
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns:html="http://www.w3.org/1999/xhtml">
<html:script>
alert('XSS Works! ' + navigator.userAgent);
</html:script>
</html>
'''
Serve with proper headers using Python HTTP server:
Code
•
418 Bytes
'''python
from http.server import HTTPServer, SimpleHTTPRequestHandler
class TextPlainHandler(SimpleHTTPRequestHandler):
def end_headers(self):
if self.path.endswith('.xml'):
self.send_header('Content-Type', 'text/plain')
self.send_header('X-Content-Type-Options', 'nosniff')
SimpleHTTPRequestHandler.end_headers(self)
HTTPServer(('0.0.0.0', 8000), TextPlainHandler).serve_forever()
'''
Open http://localhost:8000/poc.xml in different browsers:
Expected Behavior (Chrome/Safari): Shows plain text, no alert
Actual Behavior (Firefox): Alert popup appears, JavaScript executes
Supporting Material/References:
Affected Versions:
Firefox 145.0 (Desktop - Windows 11)
Firefox 145.0 (Android 15)
Desktop User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:145.0) Gecko/20100101 Firefox/145.0
Android User Agent: Mozilla/5.0 (Android 15; Mobile; rv:145.0) Gecko/145.0 Firefox/145.0
Server Response Headers (verified):
'''
HTTP/1.0 200 OK
Content-Type: text/plain
X-Content-Type-Options: nosniff
'''
Browser Comparison:
| Browser | Platform | Behavior |
|---------|----------|----------|
| Firefox | Desktop (Windows) | Executes script (VULNERABLE) |
| Firefox | Android 15 | Executes script (VULNERABLE) |
| Chrome | Desktop | Plain text only (CORRECT) |
| Chrome | Android | Plain text only (CORRECT) |
| Safari | iOS | Plain text only (CORRECT) |
Similar vulnerabilities have been reported and fixed in other browsers:
WebKit Bug (fixed in iOS 16.6/17)
Chromium Issue https://issues.chromium.org/issues/40063810 (rewarded $3,000 by Chrome VRP)
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
Impact
A site that relies on text/plain to safely show user-uploaded XML could have attacker script run in a visitor's browser, but only in Firefox; Chrome and Safari were not affected.
What the attacker needed
Victim uses Firefox; site serves user XML as text/plain; victim opens the uploaded file
How it was found
- Create an XML file containing an XHTML script element that shows an alert.
- Serve it from a local Python HTTP server that sends Content-Type text/plain and X-Content-Type-Options nosniff for .xml files.
- Open the file in Firefox on desktop and Android and observe the alert.
- Open the same file in Chrome and Safari and observe plain text with no alert.
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 server sends a file, it labels the file's type with a header, for example text/plain meaning 'just text'. A browser should trust that label and never run code from a file marked as plain text. Here Firefox ignored the label for XML files and ran a script hidden inside the XML, which means an attacker could run code in a victim's browser on a site that hosts user files.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.