T09 · Insecure Skill Coding Practices
- Location
prompt.md:249- Finding
Unrestricted User-Controlled Output Path Allows Arbitrary File Writes
- Content
View full analysis
- Remediation
View remediation
/docs/prd/`. - Reject the request if it escapes that directory. 2. **Reject dangerous path forms** - Reject absolute paths. - Reject paths containing `..`, null bytes, control characters, or platform-specific path ambiguities. - Permit only filenames ending in `.md`. 3. **Defend against symlink escapes** - Check every existing path component for symbolic links. - Resolve symlinks before performing the workspace-boundary check. - Prefer filesystem APIs that prevent following symlinks during final file creation where available. 4. **Prevent unintended overwrites** - Use exclusive file creation by default. - If the destination exists, require explicit user confirmation before replacing it. - Consider generating a unique filename instead of overwriting. 5. **Create only the validated parent directory** - Perform directory creation only after path validation. - Do not derive `mkdir` commands directly from untrusted input. - Use structured filesystem APIs rather than shell command interpolation. 6. **Use a safe validation pattern** - Accept a filename or project slug rather than an unrestricted path. - Construct the final path internally as `/docs/prd/.md`. - Record and display the canonical destination before writing. ]]>
