Files
MyAiConfiguration/shared/rules/security/references/files.md
T
Julian Lechner c3e22eb902
CI / CI configuration security checks (push) Successful in 6s
CI / Python tests and compilation (push) Failing after 12s
CI / QMD unit tests (push) Skipped
CI / Capabilities and shell quality (push) Successful in 1m50s
CI / Build and inspect generated packages (push) Skipped
CI / Bash integration and installation guards (push) Skipped
CI / Installed client configuration smoke tests (push) Skipped
CI / PowerShell tests on Ubuntu (push) Failing after 7m24s
corrections
2026-11-19 10:30:43 +01:00

14 lines
1.7 KiB
Markdown

# File and process security
Apply these rules when handling files, uploads, archives, paths, processes, IPC, XML parsing, or deserialization.
* Validate filenames, content, sizes, and paths; prevent traversal, zip-slip, and unsafe symbolic-link use.
* Resolve paths against a trusted root and verify the canonical result remains inside it. Account for symlink or reparse-point changes where an attacker can modify directories.
* Restrict filesystem permissions to the intended identity and directory. Use safe temporary-file creation and avoid predictable names or permissive shared locations.
* Validate upload content using limits and format-aware parsing; do not trust names or client-supplied MIME types. Store untrusted uploads outside executable or public paths.
* Limit archive entry count, nesting, total expanded size, and path destinations to prevent traversal and resource exhaustion.
* Do not execute uploaded or untrusted files. Avoid shell execution; when a process is required, fix the executable by absolute path and pass validated arguments through structured process APIs. On Windows, never pass untrusted arguments to `.bat` or `.cmd` targets, because `cmd.exe` re-parses them.
* Treat local files, IPC, and deserialized input as untrusted at relevant boundaries. Use explicit deserialization types and bound depth, size, and processing time.
* Parse untrusted XML with DTD processing and external entity resolution disabled (XXE); the language rules name the parser settings. Never let serialized input choose arbitrary runtime types.
* Avoid insecure temporary-file handoff and check permissions and ownership before consuming files from shared or attacker-writable locations.