T09 · Insecure Skill Coding Practices
- Location
- scripts/cleanup.sh:16
- Finding
- Indiscriminate deletion of shared temporary files## Vulnerability Details **File Location**: `scripts/cleanup.sh:16-18` **Vulnerability Type**: Unsafe recursive file deletion **Risk Level**: High **Complete Code Snippet**: ```bash # 3. Temp Files rm -rf /tmp/* /var/tmp/* echo "Temp files cleared" ``` ### Technical Analysis The script recursively and forcibly deletes all visible entries under `/tmp` and `/var/tmp` without checking file age, ownership, type, mount boundaries, or whether an entry is actively used. These directories are shared by applications, users, and system services and can contain sockets, lock files, session state, staged data, and active working files. This implementation contradicts the documented policy in `SKILL.md`, which describes deleting only old `.tmp` files and provides an age-filtered example. Glob expansion also omits hidden entries, so the operation is simultaneously destructive and incomplete. Although this issue does not provide an attacker with additional privileges by itself, elevated execution substantially increases the affected scope. A user or process can trigger loss of temporary data belonging to other users and root-owned services. ### Attack Path 1. A user invokes the skill believing it will perform the documented safe cleanup. 2. The cleanup script runs with root privileges or through the skill's elevated execution setting. 3. Shell glob expansion resolves every visible entry immediately below `/tmp` and `/var/tmp`. 4. `rm -rf` recursively removes those entries without age, ownership, or active-use validation. 5. Applications and services using the deleted files may lose data, malfunction, or enter an inconsistent state. ### Impact Assessment When run as root, the command can delete temporary data owned by every local user and system service. Potential consequences include application failures, destroyed session or working data, removal of lock files or sockets, interrupted installations, and system instability. Th ...[truncated 143 chars]
- Remediation
- ## Remediation Suggestions - Prefer the operating system's temporary-file lifecycle manager, such as `systemd-tmpfiles --clean`. - If custom cleanup is required, restrict it to old regular files and prevent traversal across filesystems: ```bash find /tmp /var/tmp -xdev -type f -atime +7 -print ``` - Present the resulting file list and obtain explicit confirmation before replacing `-print` with `-delete`. - Do not remove sockets, device files, directories, or actively used files through a blanket recursive command. - Run cleanup with the minimum required privileges and separate per-user cleanup from system-wide cleanup. - Update the implementation to match the restrictions documented in `SKILL.md`.
