T09 · Insecure Skill Coding Practices
- Location
scripts/rename_files.py:17- Finding
Path Traversal Through Unsanitized Credential Filename Components
- Content
View full analysis
- Remediation
View remediation
Path: base = base.resolve() candidate = candidate.resolve() if not candidate.is_relative_to(base): raise ValueError("Destination escapes the permitted directory") return candidate ``` 6. Use a sanitized basename and verify both `renamed_path` and `dst_path` against their respective permitted parent directories. 7. Refuse to replace existing files, or generate collision-resistant names using an explicit and documented policy. 8. Validate `src_path` and ensure that it refers to an expected regular file within an approved input directory. 9. Add security tests for absolute paths, `../` traversal, backslash traversal, nested directory components, unsupported extensions, symlinks, and destination collisions. ]]>
