T09 · Insecure Skill Coding Practices
- Location
scripts/safe_clone.sh:129- Finding
Arbitrary Recursive Deletion Through an Unrestricted Target Directory
- Content
View full analysis
/dev/null; then ``` The comments and messages above are translated into English for reporting; the executable statements are unchanged. ### Technical Analysis The script accepts `target_dir` as a command-line argument and passes it directly to: ```bash rm -rf "$target_dir" ``` Quoting prevents shell word splitting and command substitution, but it does not make the selected path safe. The script does not: - Resolve the path to its canonical location. - Reject `/`, the user's home directory, or another sensitive location. - Reject parent-directory traversal components such as `..`. - Restrict clones to a dedicated destination root. - Verify that the directory was previously created by this tool. - Reject a symbolic-link-based destination. - Verify that the directory is empty or contains only expected clone data. The interactive confirmation reduces accidental exploitation but is not an adequate authorization boundary. A user can misunderstand the prompt, and an automated agent, wrapper, or scripted input can approve it. ### Attack Path 1. An attacker influences the target directory supplied to the skill, or a user accidentally supplies a sensitive existing directory: ```bash ./scripts/safe_clone.sh https://github.com/example/repository "$HOME/Documents" ``` 2. The URL passes GitHub URL validation. 3. The script detects that the selected ta ...[truncated 883 chars]- Remediation
View remediation
