T09 · Insecure Skill Coding Practices
- Location
SKILL.md:221- Finding
Unsafe Destructive Trash Deletion Using a Working-Directory-Relative Path
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, line 221
Vulnerability Type: Unsafe destructive file operation and ambiguous path handling
Risk Level: MediumVulnerable Code
markdown | Clear Trash | `rm -rf ./.Trash/*` (confirm first) |Technical Analysis
The skill recommends recursively and forcibly deleting
./.Trash/*. Because this path is relative to the agent's current working directory, it does not reliably identify the current user's macOS Trash directory. If the command runs from an unexpected or attacker-influenced directory containing a.Trashsubdirectory, it can permanently delete unrelated files.The use of
rm -rfcompounds the risk by recursively deleting content without normal recovery through macOS Trash and by suppressing many prompts and errors. Requiring confirmation before execution helps prevent accidental invocation, but it does not ensure that the deletion target is correct. The glob also excludes dot-prefixed entries within.Trash, making the advertised operation incomplete.Attack Path
- The user asks the agent to empty the macOS Trash.
- The agent follows the skill and requests confirmation.
- The user confirms while reasonably assuming the command targets the standard macOS Trash directory.
- The agent executes
rm -rf ./.Trash/*from its current working directory. - If that directory has an unrelated
.Trashsubdirectory, all matched content beneath it is recursively and permanently deleted. - Recovery through the normal macOS Trash interface is unavailable because
rmdirectly unlinks the files.
An attacker able to influence the working directory or arrange sensitive files under its
.Trashsubdirectory could increase the likelihood and impact of unintended deletion.Impact Assessment
The command executes with the privileges of the agent's operating-system process. It can permanently delete any matched files that account is permitted to remove. It does not independent ...[truncated 258 chars]
- Remediation
View remediation
Remediation Suggestions
- Do not use a working-directory-relative path for destructive deletion.
- Resolve the intended per-user Trash location to an absolute, canonical path and validate it immediately before execution.
- Reject the operation if the resolved target is absent, is a symbolic link, or differs from the expected Trash directory.
- Display the validated absolute path and a summary of the affected entries when requesting confirmation.
- Prefer a macOS-native Finder or System Events operation that preserves platform semantics instead of directly invoking
rm -rf. - If direct deletion is unavoidable, implement a dedicated script that uses safe path handling, checks ownership and directory type, prevents traversal or symlink redirection, and fails closed on validation errors.
- Avoid shell globbing for deletion targets. Enumerate and validate each target explicitly, including dot-prefixed entries where appropriate.
- Add post-operation reporting that identifies exactly which validated directory was processed and whether any entries failed.
