Skip to main content

build-a-safe-file-upload

Build a safe file upload with authorization, size and type controls, quarantine, scanning, isolated storage, safe retrieval, retention, and abuse handling. Use when users or systems submit files.

来源信息

仓库
protosphinx/sphinxstack
最近来源活动
2026年7月29日 13:55
检测到的 SKILL.md 语言
英语
星标
3
Forks
0

安装方式

默认使用会先检查来源的 Prompt;你也可以切换为直接命令,或下载本地副本。

检查来源文件

决定是否安装前,请先阅读 SKILL.md,以及 SkillsMP 当前展示的配套文件。

文件资源管理器
2 个文件

正在显示 SKILL.md

SKILL.md
来源说明 · 只读预览
name
build-a-safe-file-upload
category
code
description
Build a safe file upload with authorization, size and type controls, quarantine, scanning, isolated storage, safe retrieval, retention, and abuse handling. Use when users or systems submit files.
# build-a-safe-file-upload Treat every upload as untrusted bytes, regardless of its name or claimed type. ## When to use - Use for documents, images, media, archives, imports, or attachments. - Obtain specialist security and privacy review for high-risk or regulated files. ## Preconditions - Define uploaders, consumers, formats, limits, threats, privacy, retention, availability, and moderation. ## Procedure 1. Authorize upload intent and issue a bounded single-use upload identity. 2. Stream with byte, time, count, and decompression limits; never trust extension or client MIME. 3. Store under generated identity outside executable or public paths. 4. Quarantine until signature, structure, malware, archive, metadata, and policy checks finish. 5. Transform risky media in isolation and strip unnecessary metadata. 6. Serve through authorized download or safe rendering with correct headers and separate origin where needed. 7. Record provenance, hashes, owner, scan version, decision, retention, access, and deletion. 8. Test polyglots, traversal, bombs, malformed files, races, duplicates, scanners, and abuse. ## Failure plan - On scanner outage, keep files quarantined rather than failing open. ## Worked example A profile image is streamed to quarantine, decoded and re-encoded in isolation, stripped of metadata, and served from a non-executable origin. ## Done - An upload implementation records authorization, limits, quarantine, checks, storage, retrieval, retention, deletion, and audit - Polyglot, path, archive-bomb, malformed, race, scanner-outage, access, and cleanup tests verify safety
在 GitHub 查看