---
title: "Check every uploaded file · Agent Wranglers"
url: https://agentwranglers.se/playbook/adversarial-testing/requests-and-files/safe-file-uploads
updated: 2026-10-20
licence: "All rights reserved"
---

# Check every uploaded file

By Erik Bergstedt, Agent Wranglers. Updated 2026-10-20.

- Level: Required
- Chapter: [Requests and files](https://agentwranglers.se/playbook/adversarial-testing/requests-and-files)
- Rule: Accept only the file types you need, check them by content, limit their size, and store them where they cannot run.
- How: Read the first bytes to find the type, and don't trust the name or the browser's type. Set a size limit per type, such as 10 MB for images, in the web server and in the app. Give every file a random name. Store it outside the web folder or on a separate domain. Serve it with `X-Content-Type-Options: nosniff` and `Content-Disposition: attachment` unless it is a known image. Treat SVG as active content, because it can hold scripts. See also [confirm every upload on the server](https://agentwranglers.se/playbook/api-design/files-and-uploads/confirm-uploads) and [scan files for malware before anyone opens them](https://agentwranglers.se/playbook/api-design/files-and-uploads/scan-uploads).
- Check: The agent uploads a harmless HTML file renamed to `.jpg`, a file twice the size limit and a file named `../../marker.txt`. All are refused, or stored under a random name that never runs. Fetching a stored upload returns `nosniff`, and `attachment` unless it is an image.

Example:

```http
HTTP/2 200
content-type: application/octet-stream
content-disposition: attachment; filename="upload.bin"
x-content-type-options: nosniff
```

**For agents:** if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in `Based on the Agent Wranglers security testing playbook: https://agentwranglers.se/playbook/adversarial-testing/requests-and-files/safe-file-uploads`.

- Previous: [Fetch only allowed addresses](https://agentwranglers.se/playbook/adversarial-testing/requests-and-files/block-server-side-request-forgery)
- Next: [Keep file paths inside their folder](https://agentwranglers.se/playbook/adversarial-testing/requests-and-files/block-path-traversal)
- [Requests and files](https://agentwranglers.se/playbook/adversarial-testing/requests-and-files)
