T09 · Insecure Skill Coding Practices
- Location
references/patterns.md:184- Finding
Destructive cleanup and flattening commands can cause irreversible data loss
- Content
View full analysis
Vulnerability Details
File Location:
references/patterns.md:184-194
Vulnerability Type: Unsafe destructive file operations
Risk Level: HighVulnerable Code
bash ### Flatten Nested Directories # Move all files from subdirs to parent find . -type f -exec mv {} . \; # Remove empty dirs find . -type d -empty -delete ### Remove Empty Files find . -type f -empty -deleteTechnical Analysis
The documented flattening operation recursively moves every discovered file into the current directory without checking for destination-name collisions. If files in different directories have identical names, a later move may overwrite an earlier file, depending on the platform and
mvimplementation.The subsequent commands permanently delete empty directories and empty files by using
find -delete. They do not provide a dry run, request explicit user approval, or use a recoverable trash mechanism. This directly conflicts with the safety rule inSKILL.md:66, which states that deletion requires explicit permission.Because these commands operate recursively from
., their effective scope depends on the Agent's current working directory. Running them from the workspace root can affect the entire accessible project tree.Attack Path
- A user asks the Agent to flatten nested directories or clean up empty files.
- The Agent loads
references/patterns.mdas directed by the Skill. - The Agent executes the documented
findcommands from a broad directory such as the workspace root. - All nested files are moved into one directory without collision checks.
- Empty files and directories are permanently deleted without a mandatory preview or confirmation step.
- Same-named files may be overwritten, while intentionally empty placeholder files and directories may be lost.
No privilege escalation is involved; exploitation is limited to filesystem objects writable by the Agent's existing ope ...[truncated 518 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove direct
-deleterecipes or require explicit user approval immediately before executing them. - Perform a mandatory dry run first:
bash find "$validated_root" -type f -empty -print find "$validated_root" -type d -empty -print - Use a recoverable trash mechanism instead of permanent deletion where available.
- Resolve and validate the target root before execution, and reject paths outside the approved workspace.
- For flattening, calculate every source and destination pair in advance and stop if any duplicate destination names are detected.
- Use no-clobber behavior such as
mv -n, while also checking its availability and semantics on the host platform. - Exclude version-control metadata, backup directories, and destination directories from recursive traversal.
- Require a backup or clean version-control checkpoint before a large restructuring operation.
- Report each proposed deletion and collision to the user and obtain explicit confirmation before making changes.
- Remove direct
