T09 · Insecure Skill Coding Practices
- Location
references/detail.md:19- Finding
Predictable Shared Temporary Directory Enables Log Disclosure and Symlink-Based File Overwrite
- Content
View full analysis
- Remediation
View remediation
` or a private per-user state directory. 2. Create the directory with mode `0700` and verify that it is a real directory owned by the expected account before every use. 3. Refuse to operate if the directory or destination files are symbolic links. Use descriptor-based, symlink-safe APIs with `O_NOFOLLOW`, `O_CREAT`, and `O_EXCL` where supported. 4. Create log files with mode `0600`, and do not rely solely on the ambient umask. 5. Write updates to a securely created temporary file in the same trusted directory and atomically replace the destination. 6. Add file locking around the `success.json` read-modify-write sequence, or use an append-only structured log or transactional database. 7. Redact credentials, tokens, connection strings, and other secrets from standard output and error output before logging. Prefer recording bounded status metadata rather than raw process output. 8. Apply log rotation and strict size limits to prevent sensitive-data accumulation and disk exhaustion. 9. If temporary storage is unavoidable, create a unique private directory with `tempfile.mkdtemp()` and ensure that it is securely removed after use. ]]>
