T09 · Insecure Skill Coding Practices
- Location
SKILL.md:178- Finding
Desktop-Wide Wildcard Cleanup Can Delete Unrelated User Files
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 178-184
Vulnerability Type: Excessively broad and destructive file cleanup
Risk Level: HighVulnerable Code
powershell ### Step 8: Clean temporary files After completing the paper, **delete all temporary script files**: - Search scripts (`search_*.ps1`) - Download scripts (`download_*.ps1`) - Figure-generation scripts (`generate_*.py`) - Other intermediate files ```powershell Remove-Item "$env:USERPROFILE\Desktop\*.ps1" -Force Remove-Item "$env:USERPROFILE\Desktop\*.py" -Force Remove-Item "$env:USERPROFILE\Desktop\*_v*.pptx" -Forcetext ### Technical Analysis The cleanup commands apply wildcard deletion to the user's entire Desktop rather than to a dedicated workspace or an explicit list of files generated by the Skill. The patterns `*.ps1` and `*.py` match every PowerShell and Python script on the Desktop, while `*_v*.pptx` may match unrelated presentations. The commands also use `-Force`, suppressing protections that might otherwise prevent deletion of hidden or read-only matching files. No ownership check, generated-file manifest, path containment validation, confirmation prompt, or recovery mechanism is present. This violates least-destructive-operation principles. The Skill only needs to remove its own temporary files, but the documented operation affects files outside the paper output directory. ### Attack Path 1. A user has unrelated `.ps1`, `.py`, or matching `*_v*.pptx` files on their Desktop. 2. The user invokes the Auto Paper Writer Skill. 3. The Agent follows the workflow through Step 8. 4. The Agent executes the documented `Remove-Item` commands. 5. PowerShell expands the wildcards across the entire Desktop. 6. All matching files are forcibly deleted, including files that were not created by the Skill. No attacker-controlled input is required; ordinary execution of the documented workflow is sufficient to trigger the vulnerability. ### Impact Assessment The ...[truncated 550 chars]- Remediation
View remediation
Remediation Suggestions
- Create all temporary files inside a dedicated per-run workspace under the paper directory.
- Maintain an explicit manifest of files created during the current run.
- Delete only manifest entries instead of using Desktop-wide wildcard patterns.
- Resolve and validate every deletion target before removal, ensuring it remains inside the expected workspace.
- Reject path traversal and symbolic-link or reparse-point escapes.
- Remove
-Forceunless it is strictly required for a validated, Skill-owned file. - Prefer deleting the dedicated temporary directory after verifying its canonical path and ownership.
- Log the exact files selected for deletion and, where practical, request confirmation.
A safer PowerShell pattern would be:
powershell $tempDir = Join-Path $paper_dir ".auto-paper-writer-temp" $resolvedPaperDir = [System.IO.Path]::GetFullPath($paper_dir) $resolvedTempDir = [System.IO.Path]::GetFullPath($tempDir) if ( $resolvedTempDir.StartsWith( $resolvedPaperDir + [System.IO.Path]::DirectorySeparatorChar, [System.StringComparison]::OrdinalIgnoreCase ) -and (Test-Path -LiteralPath $resolvedTempDir -PathType Container) ) { Remove-Item -LiteralPath $resolvedTempDir -Recurse }The implementation should additionally ensure the temporary directory is not a symbolic link or reparse point before recursively deleting it.
