T09 · Insecure Skill Coding Practices
- Location
diskclean.sh:224- Finding
Log directories are marked safe without enforcing the documented age gate
- Content
View full analysis
= 50 )); then emit_item "$logs_dir" "logs" "$size" "999" "safe" fi fi local crash_dir="${HOME}/Library/Logs/DiagnosticReports" if [[ -d "$crash_dir" ]]; then local size size=$(dir_size_mb "$crash_dir") if (( size >= 10 )); then emit_item "$crash_dir" "crash_reports" "$size" "999" "safe" fi fi local tmp_user="/private/tmp/claude-$(id -u)" ``` ### Technical Analysis The scanner assigns an artificial age of `999` days to the complete `~/Library/Logs` and `~/Library/Logs/DiagnosticReports` directories and marks them as `safe` based solely on their aggregate size. It does not inspect the actual modification time of any directory or file. This contradicts the documented 30-day age gate for logs and crash reports. During confirmed cleanup, safe directory entries are passed to `shutil.rmtree`, recursively deleting their entire contents. Consequently, recent and actively used logs can be removed even though the user is told that only items older than 30 days qualify. The two emitted paths also overlap: `DiagnosticReports` is contained within `Library/Logs`. This can produce duplicate cleanup records, misleading reclaimed-space totals, and a second deletion attempt after the parent directory has already been removed. ### Attack Path 1. `~/Library/Logs` grows to at least 50 MB, or `DiagnosticReports` grows to at least 10 MB. 2. The user or Agent runs `diskclean.sh scan`. 3. The scanner marks the entire directory as safe and reports an age of 999 days without checking actual timestamps. 4. The dry-run presents the directory as an age-qualified safe item. 5. R ...[truncated 882 chars]- Remediation
View remediation
