T09 · Insecure Skill Coding Practices
Error
- Location
- SKILL.md:723
- Finding
- Unvalidated Parent Directory Discovery Enables Recursive Deletion of Unrelated Data<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 723–757 **Vulnerability Type**: Unvalidated destructive file-system operation **Risk Level**: High ### Vulnerable Code ```powershell # Phase 1: Environment scan Write-Host "[Phase 1] Environment scan..." -ForegroundColor Yellow $installed = Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*" | Where-Object { $_.DisplayName -match "autocad|autodesk" } foreach ($app in $installed) { if ($app.InstallLocation -and (Test-Path $app.InstallLocation)) { $global:autodeskDirs += $app.InstallLocation $global:autodeskDirs += Split-Path $app.InstallLocation -Parent } } @("$env:SystemDrive\Autodesk","${env:ProgramFiles}\Autodesk","$env:ProgramData\Autodesk", "$env:LOCALAPPDATA\Autodesk","$env:APPDATA\Autodesk") | ForEach-Object { if (Test-Path $_) { $global:autodeskDirs += $_ } } # Phase 2: Terminate processes Write-Host "[Phase 2] Terminate processes..." -ForegroundColor Yellow $procs = Get-Process | Where-Object { $_.ProcessName -match "autocad|autodesk|fusion|eagle" } if (@($procs).Count -gt 0 -and (Confirm-Action "Terminate $($procs.Count) processes?")) { $procs | Stop-Process -Force } # Phase 3: Stop services Write-Host "[Phase 3] Stop services..." -ForegroundColor Yellow $services = Get-Service | Where-Object { $_.DisplayName -match "autodesk|autocad|adsv" } if (@($services).Count -gt 0 -and (Confirm-Action "Stop $($services.Count) services?")) { $services | Stop-Service -Force -ErrorAction SilentlyContinue } # Phase 4: Delete directories Write-Host "[Phase 4] Delete directories..." -ForegroundColor Yellow $toDelete = $global:autodeskDirs | Sort-Object -Unique | Where-Object { Test-Path $_ } if (@($toDelete).Count -gt 0 -and (Confirm-Action "Delete $($toDelete.Count) directories?")) { foreach ($dir in $toDelete) { try { Remove-Item $dir -Recurse -Force -ErrorAction Stop Write-Host " [OK] ...[truncated 2353 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Do not automatically add the parent of `InstallLocation` to the deletion list. 2. Canonicalize every path with a trusted path-resolution API before evaluating or deleting it. 3. Maintain an explicit allowlist of Autodesk-owned roots and require each deletion target to be a descendant of an approved root. 4. Explicitly reject drive roots, user-profile roots, `Program Files`, `Program Files (x86)`, `ProgramData`, Windows directories, and other shared locations. 5. Validate directory ownership using multiple signals rather than relying only on a registry display-name match. 6. Detect and reject symbolic links, junctions, mount points, and other reparse points that could redirect recursive deletion. 7. Present every canonical path—not only the number of paths—for explicit confirmation. 8. Add a dry-run mode and create a deletion log before making changes. 9. Abort on validation errors rather than globally suppressing errors. 10. Prefer the vendor's supported uninstaller and remove only known residual directories afterward. ]]>
