T09 · Insecure Skill Coding Practices
- Location
SKILL.md:63- Finding
Unsafe Destructive File and Process Management Commands
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 63, 119, 299, 352, and 362
Vulnerability Type: Unsafe destructive shell command guidance
Risk Level: HighVulnerable Code
SKILL.md:63bash rm -rf directory/ # Delete directorySKILL.md:119bash kill -9 PID # Force terminationSKILL.md:299bash find . -name "*.log" | xargs rm # Batch deletionSKILL.md:352bash kill -9 $(lsof -t -i:8080)SKILL.md:362bash sudo rm -rf /var/log/*.logTechnical Analysis
The Skill provides destructive shell commands without adequate validation, scoping, preview, confirmation, or error handling:
rm -rf directory/recursively removes a target without confirmation. If the path is incorrect, empty after variable substitution in generated variants, or unexpectedly resolved, the command can cause extensive data loss.find . -name "*.log" | xargs rmdoes not use null-delimited filenames or an option terminator. Filenames containing whitespace, newlines, or leading hyphens can be parsed incorrectly. A leading-hyphen filename may be interpreted as anrmoption.sudo rm -rf /var/log/*.logperforms privileged wildcard deletion of system logs. This can remove active diagnostic or security records, interfere with services, and destroy evidence needed for incident investigation.kill -9immediately terminates processes without allowing graceful shutdown, cleanup, lock release, or state persistence.kill -9 $(lsof -t -i:8080)does not explicitly validate that the returned values are expected numeric process identifiers belonging to the intended application. It can terminate multiple processes associated with the port and may disrupt unrelated services.
These commands are presented as reusable operational guidance and may therefore be copied directly or reproduced by an agent in ge ...[truncated 2516 chars]
- Remediation
View remediation
Remediation Suggestions
-
Replace broad recursive deletion examples with scoped, defensive alternatives. Require users to inspect the target before deletion:
bash target="/expected/path/directory" printf 'Target: %s\n' "$target" find "$target" -maxdepth 1 -print rm -rI -- "$target" -
Use null-delimited pathname handling and an explicit option terminator for batch operations:
bash find . -type f -name '*.log' -print0 | xargs -0 --no-run-if-empty rm --Alternatively:
bash find . -type f -name '*.log' -exec rm -- {} +Add a preview stage using
-printbefore recommending deletion. -
Do not recommend deleting system logs using
sudo rm -rf. Use the system's log-management facilities, such aslogrotateor bounded journal cleanup:bash sudo journalctl --vacuum-time=7dAny cleanup guidance should preserve active logs, comply with retention requirements, and identify the exact files affected before modification.
-
Prefer graceful process termination and verify process identity before escalation:
bash pids=$(lsof -t -iTCP:8080 -sTCP:LISTEN) if [ -n "$pids" ]; then ps -fp $pids kill $pids fiRecommend
SIGKILLonly as a final recovery step after graceful termination fails and the operator verifies each PID. -
Add explicit safeguards to generated scripts, including:
- Quoted path and variable expansions.
- Nonempty and expected-prefix checks for paths.
- Numeric validation for process identifiers.
- Dry-run or preview modes.
- Interactive confirmation for destructive operations.
- Least-privilege execution.
- Backups or recovery instructions before deletion.
-
