T09 · Insecure Skill Coding Practices
- Location
scripts/common.ps1:43- Finding
Cloud destination writes can bypass the documented confirmation requirement
- Content
View full analysis
Vulnerability Details
File Location:
scripts/upload.ps1:2-12, with the write operation implemented inscripts/common.ps1:43-48
Vulnerability Type: Unconfirmed destructive write / destination overwrite
Risk Level: MediumRelevant Code
powershell # scripts/upload.ps1:2-12 param([Parameter(Mandatory = $true)][string]$Manifest) . (Join-Path $PSScriptRoot 'common.ps1') if (-not $env:CD2_TOKEN) { throw 'CD2_TOKEN is required' } $m = Read-Manifest $Manifest Log ("===== Upload started, manifest {0}, free space {1:N2}GB =====" -f $Manifest, ((Get-PSDrive C).Free / 1GB)) foreach ($b in $m.batches) { $files = @(foreach ($it in $b.items) { Expand-Item $it }) Log ("[{0}] Copying to cache: {1} files, {2:N2}GB" -f $b.name, $files.Count, (($files | Measure-Object Len -Sum).Sum / 1GB)) $sw = [Diagnostics.Stopwatch]::StartNew() foreach ($it in $b.items) { Copy-Item2Z $it } }powershell # scripts/common.ps1:43-48 function Copy-Item2Z($it) { switch ($it.type) { 'dir' { robocopy $it.src $it.dst /E /COPY:DAT /DCOPY:T /R:3 /W:10 /NP /NFL /NDL /NJH /NJS /XF $XF /XD $XD | Out-Null } 'file' { robocopy (Split-Path $it.src) $it.dst (Split-Path $it.src -Leaf) /COPY:DAT /R:3 /W:10 /NP /NFL /NDL /NJH /NJS | Out-Null } 'files' { robocopy $it.src $it.dst $it.filter /COPY:DAT /R:3 /W:10 /NP /NFL /NDL /NJH /NJS | Out-Null } } }Technical Analysis
The Skill documentation states that write operations must first be presented as a dry-run table and approved by the user. The executable upload path does not enforce that control.
upload.ps1only requires a manifest path and a CloudDrive API token. It does not require a dry-run flag, confirmation token, approved manifest hash, or interactive acknowledgement. Manifest-controlledsrc,dst,type, andfiltervalues flow directly intorobocopy.If matching files already exist at the selected CloudDrive ...[truncated 1610 chars]
- Remediation
View remediation
Remediation Suggestions
- Add a mandatory dry-run mode that enumerates every planned source-to-destination mapping and all existing destination collisions without writing data.
- Require a separate explicit confirmation parameter for the write phase. Bind confirmation to a cryptographic hash of the reviewed manifest so that the manifest cannot be changed after approval.
- Make collision handling fail closed by default. Abort when a destination exists unless the user separately approves overwrite behavior.
- Validate that destination paths are under the user-approved CloudDrive root before invoking
robocopy. - Record the approved destination root, manifest hash, collision policy, and approval result in the operation log.
- Return a failing exit status when
robocopyreports an error instead of only logging the condition.
