T09 · Insecure Skill Coding Practices
- Location
SKILL.md:119- Finding
Predictable Recursive Workspace Deletion
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, line 119
Vulnerability Type: Unsafe temporary workspace cleanup
Risk Level: MediumVulnerable Code
markdown - Clean up `tmp_llm_research` only after the final Markdown report has been successfully written, to avoid affecting the final aggregation.The associated cleanup instruction also appears at line 104:
markdown After the final report is successfully written, delete the entire `tmp_llm_research` folder.Technical Analysis
The skill directs the agent to recursively delete a fixed, relative directory named
tmp_llm_research. It does not require the directory to be uniquely created for the current execution, verify its resolved path, reject symbolic links, establish ownership with a marker, or restrict deletion to files generated during the current run.Because the directory name is predictable and interpreted relative to the execution environment, it may already contain unrelated user data. An attacker with write access to the working directory could also prepare this path or influence where it resolves before the skill runs. Once report generation succeeds, the cleanup step may recursively remove content that the skill did not create.
This is an unsafe temporary-file and cleanup practice rather than evidence of deliberate malicious behavior.
Attack Path
- The victim runs the skill in a directory where
tmp_llm_researchalready exists, or an attacker with local write access prepares that predictable path. - The existing directory contains unrelated files or is arranged to resolve to content outside the intended per-run workspace.
- The skill processes entries and successfully writes its final report.
- The cleanup instruction is triggered.
- The agent recursively deletes the entire
tmp_llm_researchdirectory rather than deleting only artifacts created during the current run.
Impact Assessment
Successful exploitation can cause deletion of files av ...[truncated 366 chars]
- The victim runs the skill in a directory where
- Remediation
View remediation
Remediation Suggestions
- Create a unique workspace for every run using a secure temporary-directory facility rather than the fixed
tmp_llm_researchname. - Store the workspace's canonical absolute path immediately after creation.
- Create an ownership marker containing a random run identifier and require that marker to match before cleanup.
- Before deletion, resolve the path and verify that it remains beneath an explicitly approved temporary root.
- Reject symbolic links and refuse cleanup if the workspace path, any relevant parent, or the ownership marker has changed unexpectedly.
- Track generated artifacts and delete only those files where possible instead of recursively deleting an entire directory.
- Use cleanup APIs that do not follow symbolic links and operate on trusted directory handles where the platform supports them.
- If any validation fails, preserve the directory and report a cleanup warning rather than attempting deletion.
- Update both cleanup directives in
SKILL.mdso the workflow consistently applies these safeguards.
- Create a unique workspace for every run using a secure temporary-directory facility rather than the fixed
