T09 · Insecure Skill Coding Practices
- Location
fix.sh:49- Finding
Unquoted Path Expansion in Recursive Directory Deletion
- Content
View full analysis
- Remediation
View remediation
0 )); then printf ' - %q\n' "${TARGETS[@]}" read -r -p " Delete these directories? [y/N] " REPLY if [[ "$REPLY" =~ ^[Yy]$ ]]; then for dir in "${TARGETS[@]}"; do rm -rf -- "$dir" done fi fi ``` Additional hardening should include: - Canonicalize `$WORKSPACE` and every deletion target before deletion. - Verify each canonical target remains strictly beneath the canonical workspace path. - Reject symbolic links or unexpected path types where appropriate. - Use `--` before path arguments to prevent names beginning with `-` from being treated as options. - Print each target using shell-safe escaping, such as `printf '%q'`. - Consider requiring confirmation for each target or moving directories to a quarantine location before permanent deletion. ]]>
