filesystem-security
Path traversal defense, symlink attack mitigation, TOCTOU prevention, POSIX permissions, atomic file replacement, and protected directories
- License 许可
- MIT
- 所属仓库
- poppyTM/oride
- 最近更新
- 2026-09-30
- Stars
- ★ 1
- Forks
- 0
01 前言 Front Matter
- name
- filesystem-security
- description
- Path traversal defense, symlink attack mitigation, TOCTOU prevention, POSIX permissions, atomic file replacement, and protected directories
02 资源文件 7
- 参考文档checks/filesystem-security-checklist.md620 B
- 参考文档examples/safe_file_upload.md1.9 KB
- 参考文档manifest.json1.9 KB
- 参考文档references/file-upload-security.md1.8 KB
- 脚本scripts/check_permissions.sh62 B
- 脚本scripts/verify.sh3.7 KB
- 参考文档templates/filesystem-security-report.md1.3 KB
03 SKILL.md 正文
Filesystem Security & Access Control
1. Path Traversal Defense
Normalize and sanitize all file paths using canonical library methods (e.g. filepath.Clean). Verify that the resolved target path is strictly prefixed by the authorized workspace root before performing any read, write, or delete operation.
2. Symlink & Hardlink Attack Prevention
Resolve all symbolic links to their absolute target paths using filepath.EvalSymlinks. Explicitly reject any symlink whose target destination lies outside the designated project root directory.
3. Time-of-Check to Time-of-Use (TOCTOU) Mitigation
Avoid vulnerable check-then-open sequences. Use atomic file descriptor operations (e.g. os.OpenFile with O_CREATE|O_EXCL) to guarantee that the file examined is the exact file modified without race window exploitation.
4. Strict POSIX Permission Discipline
Enforce restrictive file permissions: 0600 (read/write by owner only) for private files and credentials; 0700 for private directories; 0644 for public source files; 0755 for executables. Never create world-writable files (0666/0777).
5. Safe Temporary File Management
Create temporary files exclusively via secure system utilities (os.CreateTemp) within designated temporary directories. Set restrictive permissions on temporary files and guarantee cleanup using defer os.Remove.
6. Atomic File Replacement
Never overwrite production files directly in-place. Write new content to an adjacent temporary file in the same filesystem directory, call f.Sync() to flush buffers to disk, and execute an atomic rename (os.Rename).
7. File Size & Memory Caps
Guard file reads against memory exhaustion attacks using bounded readers (io.LimitReader). Enforce an explicit maximum file size threshold (e.g. max 50MB) for automated ingestion and tool parsing.
8. Protected Directory Shield
Hardcode inviolable security barriers that prevent modifications to critical infrastructure paths: .git/, .prumo/credentials, system binary directories, and root filesystem locations.
9. Secure Data Wiping
When deleting temporary files containing decrypted keys or sensitive tokens, overwrite the disk blocks with random bytes or zeros prior to unlinking to prevent data recovery from raw block storage.
10. Filesystem Audit Logging
Record all file creation, modification, and deletion events in the project security audit log, capturing relative path, actor ID, timestamp, and post-modification cryptographic checksum.
04 同仓库更多 Skills
zoom-reflow
暂无简介
wireframe-styleguide
暂无简介
visual-regression
Pixel-by-pixel snapshot testing, Playwright integration, dynamic content masking, deterministic font rendering, and cross-browser CI gates
ui-implementation
Component-driven UI implementation, multi-state matrix (default, hover, focus-visible, active, disabled, loading, empty, error), DTCG design tokens, responsive layout contracts, and accessibility tree mapping.
tui-editor-engine
Text buffer and editing semantics for a terminal code editor — index conversion, transaction-first editing, multi-cursor invariants, undo grouping, and large-file behaviour.
tree-sitter-context-indexing
暂无简介