{"data":{"slug":"github-thedaviddias-front-end-checklist-skills-x-content-type-92ea169a4c3d","title":"Prevent MIME Type Sniffing with X-Content-Type-Options","summary":"Set the X-Content-Type-Options: nosniff header on all HTTP responses to prevent browsers from MIME-sniffing, reducing the risk of executing malicious content disguised as other file types.","url":"https:\/\/skillshunter.net\/skills\/github-thedaviddias-front-end-checklist-skills-x-content-type-92ea169a4c3d","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-thedaviddias-front-end-checklist-skills-x-content-type-92ea169a4c3d","markdown_url":"https:\/\/skillshunter.net\/skills\/github-thedaviddias-front-end-checklist-skills-x-content-type-92ea169a4c3d.md","download_url":"https:\/\/skillshunter.net\/skills\/github-thedaviddias-front-end-checklist-skills-x-content-type-92ea169a4c3d\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_note":"Ensure that the X-Content-Type-Options header is set to 'nosniff' on all responses, including HTML pages, scripts, stylesheets, and API responses. Verify the header is present using tools like curl -I https:\/\/example.com.","instructions":"---\nname: x-content-type\ndescription: \"Use when auditing HTTP response headers on any web server or CDN for security hardening.\"\nmetadata:\n  category: security\n  priority: high\n  difficulty: beginner\n  estimatedTime: \"5\"\n  source: frontendchecklist.io\n  url: https:\/\/frontendchecklist.io\/rules\/security\/x-content-type\n---\n\n# Set X-Content-Type-Options: nosniff\n\nBrowsers that MIME-sniff can be tricked into executing malicious JavaScript uploaded as an image \u2014 even if the server sends `Content-Type: image\/png`. `nosniff` forces the browser to honor the declared type.\n\n## Quick Reference\n\n- Set `X-Content-Type-Options: nosniff` on all responses \u2014 the only valid value is `nosniff`\n- Without this header, browsers may execute a JavaScript file disguised as an image if the server serves it with the wrong MIME type\n- This header is required by OWASP's security hardening checklist and the Fetch specification\n- Pair with correct `Content-Type` headers on all responses for defense in depth\n- Takes 5 minutes to configure and has no compatibility issues\n\n## Check\n\nCheck whether the server sends an X-Content-Type-Options: nosniff header on responses. Verify the header is present on HTML pages, scripts, stylesheets, and API responses.\n\n## Fix\n\nAdd X-Content-Type-Options: nosniff to all HTTP responses. Configure it at the web server level (Nginx, Apache) or in your application framework, and verify with curl -I https:\/\/example.com.\n\n## Explain\n\nExplain what MIME type sniffing is, how it can be exploited to execute malicious files, and how X-Content-Type-Options: nosniff prevents this attack.\n\n## Code Review\n\nReview server config, headers, forms, and integration points related to Set X-Content-Type-Options: nosniff. Flag exact responses, cookies, or browser behaviors that violate the rule, and verify them against the effective production-like response.\n\n---\n\nFor full implementation details, code examples, and framework-specific guidance,\nsee `references\/rule.md`.\n\nRule page: https:\/\/frontendchecklist.io\/rules\/security\/x-content-type\n","use_cases":["Auditing HTTP response headers for security hardening on web servers or CDNs.","Preventing browsers from executing malicious JavaScript disguised as images or other file types.","Complying with OWASP security hardening guidelines and the Fetch specification."],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/thedaviddias\/Front-End-Checklist\/blob\/e8d14d049010e2ce25afcd5e8609dfcbbe63e47e\/skills\/x-content-type\/SKILL.md","source_commit":"e8d14d049010e2ce25afcd5e8609dfcbbe63e47e","license":null,"version":null,"listing_approved_at":"2026-11-24","created_at":"2026-11-23T06:16:41.000000Z","updated_at":"2026-11-24T07:12:47.000000Z","seo_title":"Prevent MIME Sniffing with X-Content-Type-Options","seo_description":"Secure your web application by setting X-Content-Type-Options: nosniff to prevent MIME type sniffing and potential XSS attacks.","seo_keywords":["X-Content-Type-Options security","Prevent MIME sniffing","Secure HTTP headers","OWASP security hardening","MIME type sniffing prevention"]}}