T09 · Insecure Skill Coding Practices
Error
- Location
- SKILL.md:133
- Finding
- Overbroad Destructive Log and Cache Cleanup<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:133-139` **Vulnerability Type**: Unsafe recursive file deletion **Risk Level**: High ### Vulnerable Code ```bash # Clean old logs (> 7 days) find /var/log -name "*.log" -mtime +7 -delete 2>/dev/null find ~/.cache -type f -mtime +7 -delete 2>/dev/null # Clean temp files rm -f /tmp/agent-temp-* 2>/dev/null rm -rf ~/.cache/pip 2>/dev/null ``` ### Technical Analysis The Skill describes these commands as “safe” auto-fixes, but their deletion scope is not limited to files created or owned by the Skill. The first command deletes every file ending in `.log` under `/var/log` if it is older than seven days. When executed with sufficient privileges, this can remove logs belonging to unrelated applications and system components. The second command recursively deletes all old files under the current user's cache directory, regardless of which application owns them. The final command removes the complete pip cache without checking whether another operation depends on it. The commands do not provide a dry-run, validate the resolved paths, enforce filesystem boundaries, preserve an audit record, or request confirmation. Redirecting standard error to `/dev/null` also conceals permission failures and partial cleanup, making it difficult to determine what was removed. ### Attack Path 1. The Agent observes disk usage above the documented critical threshold. 2. It interprets the cleanup commands as authorized “safe” automatic actions. 3. The Agent runs the commands using its current account or an elevated execution context. 4. `find` traverses system-wide or user-wide directories and identifies files unrelated to the Skill. 5. Matching logs and cache files are permanently deleted. 6. Operational diagnostics, audit evidence, or application state stored in those locations becomes unavailable. An attacker who can influence disk usage or persuade the Agent that disk pressure is critical could increase the likelih ...[truncated 792 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Do not characterize broad recursive deletion as automatically safe. - Require explicit user confirmation before deleting logs or application-owned cache files. - Use an allowlist containing only paths created and managed by this Skill. - Run a dry-run first and present the exact files, total size, and ownership information to the user. - Apply retention through `logrotate`, `journalctl --vacuum-*`, or application-specific maintenance tools rather than generic `find -delete`. - Never run cleanup with elevated privileges unless a specific approved target requires them. - Use `find -xdev` or equivalent filesystem-boundary controls where traversal is necessary. - Validate canonical paths before deletion and reject symbolic-link or path-redirection anomalies. - Preserve a deletion manifest and report errors instead of suppressing all standard error. - For pip, prefer supported cache-management commands such as `python -m pip cache purge`, subject to user approval. ]]>
