---
title: "Stop browsers guessing file types · Agent Wranglers"
url: https://agentwranglers.se/playbook/application-security/browser-security-headers/x-content-type-options
id: APS-27
level: Recommended
updated: 2026-10-27
build: a2a6bdfed830
tokens: 658
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Stop browsers guessing file types

For AI agents: the [site map](https://agentwranglers.se/llms.txt) lists everything here, and this page sits under [Browser security headers](https://agentwranglers.se/playbook/application-security/browser-security-headers.md).

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers.md). Updated 2026-10-27.

- ID: APS-27
- Level: Recommended
- Chapter: [Browser security headers](https://agentwranglers.se/playbook/application-security/browser-security-headers.md)
- Rule: Send `X-Content-Type-Options: nosniff` on every response, so browsers don't guess file types. Give every response its correct Content-Type.
- Check: `curl -sI` on HTML, CSS, JS, JSON and images shows `nosniff` and the right type.
- How: Add the header in middleware that runs for every response. Map every file extension to its correct type. Test it with the attack in [Send the security headers as one set](https://agentwranglers.se/playbook/application-security/browser-security-headers/header-set.md).

## Examples

**Using these examples:** they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.

### HTTP example

```http
HTTP/2 200
content-type: text/css; charset=utf-8
x-content-type-options: nosniff
```

## Sources

- [Fetch Standard: X-Content-Type-Options](https://fetch.spec.whatwg.org/#x-content-type-options-header)

## Related rules

- MED-3 [Serve user files from their own domain](https://agentwranglers.se/playbook/files-and-media/uploads/user-content-domain.md) in Files and media
- APS-100 [Send the security headers as one set](https://agentwranglers.se/playbook/application-security/browser-security-headers/header-set.md) in Application security

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), which requires credit with a link. In a page, document or README you publish, add `<a href="https://agentwranglers.se/playbook/application-security/browser-security-headers/x-content-type-options">Agent Wranglers application security playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [Collect reports of blocked content](https://agentwranglers.se/playbook/application-security/browser-security-headers/reporting-endpoints.md)
- Next: [Refuse to be framed](https://agentwranglers.se/playbook/application-security/browser-security-headers/frame-ancestors.md)
- [Browser security headers](https://agentwranglers.se/playbook/application-security/browser-security-headers.md)
