{"playbook":"Files and media","url":"https://agentwranglers.se/playbook/files-and-media","updated":"2026-10-22","license":"https://creativecommons.org/licenses/by/4.0/","credit":"Required by the licence: credit Agent Wranglers with a link to the rule or playbook you used.","ids":"Each rule has an id, such as PAY-14, that never changes. Open a rule by its id at /r/PAY-14. Its revision changes whenever its content changes.","how":"Each rule's How and Measured text is on its own page: add .md to its url.","rules":[{"id":"MED-1","revision":"80fb0461a1b4","updated":"2026-10-22","name":"Define each kind of upload once","level":"Recommended","rule":"Keep one list of upload kinds, each with its allowed types, its size limit and its pixel or length limit. The browser field, the signed upload and the server check all read that list.","check":"For each kind, a test tries a file 1 byte over its size limit and a file of a type the kind does not allow. The browser field, the signed address and the server check each refuse both. A code search finds no upload size limit outside the list.","check_type":"static","url":"https://agentwranglers.se/playbook/files-and-media/uploads/upload-kinds","related":["/playbook/api-design/requests-and-responses/request-body-limit","/playbook/accounts/bank-and-government-id/identity-documents","/playbook/app-ui/forms/file-upload-field","/playbook/files-and-media/uploads/presigned-uploads","/playbook/files-and-media/uploads/confirm-uploads","/playbook/files-and-media/images/phone-photo-formats","/playbook/files-and-media/video-and-audio/media-limits"],"sources":[]},{"id":"MED-41","revision":"31a132e18086","updated":"2026-10-22","name":"Upload straight to storage with a signed address","level":"Recommended","rule":"Let clients send file bytes straight to object storage through a pre-signed address that your API issues, limited in size, type and time.","check":"Ask for an upload address for a 10 MB limit. Upload a file 1 byte over the limit and storage refuses it. Wait past the expiry and upload again, and storage answers 403. The key in the address never contains the client's file name.","check_type":"manual","url":"https://agentwranglers.se/playbook/files-and-media/uploads/presigned-uploads","related":["/playbook/scaling/stateless-app-servers/stateless-processes","/playbook/ecommerce/orders-and-fulfilment/digital-downloads","/playbook/files-and-media/uploads/upload-kinds","/playbook/files-and-media/uploads/confirm-uploads","/playbook/application-security/requests-files-and-caches/safe-file-uploads","/playbook/files-and-media/quotas-and-cost/storage-quotas"],"sources":["https://docs.aws.amazon.com/AmazonS3/latest/userguide/PresignedUrlUploadObject.html"]},{"id":"MED-42","revision":"5d882adb11d3","updated":"2026-10-22","name":"Make large uploads resumable","level":"Recommended","rule":"Let any upload over 100 MB, or any upload from a phone, continue from the last received byte after a dropped connection.","check":"Start a 500 MB upload, cut the network at 50 percent and reconnect. The upload finishes without sending the first half again, and the stored file's SHA-256 matches the original.","check_type":"manual","url":"https://agentwranglers.se/playbook/files-and-media/uploads/resumable-uploads","related":["/playbook/files-and-media/uploads/confirm-uploads","/playbook/files-and-media/serving-files/range-downloads"],"sources":["https://datatracker.ietf.org/doc/draft-ietf-httpbis-resumable-upload/"]},{"id":"MED-43","revision":"6ed33a401b9d","updated":"2026-10-22","name":"Confirm every upload on the server","level":"Recommended","rule":"Have the client send a SHA-256 checksum with each upload. Keep the new file `pending` until the server has checked its size, type and checksum from the stored bytes. Never trust what the client reports.","check":"Upload a text file named `photo.jpg` with a content type of `image/jpeg`. The file never leaves `pending`, and the API answers with a problem response naming the type. Upload a file with the checksum of other bytes, and storage or the server refuses it. With the right checksum, the files table holds the same SHA-256.","check_type":"http","url":"https://agentwranglers.se/playbook/files-and-media/uploads/confirm-uploads","related":["/playbook/app-ui/forms/file-upload-field","/playbook/files-and-media/uploads/upload-kinds","/playbook/files-and-media/uploads/presigned-uploads","/playbook/files-and-media/uploads/resumable-uploads","/playbook/files-and-media/storage-and-backups/restore-files-with-records","/playbook/application-security/requests-files-and-caches/safe-file-uploads","/playbook/files-and-media/images/phone-photo-formats"],"sources":["https://cheatsheetseries.owasp.org/cheatsheets/File_Upload_Cheat_Sheet.html","https://www.rfc-editor.org/rfc/rfc9530"]},{"id":"MED-44","revision":"a85e8d67721d","updated":"2026-10-22","name":"Scan files for malware before anyone opens them","level":"Required","risk":"takeover","rule":"Scan every file that other people or systems will open, and serve it only after the scan says clean.","check":"Upload the EICAR test file. It stays in quarantine, its status reads `infected`, and a download request answers 403 or 404.","check_type":"http","url":"https://agentwranglers.se/playbook/files-and-media/uploads/scan-uploads","related":["/playbook/stack/databases-and-storage/clamav","/playbook/application-security/requests-files-and-caches/safe-file-uploads","/playbook/application-security/requests-files-and-caches/safe-archive-extraction"],"sources":["https://cheatsheetseries.owasp.org/cheatsheets/File_Upload_Cheat_Sheet.html"]},{"id":"MED-3","revision":"23ed34a3291c","updated":"2026-10-22","name":"Serve user files from their own domain","level":"Required","risk":"takeover","applies":["user-content"],"rule":"Serve every file users upload from a separate registrable domain, such as `example-usercontent.com`, never from the app's own domain. Send `Content-Security-Policy: sandbox` with each of those files.","check":"Upload an SVG holding `<script>alert(document.domain)</script>` to the test copy. It is served from the user content domain with `Content-Security-Policy: sandbox`, and opening it runs no script. A request for any upload on the app's own domain answers 404.","check_type":"http","url":"https://agentwranglers.se/playbook/files-and-media/uploads/user-content-domain","related":["/playbook/files-and-media/serving-files/signed-downloads","/playbook/application-security/browser-security-headers/x-content-type-options","/playbook/application-security/requests-files-and-caches/safe-file-uploads","/playbook/files-and-media/uploads/svg-and-html-uploads"],"sources":["https://www.w3.org/TR/CSP3/#directive-sandbox","https://cheatsheetseries.owasp.org/cheatsheets/File_Upload_Cheat_Sheet.html"]},{"id":"MED-39","revision":"7e5a29d2baa6","updated":"2026-10-22","name":"Turn SVG uploads into plain images and refuse HTML","level":"Recommended","rule":"Leave HTML, XHTML, XML and SVG off every upload kind that other people view. Where people must upload a vector logo, convert the SVG to PNG on the server and serve only the PNG.","check":"Upload `logo.svg` holding `<script>` and `onload=` to the test copy. The stored file is a PNG, or an SVG with no script, handler or external reference. Upload `page.html` renamed to `photo.jpg`, and it is refused with 415.","check_type":"command","url":"https://agentwranglers.se/playbook/files-and-media/uploads/svg-and-html-uploads","related":["/playbook/files-and-media/video-and-audio/media-tool-sandbox","/playbook/files-and-media/uploads/user-content-domain"],"sources":["https://cheatsheetseries.owasp.org/cheatsheets/File_Upload_Cheat_Sheet.html","https://cwe.mitre.org/data/definitions/79.html"]},{"id":"MED-40","revision":"11eaa76ddcea","updated":"2026-10-22","name":"Store files under keys you make and clean the names you show","level":"Recommended","rule":"Never use an uploaded file name in a storage key or a file path. Store each file under a random key, and keep the original name only as a cleaned label of at most 255 bytes.","check":"Upload files named `../../a.txt`, `a\\nb.pdf` and a 300-byte name in Swedish. Each is stored under a random key, and no file appears outside the upload prefix. The download answers with a `Content-Disposition` header holding a `filename*` with no line break and at most 255 bytes.","check_type":"http","url":"https://agentwranglers.se/playbook/files-and-media/uploads/safe-file-names","related":["/playbook/application-security/requests-files-and-caches/block-path-traversal"],"sources":["https://www.rfc-editor.org/rfc/rfc6266","https://www.rfc-editor.org/rfc/rfc8187","https://cwe.mitre.org/data/definitions/22.html"]},{"id":"MED-4","revision":"ae713c2fc4ec","updated":"2026-10-22","name":"Keep deleted files restorable for 30 days","level":"Recommended","rule":"When a person deletes a file, hide it at once and keep it restorable for 30 days. Then delete the object, every old version and every derived file.","check":"Delete a test file, and within 1 minute it leaves every list and its share link answers 404. Restore it on day 29, and it opens. The erase job run with the clock at day 31 leaves no object, old version or thumbnail under its key.","check_type":"command","url":"https://agentwranglers.se/playbook/files-and-media/storage-and-backups/deleted-files-bin","related":["/playbook/data/multi-tenancy/tenant-offboarding","/playbook/app-ui/feedback-and-dialogs/confirm-or-undo","/playbook/files-and-media/storage-and-backups/delete-files-with-owner","/playbook/website/privacy/data-requests","/playbook/operations/disaster-recovery/backup-retention","/playbook/compliance/records-and-data-map/retention-schedule"],"sources":[]},{"id":"MED-5","revision":"cb3c66dc2d55","updated":"2026-10-22","name":"Back up user files outside their bucket","level":"Required","risk":"data","rule":"Copy every original file to storage in a second account or provider that the app's keys cannot delete from. Old versions in the same bucket do not count as a backup.","check":"Upload a test file, and within 1 hour a copy with the same SHA-256 sits in the backup account. A delete request on that copy, sent with the app's own keys, is refused. Delete the file in the app, and the backup copy stays until its lock ends.","check_type":"http","url":"https://agentwranglers.se/playbook/files-and-media/storage-and-backups/file-backups","related":["/playbook/operations/disaster-recovery/recovery-targets","/playbook/operations/disaster-recovery/backup-retention","/playbook/operations/disaster-recovery/off-site-backups","/playbook/data/database-security/encrypted-backups"],"sources":["https://csrc.nist.gov/pubs/sp/800/209/final","https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lock.html","https://docs.aws.amazon.com/AmazonS3/latest/userguide/replication.html"]},{"id":"MED-6","revision":"34efd8652d82","updated":"2026-10-22","name":"Restore files and their records together","level":"Recommended","rule":"In every restore drill, bring back the database and the files to the same moment. Then count file records without an object, objects without a record and checksums that differ, and get 0 for each.","check":"The drill report lists file records without an object, objects without a record and checksum mismatches. Each count is 0, and the report names the restore point used for both.","check_type":"manual","url":"https://agentwranglers.se/playbook/files-and-media/storage-and-backups/restore-files-with-records","related":["/playbook/files-and-media/uploads/confirm-uploads","/playbook/operations/disaster-recovery/restore-drills","/playbook/operations/disaster-recovery/restore-runbook","/playbook/files-and-media/storage-and-backups/delete-files-with-owner"],"sources":[]},{"id":"MED-47","revision":"2677ce780504","updated":"2026-10-22","name":"Lay out storage by owner and let rules clean it","level":"Recommended","rule":"Name every stored object by stage, owner and a random ID, with the stage as the first prefix. Let storage lifecycle rules delete what nobody needs.","check":"Read the bucket's lifecycle settings with the provider's tool. It has a rule for quarantine, one for unfinished multipart uploads and, with versioning on, one for old versions. A listing finds no unfinished multipart upload older than 2 days.","check_type":"command","url":"https://agentwranglers.se/playbook/files-and-media/storage-and-backups/storage-lifecycle","related":["/playbook/compliance/records-and-data-map/retention-schedule","/playbook/files-and-media/generated-documents/document-jobs"],"sources":["https://docs.aws.amazon.com/AmazonS3/latest/userguide/intro-lifecycle-rules.html"]},{"id":"MED-48","revision":"2b100c0f78c7","updated":"2026-10-22","name":"Store the same file once per owner","level":"Optional","rule":"When users upload the same file often, store it once per owner under its SHA-256 hash and count the references.","check":"One owner uploads the same file twice, and storage holds one object with a count of 2. Deleting one record keeps the object, and deleting the second removes it. A second owner uploading the same file gets their own object.","check_type":"manual","url":"https://agentwranglers.se/playbook/files-and-media/storage-and-backups/dedupe-by-hash","related":["/playbook/files-and-media/storage-and-backups/delete-files-with-owner"],"sources":["https://csrc.nist.gov/pubs/fips/180-4/upd1/final"]},{"id":"MED-49","revision":"492cc24cfbc4","updated":"2026-10-22","name":"Delete files when their owner is deleted","level":"Required","risk":"law","applies":["eu-users"],"rule":"Record every stored object in a files table with its owner, and delete the objects in the same job that deletes the owner.","check":"Create a test owner with an upload, a thumbnail and two versions of a file. Delete the owner. A listing of the owner's prefix, including old versions, is empty. The weekly sweep reports zero objects without a row.","check_type":"manual","url":"https://agentwranglers.se/playbook/files-and-media/storage-and-backups/delete-files-with-owner","related":["/playbook/data/multi-tenancy/tenant-offboarding","/playbook/files-and-media/storage-and-backups/deleted-files-bin","/playbook/files-and-media/storage-and-backups/restore-files-with-records","/playbook/files-and-media/storage-and-backups/dedupe-by-hash","/playbook/operations/disaster-recovery/backup-retention","/playbook/compliance/records-and-data-map/retention-schedule","/playbook/website/privacy/data-requests","/playbook/files-and-media/serving-files/cdn-purge-on-delete","/playbook/files-and-media/copyright-and-takedowns/uploader-and-licence"],"sources":["https://eur-lex.europa.eu/eli/reg/2016/679/oj"]},{"id":"MED-45","revision":"bcf05db82cd5","updated":"2026-10-22","name":"Rebuild every uploaded image","level":"Recommended","rule":"Decode each uploaded image, turn it upright, convert it to sRGB and shrink it to a size limit. Save it again as a new file without metadata. Never serve the original.","check":"Upload a photo with GPS tags and a 90-degree orientation tag. A metadata reader such as ExifTool finds no GPS or EXIF tags in the served file, and it shows upright. A Display P3 test photo's known red patch matches its sRGB value within 2 units per channel. A 20,000 by 20,000 pixel PNG is refused.","check_type":"manual","url":"https://agentwranglers.se/playbook/files-and-media/images/process-images","related":["/playbook/ai-features/guardrails-and-human-review/model-file-inputs","/playbook/stack/product-services/image-processing","/playbook/website/performance/image-optimization","/playbook/files-and-media/images/fixed-image-sizes","/playbook/files-and-media/images/image-dimensions","/playbook/files-and-media/images/keep-ai-marking","/playbook/files-and-media/video-and-audio/video-posters"],"sources":["https://cheatsheetseries.owasp.org/cheatsheets/File_Upload_Cheat_Sheet.html","https://sharp.pixelplumbing.com/api-output/"]},{"id":"MED-7","revision":"8c01a3396b03","updated":"2026-10-22","name":"Make image sizes from a fixed list","level":"Recommended","rule":"Resize images only to widths and formats on a fixed list in your code. An image address that asks for any other size answers 400 and never reaches the resizer.","check":"Request an image at each width on the list, and each answers 200. Request it at 1,234 pixels wide, and the answer is 400 with no new object in storage.","check_type":"http","url":"https://agentwranglers.se/playbook/files-and-media/images/fixed-image-sizes","related":["/playbook/files-and-media/images/process-images","/playbook/website/performance/image-optimization","/playbook/files-and-media/video-and-audio/video-posters"],"sources":[]},{"id":"MED-9","revision":"278d6f4fbef3","updated":"2026-10-22","name":"Accept the photo formats phones save","level":"Recommended","rule":"Accept HEIC and HEIF photos on every upload kind that takes photos, and convert them on the server to the formats you serve.","check":"Upload a HEIC photo from a phone through the API and the browser. Both reach `ready`, and the served copy is AVIF, WebP or JPEG with the same width and height.","check_type":"manual","url":"https://agentwranglers.se/playbook/files-and-media/images/phone-photo-formats","related":["/playbook/files-and-media/uploads/upload-kinds","/playbook/files-and-media/uploads/confirm-uploads"],"sources":["https://www.iana.org/assignments/media-types/image/heic"]},{"id":"MED-10","revision":"148f22ee386c","updated":"2026-10-22","name":"Pick the image format from Accept and send Vary","level":"Recommended","rule":"When one image address can answer in several formats, choose from the request's `Accept` header and send `Vary: Accept`. Otherwise give each format its own address.","check":"Request one image address with `Accept: image/avif,image/webp,*/*` and again with `Accept: image/jpeg`. The answers carry `image/avif` and `image/jpeg`, and both carry `Vary: Accept`.","check_type":"http","url":"https://agentwranglers.se/playbook/files-and-media/images/format-negotiation","related":["/playbook/website/performance/image-optimization","/playbook/files-and-media/serving-files/versioned-file-addresses"],"sources":["https://www.rfc-editor.org/rfc/rfc9110#section-12.5.5"]},{"id":"MED-11","revision":"13eeb793805a","updated":"2026-10-22","name":"Store each image's width and height","level":"Recommended","rule":"Save the width and height of every processed image in its file record, and write them into every `<img>` the app renders for it.","check":"A test uploads a portrait photo with an orientation tag. Its file record shows the upright width and height, and every rendered `<img>` for it has matching `width` and `height` attributes.","check_type":"manual","url":"https://agentwranglers.se/playbook/files-and-media/images/image-dimensions","related":["/playbook/website/performance/image-optimization","/playbook/files-and-media/images/process-images"],"sources":["https://web.dev/articles/optimize-cls"]},{"id":"MED-12","revision":"fd61608d97ec","updated":"2026-10-22","name":"Ask the uploader to describe each image","level":"Recommended","rule":"When people upload an image others will see, ask them for a short description and use it as the alt text. Store an empty description only when they mark the image as decorative.","check":"Upload an image through the form, give it a description, and every page that shows it renders that text as `alt`. An image saved without a description and not marked decorative shows a reminder to the uploader.","check_type":"manual","url":"https://agentwranglers.se/playbook/files-and-media/images/uploader-alt-text","related":["/playbook/accessibility/media-documents-and-email/authoring-checks","/playbook/seo/search-result-appearance/alt-text-for-search"],"sources":["https://www.w3.org/WAI/WCAG22/Understanding/non-text-content.html"]},{"id":"MED-37","revision":"73b5523ac7ec","updated":"2026-10-22","name":"Keep the AI marking when you resize generated media","level":"Required","risk":"law","applies":["ai-features","eu-users"],"rule":"When your pipeline resizes or transcodes generated images, audio or video, every served copy keeps a signed content credential and the watermark. Test the files as served, not as stored.","check":"Make one generated image and one generated video on staging, then fetch every size and rendition the site serves. A C2PA verifier, such as c2patool, finds a valid manifest with an AI statement on each. The watermark detector finds the mark on each.","check_type":"manual","url":"https://agentwranglers.se/playbook/files-and-media/images/keep-ai-marking","related":["/playbook/files-and-media/images/process-images","/playbook/compliance/ai-act/ai-content-marking"],"sources":["https://eur-lex.europa.eu/eli/reg/2024/1689/oj","https://spec.c2pa.org/specifications/specifications/2.4/specs/C2PA_Specification.html"]},{"id":"MED-13","revision":"368848c977c2","updated":"2026-10-22","name":"Transcode every video into an adaptive stream","level":"Recommended","rule":"Transcode every uploaded video in a background job into an HLS or DASH stream with three or more renditions, and play that stream. Never play the uploaded original.","check":"Upload a 1080p test video. The job writes a multivariant playlist with three or more renditions, and no segment is longer than 6.5 seconds. A request for the original without a signature answers 403.","check_type":"http","url":"https://agentwranglers.se/playbook/files-and-media/video-and-audio/adaptive-streaming","related":["/playbook/files-and-media/video-and-audio/media-tool-sandbox","/playbook/website/performance/video-delivery","/playbook/files-and-media/video-and-audio/video-posters"],"sources":["https://www.rfc-editor.org/rfc/rfc8216","https://developer.apple.com/streaming/hls-authoring-specification-for-apple-devices.html"]},{"id":"MED-14","revision":"39f439830936","updated":"2026-10-22","name":"Run media tools in a sandbox with no network","level":"Required","risk":"data","rule":"Run every tool that decodes uploaded media, such as FFmpeg or ImageMagick, in a sandbox. It has no network, sees only its input and output folders, and stops at a time and memory limit.","check":"On the test copy, upload an HLS playlist renamed to `.mp4` that lists `file:///etc/passwd` and an address on a test server. The job fails, the test server logs no request, and no output file holds the text of `/etc/passwd`. A job made to run past its time limit is killed.","check_type":"http","url":"https://agentwranglers.se/playbook/files-and-media/video-and-audio/media-tool-sandbox","related":["/playbook/files-and-media/uploads/svg-and-html-uploads","/playbook/files-and-media/video-and-audio/adaptive-streaming","/playbook/engineering/ci-and-supply-chain/image-scanning","/playbook/application-security/requests-files-and-caches/block-server-side-request-forgery","/playbook/files-and-media/video-and-audio/media-limits","/playbook/files-and-media/video-and-audio/loudness-normalisation","/playbook/files-and-media/generated-documents/sandboxed-rendering"],"sources":["https://cheatsheetseries.owasp.org/cheatsheets/File_Upload_Cheat_Sheet.html","https://ffmpeg.org/ffmpeg-protocols.html"]},{"id":"MED-15","revision":"4773edb67ce7","updated":"2026-10-22","name":"Probe each media file and refuse it past its limits","level":"Recommended","rule":"Before transcoding, read each file's duration, resolution and frame rate with a probe such as `ffprobe`. Refuse the file when any value passes the limit of its upload kind.","check":"Upload a 2 second clip at 7680 by 4320 pixels and a 1 hour clip at 64 by 64 pixels, both under the size limit. Both are refused with a problem response naming the limit, and no encoding job starts.","check_type":"http","url":"https://agentwranglers.se/playbook/files-and-media/video-and-audio/media-limits","related":["/playbook/files-and-media/uploads/upload-kinds","/playbook/files-and-media/video-and-audio/media-tool-sandbox"],"sources":[]},{"id":"MED-16","revision":"8765de6bacfe","updated":"2026-10-22","name":"Make a poster and a thumbnail from every video","level":"Recommended","rule":"Make a poster image and a thumbnail for every video in the transcoding job, and let the uploader pick another frame. Keep the thumbnail address the same when the video is encoded again.","check":"Every video in the `ready` state has a poster and a thumbnail with a stored width and height. Encode a test video again, and its thumbnail address is unchanged.","check_type":"manual","url":"https://agentwranglers.se/playbook/files-and-media/video-and-audio/video-posters","related":["/playbook/files-and-media/images/process-images","/playbook/files-and-media/images/fixed-image-sizes","/playbook/website/performance/video-delivery","/playbook/seo/search-result-appearance/video-watch-pages","/playbook/files-and-media/video-and-audio/adaptive-streaming"],"sources":[]},{"id":"MED-17","revision":"de3206798e3e","updated":"2026-10-22","name":"Keep captions as WebVTT files with each video","level":"Recommended","rule":"Store each video's captions as WebVTT files, one per language, and list them in its player and its stream. Let uploaders add and correct them, and mark machine captions as automatic until a person checks them.","check":"Every ready video with speech has a captions file that parses as WebVTT. Its multivariant playlist lists a subtitles group with a `LANGUAGE` for each file. Machine captions that nobody checked show as automatic in the player.","check_type":"manual","url":"https://agentwranglers.se/playbook/files-and-media/video-and-audio/caption-files","related":["/playbook/website/performance/video-delivery","/playbook/seo/search-result-appearance/video-watch-pages"],"sources":["https://www.w3.org/TR/webvtt1/","https://developer.apple.com/streaming/hls-authoring-specification-for-apple-devices.html"]},{"id":"MED-18","revision":"9fcb2e4060c2","updated":"2026-10-22","name":"Even out the loudness of uploaded audio","level":"Optional","rule":"Measure each uploaded audio track's loudness by ITU-R BS.1770 and adjust it to one target, such as −23 LUFS with peaks under −1 dBTP.","check":"Upload test tracks at −35 and −10 LUFS. After processing, both measure within 1 LU of the target, with true peaks at or below −1 dBTP.","check_type":"manual","url":"https://agentwranglers.se/playbook/files-and-media/video-and-audio/loudness-normalisation","related":["/playbook/files-and-media/video-and-audio/media-tool-sandbox"],"sources":["https://www.itu.int/rec/R-REC-BS.1770","https://tech.ebu.ch/publications/r128"]},{"id":"MED-19","revision":"1f55c1b899fa","updated":"2026-10-22","name":"Give every file version its own address","level":"Recommended","rule":"Put a version or a content hash in the address of every public file and derived file. A changed file gets a new address, so each address can be cached as long as a hashed asset.","check":"`curl -sI` on a derived image shows `immutable`. Replace the original, and the app links a new address within 1 minute while the old address still answers 200.","check_type":"http","url":"https://agentwranglers.se/playbook/files-and-media/serving-files/versioned-file-addresses","related":["/playbook/files-and-media/images/format-negotiation","/playbook/website/performance/cache-control","/playbook/application-security/requests-files-and-caches/private-responses-uncached","/playbook/files-and-media/serving-files/signed-cdn-access"],"sources":["https://www.rfc-editor.org/rfc/rfc8246"]},{"id":"MED-20","revision":"445b5ef9d687","updated":"2026-10-22","name":"Sign CDN access to private media for the whole stream","level":"Recommended","rule":"Serve private video and other media made of many files through the CDN with a signed cookie or token for one path prefix. The CDN checks it on every segment, and the app checks access before it issues one.","check":"Without the cookie, a segment request answers 403 at the CDN. With a cookie for video A, a segment of video B answers 403. After the grant expires, a segment of video A answers 403.","check_type":"http","url":"https://agentwranglers.se/playbook/files-and-media/serving-files/signed-cdn-access","related":["/playbook/files-and-media/serving-files/versioned-file-addresses","/playbook/application-security/secrets-and-configuration/private-storage-buckets","/playbook/files-and-media/serving-files/signed-downloads"],"sources":["https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-choosing-signed-urls-cookies.html","https://docs.cloud.google.com/cdn/docs/using-signed-cookies"]},{"id":"MED-21","revision":"53667eeed9b0","updated":"2026-10-22","name":"Purge cached copies when a file is deleted or removed","level":"Required","risk":"law","rule":"When a file is deleted, erased or taken down, purge its addresses and every derived file from the CDN in the same job. Close the request only after the purge is confirmed.","check":"Load a public test image and its thumbnail through the CDN, so both are cached. Delete the file. Within 5 minutes both addresses answer 404 or 410 from every CDN region tested, and the job log shows the purge confirmed.","check_type":"manual","url":"https://agentwranglers.se/playbook/files-and-media/serving-files/cdn-purge-on-delete","related":["/playbook/files-and-media/storage-and-backups/delete-files-with-owner","/playbook/compliance/online-platforms/notice-and-action","/playbook/files-and-media/serving-files/share-links","/playbook/files-and-media/copyright-and-takedowns/takedown-and-counter-notice"],"sources":["https://eur-lex.europa.eu/eli/reg/2016/679/oj","https://eur-lex.europa.eu/eli/reg/2022/2065/oj"]},{"id":"MED-46","revision":"4b675bc748f4","updated":"2026-10-22","name":"Serve private files through short-lived links","level":"Required","risk":"data","rule":"Keep the bucket private. Check access on every download request, then redirect to a signed address that expires within 5 minutes and sets safe download headers.","check":"Fetch the bucket address of a private file without a signature, and storage answers 403. A signed address works, then answers 403 after 5 minutes. A file named `rapport \"Q3\"\\r\\nX: y.pdf` downloads with one `Content-Disposition` header and no extra header.","check_type":"http","url":"https://agentwranglers.se/playbook/files-and-media/serving-files/signed-downloads","related":["/playbook/api-design/api-security/no-secrets-in-urls","/playbook/data/multi-tenancy/tenant-scoped-storage","/playbook/email/email-security/safe-attachments","/playbook/files-and-media/uploads/user-content-domain","/playbook/files-and-media/serving-files/signed-cdn-access","/playbook/api-design/api-security/object-authorisation","/playbook/application-security/secrets-and-configuration/private-storage-buckets","/playbook/files-and-media/serving-files/range-downloads","/playbook/files-and-media/serving-files/share-links","/playbook/files-and-media/serving-files/hotlink-protection","/playbook/files-and-media/generated-documents/document-jobs"],"sources":["https://www.rfc-editor.org/rfc/rfc6266","https://www.rfc-editor.org/rfc/rfc8187"]},{"id":"MED-51","revision":"9582183a8c89","updated":"2026-10-22","name":"Let large downloads resume with range requests","level":"Recommended","rule":"Answer byte range requests with 206 on every download over 10 MB, so a client that loses the connection fetches only the missing bytes.","check":"A test downloads a 20 MB export with `Range: bytes=0-99` and gets 206, a matching `Content-Range` and exactly 100 bytes. The same request with a stale `If-Range` gets 200 and the whole file. A range past the end gets 416.","check_type":"http","url":"https://agentwranglers.se/playbook/files-and-media/serving-files/range-downloads","related":["/playbook/files-and-media/serving-files/signed-downloads","/playbook/files-and-media/uploads/resumable-uploads"],"sources":["https://www.rfc-editor.org/rfc/rfc9110#section-14","https://www.rfc-editor.org/rfc/rfc9110#section-13.1.5"]},{"id":"MED-38","revision":"60dd5aac34f7","updated":"2026-10-22","name":"Give every share link a random token and an expiry","level":"Required","risk":"data","rule":"A link that opens a file without signing in holds a random token of at least 128 bits, an expiry and an owner. The owner can see and revoke each link, and a revoked or expired link answers 410.","check":"Create a link and open it signed out. It works, and the response carries both headers. Revoke it, and the next request answers 410. A link past its expiry answers 410. The stored row holds a hash, not the token.","check_type":"http","url":"https://agentwranglers.se/playbook/files-and-media/serving-files/share-links","related":["/playbook/api-design/api-security/api-keys","/playbook/files-and-media/serving-files/signed-downloads","/playbook/files-and-media/serving-files/cdn-purge-on-delete"],"sources":["https://www.w3.org/TR/capability-urls/","https://developers.google.com/search/docs/crawling-indexing/robots-meta-tag"]},{"id":"MED-30","revision":"053dd1a00ffd","updated":"2026-10-22","name":"Stop other sites from serving your files","level":"Recommended","rule":"Serve private files only through addresses that expire. For public files, refuse requests at the CDN whose `Referer` names a site outside your own list, and allow requests that send no `Referer`.","check":"Request a public image with `Referer: https://other.example.net/`, and the CDN answers 403. The same request with your own domain, or with no `Referer`, answers 200.","check_type":"http","url":"https://agentwranglers.se/playbook/files-and-media/serving-files/hotlink-protection","related":["/playbook/files-and-media/serving-files/signed-downloads","/playbook/files-and-media/quotas-and-cost/egress-alerts"],"sources":["https://www.rfc-editor.org/rfc/rfc9110#section-10.1.3"]},{"id":"MED-22","revision":"11341c5c8c11","updated":"2026-10-22","name":"Render documents with no network and no local files","level":"Required","risk":"data","rule":"Turn HTML into PDF or images in a renderer that can load only the template's own assets, never other addresses or local files. Escape every value placed in the template.","check":"On the test copy, set a customer name to `<img src=\"https://test-server.example.com/hit\">` and another to `<iframe src=\"file:///etc/passwd\">`. Generate an invoice for each. The test server logs no request, each PDF shows the name as text, and neither holds a line of `/etc/passwd`.","check_type":"http","url":"https://agentwranglers.se/playbook/files-and-media/generated-documents/sandboxed-rendering","related":["/playbook/application-security/input-and-injection/template-injection","/playbook/files-and-media/video-and-audio/media-tool-sandbox","/playbook/application-security/requests-files-and-caches/block-server-side-request-forgery"],"sources":["https://cheatsheetseries.owasp.org/cheatsheets/Server_Side_Request_Forgery_Prevention_Cheat_Sheet.html","https://doc.courtbouillon.org/weasyprint/stable/first_steps.html"]},{"id":"MED-23","revision":"38198254c655","updated":"2026-10-22","name":"Build documents in a background job","level":"Recommended","rule":"Generate PDFs, exports and other documents in a background job that stores the file and tells the person when it is ready. Never render one inside a web request.","check":"A load test asks for 50 invoices at once. Every web request answers 202 within 500 ms with a job address. No worker runs more renders than its cap, and all 50 files appear once each.","check_type":"http","url":"https://agentwranglers.se/playbook/files-and-media/generated-documents/document-jobs","related":["/playbook/api-design/reliability/long-running-jobs","/playbook/files-and-media/storage-and-backups/storage-lifecycle","/playbook/files-and-media/serving-files/signed-downloads","/playbook/scaling/exports-and-fair-share/build-exports-ahead"],"sources":[]},{"id":"MED-24","revision":"be29a0c82736","updated":"2026-10-22","name":"Store each issued document and never rebuild it","level":"Recommended","rule":"Save every issued invoice, receipt, contract and statement as the exact file sent, with its SHA-256 and template version. Serve that stored file every time after, never a new render from today's data.","check":"Issue a test invoice, then change the template and the customer's address. Download the invoice again, and its SHA-256 equals the stored one.","check_type":"manual","url":"https://agentwranglers.se/playbook/files-and-media/generated-documents/issued-documents","related":["/playbook/payments/invoices-and-records/credit-notes","/playbook/payments/invoices-and-records/payment-record-retention","/playbook/files-and-media/generated-documents/pdf-a-archives"],"sources":["https://eur-lex.europa.eu/eli/dir/2010/45/oj"]},{"id":"MED-25","revision":"7b43456524c8","updated":"2026-10-22","name":"Make generated PDFs accessible","level":"Required","risk":"law","applies":["eu-users"],"region":["EU"],"rule":"When the European Accessibility Act covers your service, generate every PDF that people read as a tagged PDF. Give it a title, a document language, headings, a reading order, image descriptions and embedded fonts. Validate each document type against PDF/UA in CI.","check":"CI renders one sample of each document type and runs a PDF/UA validator on it with 0 failures. A text extractor reads a customer name in Arabic and one in Chinese from the sample as text.","check_type":"command","url":"https://agentwranglers.se/playbook/files-and-media/generated-documents/accessible-pdfs","related":["/playbook/accessibility/media-documents-and-email/tagged-pdf","/playbook/compliance/product-and-data-laws/accessibility-act-duty","/playbook/stack/product-services/html-to-pdf"],"sources":["https://www.iso.org/standard/82278.html","https://www.w3.org/WAI/WCAG22/Techniques/#pdf","https://eur-lex.europa.eu/eli/dir/2019/882/oj"]},{"id":"MED-26","revision":"801403277153","updated":"2026-10-22","name":"Use PDF/A for documents kept for years","level":"Optional","rule":"Write documents that must stay readable for 5 years or more, such as invoices and signed agreements, as PDF/A. Validate each file against its declared PDF/A part before you store it.","check":"Every stored invoice passes a PDF/A validator, such as veraPDF, for the part it declares.","check_type":"manual","url":"https://agentwranglers.se/playbook/files-and-media/generated-documents/pdf-a-archives","related":["/playbook/payments/invoices-and-records/e-invoicing","/playbook/files-and-media/generated-documents/issued-documents"],"sources":["https://www.iso.org/standard/71832.html"]},{"id":"MED-27","revision":"8b9c750b0233","updated":"2026-10-22","name":"Count each owner's storage and enforce a quota","level":"Recommended","rule":"Keep a running total of stored bytes per owner, including old versions and derived files. Refuse a new upload address when the upload would pass the owner's quota.","check":"Set a test owner's quota to 10 MB with 9 MB used. A request for a 2 MB upload address is refused with a problem response naming the quota. The weekly comparison finds each owner's total within 1 percent of the bucket listing.","check_type":"http","url":"https://agentwranglers.se/playbook/files-and-media/quotas-and-cost/storage-quotas","related":["/playbook/files-and-media/uploads/presigned-uploads","/playbook/usage-billing/metering/server-side-metering","/playbook/scaling/exports-and-fair-share/per-tenant-limits"],"sources":[]},{"id":"MED-28","revision":"d62e936106aa","updated":"2026-10-22","name":"Limit how many uploads each account starts","level":"Recommended","rule":"Limit how many upload addresses each account may ask for per hour, with a lower limit for new accounts. Past the limit, answer 429 with `Retry-After`.","check":"A test asks for upload addresses one past the hourly limit from one account. The last request answers 429 with `Retry-After`. A new account hits its lower limit first.","check_type":"http","url":"https://agentwranglers.se/playbook/files-and-media/quotas-and-cost/upload-rate-limits","related":["/playbook/application-security/limits-and-business-logic/rate-limits","/playbook/api-design/reliability/rate-limit-headers","/playbook/trust-and-safety/sign-up-fraud-and-abuse/new-account-limits"],"sources":[]},{"id":"MED-29","revision":"2bf53ee4b98b","updated":"2026-10-22","name":"Watch data sent out per file and per owner","level":"Recommended","rule":"Count the bytes sent out per file and per owner each day. Alert when either passes 10 times its 28 day daily average, and slow or stop downloads past the owner's daily cap.","check":"Replay a test access log in which one file serves 20 times its daily average. An alert names the file and its owner within 1 hour. Downloads by an owner past their daily cap answer 429.","check_type":"manual","url":"https://agentwranglers.se/playbook/files-and-media/quotas-and-cost/egress-alerts","related":["/playbook/files-and-media/serving-files/hotlink-protection","/playbook/infrastructure/hosting-platforms/usage-cost-model","/playbook/infrastructure/cost-and-ownership/budgets-for-every-account","/playbook/operations/capacity-and-resilience/exhaustion-alerts"],"sources":[]},{"id":"MED-31","revision":"d1ae43fb67d1","updated":"2026-10-22","name":"Register a copyright agent before you host files for US users","level":"Required","risk":"money","applies":["user-content"],"region":["US"],"rule":"To rely on the US section 512 safe harbour for files users upload, designate an agent with the US Copyright Office. Publish the agent's contact details on your site, and renew the designation before it expires.","check":"The Copyright Office's DMCA directory lists the business with an expiry date more than 30 days away. The site's copyright page shows the same agent details. The compliance calendar holds the renewal date.","check_type":"manual","url":"https://agentwranglers.se/playbook/files-and-media/copyright-and-takedowns/dmca-agent","related":["/playbook/compliance/scope-and-ownership/compliance-calendar","/playbook/compliance/online-platforms/notice-and-action"],"sources":["https://www.copyright.gov/dmca-directory/","https://www.copyright.gov/title17/92chap5.html#512","https://blogs.loc.gov/copyright/2019/10/it-may-be-time-to-renew-your-dmca-agent-registration/"]},{"id":"MED-32","revision":"2af6e10b1175","updated":"2026-10-22","name":"Take files down and restore them after a counter-notice","level":"Recommended","rule":"On a complete copyright notice, disable the file and every copy and derived file, and tell the uploader with the notice's details. Restore the file 10 to 14 business days after a valid counter-notice, unless the sender reports a court action.","check":"An end-to-end test files a complete notice for a test video. The video, its thumbnail and its stream answer 451, and the uploader gets an email naming the notice. A counter-notice schedules the restore between 10 and 14 business days later.","check_type":"manual","url":"https://agentwranglers.se/playbook/files-and-media/copyright-and-takedowns/takedown-and-counter-notice","related":["/playbook/files-and-media/serving-files/cdn-purge-on-delete","/playbook/trust-and-safety/decisions-and-appeals/removed-content-hold","/playbook/compliance/online-platforms/notice-and-action"],"sources":["https://www.copyright.gov/title17/92chap5.html#512","https://www.rfc-editor.org/rfc/rfc7725"]},{"id":"MED-33","revision":"e506d3a8a7e0","updated":"2026-10-22","name":"Close the accounts of repeat infringers","level":"Recommended","rule":"Publish a repeat infringer policy with a fixed number of valid copyright strikes that closes an account, such as 3 in 12 months. Apply it every time the number is reached.","check":"A test account gets 3 valid notices within 12 months, and the account closes with a message to its owner. A withdrawn notice removes its strike. The terms page states the policy.","check_type":"manual","url":"https://agentwranglers.se/playbook/files-and-media/copyright-and-takedowns/repeat-infringers","related":["/playbook/trust-and-safety/decisions-and-appeals/strikes-and-suspensions","/playbook/trust-and-safety/sign-up-fraud-and-abuse/ban-evasion"],"sources":["https://www.copyright.gov/title17/92chap5.html#512"]},{"id":"MED-34","revision":"14fcdcb5f7cb","updated":"2026-10-22","name":"Decide whether EU Article 17 covers your uploads","level":"Recommended","applies":["eu-users"],"rule":"Decide in writing whether you are an online content-sharing service under Article 2(6) of EU Directive 2019/790. If you are, seek licences and block works that rights holders identify, as Article 17 requires.","check":"The obligations register holds the Article 2(6) decision with its facts and date. If the service is in scope, a test upload of a work on a rights holder's list is blocked. The uploader can then complain to a person.","check_type":"manual","url":"https://agentwranglers.se/playbook/files-and-media/copyright-and-takedowns/article-17-check","related":["/playbook/compliance/scope-and-ownership/obligations-register","/playbook/compliance/online-platforms/dsa-tier"],"sources":["https://eur-lex.europa.eu/eli/dir/2019/790/oj"]},{"id":"MED-35","revision":"d5aeb789ed8c","updated":"2026-10-22","name":"Record who uploaded each file and under what licence","level":"Recommended","rule":"Store the uploader, the upload time and the accepted terms version for every file others can see. When the uploader picks a licence, such as a Creative Commons licence, show it where the file appears.","check":"The database refuses a visible file record without an uploader, an upload time and a terms version. Every public page showing a file with a Creative Commons licence shows the licence name and a link to it.","check_type":"manual","url":"https://agentwranglers.se/playbook/files-and-media/copyright-and-takedowns/uploader-and-licence","related":["/playbook/files-and-media/storage-and-backups/delete-files-with-owner","/playbook/trust-and-safety/decisions-and-appeals/removed-content-hold","/playbook/trust-and-safety/reports-and-queues/report-button"],"sources":[]}]}