T09 · Insecure Skill Coding Practices
Warning
- Location
- references/config/cleanup.yaml:11
- Finding
- Automatic Overbroad Cleanup Can Remove Unrelated User Files Without Confirmation## Vulnerability Details **File Location**: `references/config/cleanup.yaml:11-16, 48-59, 119-149, 223-232, 315-327`; conflicting safeguards in `SKILL.md:596-603` **Vulnerability Type**: Unsafe destructive file-cleanup configuration **Risk Level**: Medium ### Vulnerable Code ```yaml global: enabled: true cleanup_on_start: true # Cleanup at startup cleanup_on_complete: true # Cleanup after task completion cleanup_on_error: true # Cleanup after errors dry_run: false # Perform actual deletion log_deletions: true ``` ```yaml compilation_cache: patterns: - "**/.cache/" - "**/target/debug/" - "**/target/release/" - "**/.gradle/" - "**/.m2/" - "**/.npm/" - "**/.eslintcache" - "**/.tsbuildinfo" ``` ```yaml dev_tools_cache: patterns: - "**/.vscode/.cache/" - "**/.idea/caches/" - "**/.env.local" - "**/.env.*.local" retention: max_age_hours: 168 cleanup_strategy: "manual" ``` ```yaml media_cache: patterns: - "**/*.mp4" - "**/*.avi" - "**/*.mov" - "**/*.mp3" - "**/*.wav" - "**/*.jpg" - "**/*.png" - "**/*.gif" retention: max_age_hours: 24 max_size_mb: 5000 cleanup_strategy: "size_based" ``` ```yaml - name: "weekly_deep_cleanup" enabled: true schedule: "0 2 * * 0" categories: - "dev_tools_cache" - "test_artifacts" conditions: - type: "age" threshold_hours: 168 action: "delete" priority: 3 ``` ```yaml execution: max_parallel_deletes: 10 delete_batch_size: 100 require_confirmation: false large_file_threshold_mb: 100 move_to_trash: true ``` The configuration conflicts with the safeguards declared in `SKILL.md`: ```markdown | **Use trash** | Use the `trash` command instead of `rm` so recovery is possible | | **Preview before deletion** | Use `--dry-run` to list files pending deletion | | **Secondary confirmation** | Display the file list and require confirmation before deletion | | **R ...[truncated 4259 chars]
- Remediation
- ## Remediation Suggestions 1. **Disable automatic destructive cleanup by default** ```yaml global: cleanup_on_start: false cleanup_on_complete: false cleanup_on_error: false dry_run: true ``` 2. **Require informed confirmation** ```yaml execution: require_confirmation: true move_to_trash: true ``` Display the complete resolved file list, total size, scan root, and reason for matching before accepting approval. 3. **Constrain cleanup to a task-specific root** - Require an explicit workspace path created for the current task. - Resolve the workspace and every candidate with canonical path resolution. - Reject candidates outside the canonical workspace. - Do not scan home directories, repository parents, system temporary roots, or arbitrary current working directories. 4. **Use an artifact ownership allowlist** - Track files created by the current task in a manifest. - Permit cleanup only for manifest entries or narrowly defined task-generated directories. - Do not infer ownership solely from filenames, extensions, age, or directory names. 5. **Remove sensitive and user-content patterns** - Remove `.env.local`, `.env.*.local`, and all credential or key patterns from cleanup categories. - Remove broad media patterns such as `**/*.png`, `**/*.jpg`, `**/*.mp4`, and `**/*.mp3`. - Restrict cache cleanup to caches created inside the task workspace. 6. **Preserve manual-category semantics** - Exclude `dev_tools_cache` from all scheduled and automatic rules. - Validate configuration at load time and reject any automatic rule referencing a category marked `manual`. 7. **Harden path processing** - Reject symlinks or verify both link and target remain inside the authorized root. - Prevent `..` traversal and filesystem mount-boundary crossing. - Avoid following junctions, bind mounts, and recursive links. - Apply deletion atomically where possible and handle race conditions be ...[truncated 573 chars]
