Remove Content Type Sniffing for Worker Scripts
- Category
- JavaScript
- Type
- New or changed feature
- Status
- No active development (Chrome No active development)
- Intent stage
- Removed
WPT details: We have Worker tests in WPT that currently exercise both valid and invalid MIME types. When landing this change, we'll update their expectations accordingly.
Summary
Worker scripts will be rejected unless they're delivered with a javascript MIME type (https://mimesniff.spec.whatwg.org/#javascript-mime-type).
Motivation
Web browsers will execute JavaScript, use CSS, etc., even if the Content-Type: header indicates a non-matching MIME type. For example, including a text/html resource via a <script src=.... > tag would succeed. This has been a security concern for quite a while, and there's a long-standing desire to eliminate or at least reduce this. Tightening MIME type restrictions makes it less likely that a server's resources are inadvertently executed as script, and allows us to tighten CORB protections outside the renderer process.
Standards & signals
- Specification: https://github.com/whatwg/html/issues/3255
- Firefox: Positive — Firefox shipped this to their beta channel in 2019Q3, and have seen only minimal breakage.
- Safari: No signal
- Web developers: No signals
- Tracking bug: https://bugs.chromium.org/p/chromium/issues/detail?id=794548
Ecosystem
- Web Platform Tests: https://wpt.fyi/results/?q=remove-content-type-sniffing-for-worker-scripts
- Chrome Platform Showcase: https://chrome-platform-showcase.paulkinlan-ea.deno.net/features
- GenDN reference: https://gendn.paulkinlan-ea.deno.net/features
- chrome.dev demos search: https://www.google.com/search?q=site%3Achrome.dev+Remove%20Content%20Type%20Sniffing%20for%20Worker%20Scripts
- MDN Web Docs: https://developer.mozilla.org/en-US/search?q=Remove%20Content%20Type%20Sniffing%20for%20Worker%20Scripts
- Baseline status: https://webstatus.dev/?q=Remove%20Content%20Type%20Sniffing%20for%20Worker%20Scripts
Docs: https://mimesniff.spec.whatwg.org/#javascript-mime-type https://groups.google.com/a/chromium.org/d/msg/blink-dev/35t5cJQ3J_Q/FH45dl0vAwAJ