Back to skill

Security audit

Windows 磁盘空间整理(CloudDrive 上云)

Security checks for vulnerabilities and agentic risk

Overview

The skill is a mostly transparent Windows disk-cleanup and cloud-backup workflow, but it deserves review because its helpers can perform broad cloud writes and raw CloudDrive API calls without hard technical scoping.

Install only if you are comfortable letting the agent inspect large parts of your Windows drives, prepare file manifests, upload selected files to CloudDrive2, and later guide deletion of local copies. Before any upload or deletion, require a visible dry-run table, verify the destination root, check for overwrites, keep CD2_URL on the local CloudDrive endpoint, and do not provide CD2_TOKEN unless you trust the current session.

Vulnerability Patterns
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (1)

T09 · Insecure Skill Coding Practices

Warning
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 in scripts/common.ps1:43-48
Vulnerability Type: Unconfirmed destructive write / destination overwrite
Risk Level: Medium

Relevant 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.ps1 only 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-controlled src, dst, type, and filter values flow directly into robocopy.

If matching files already exist at the selected CloudDrive ...[truncated 1610 chars]

Remediation
View remediation

Remediation Suggestions

  1. Add a mandatory dry-run mode that enumerates every planned source-to-destination mapping and all existing destination collisions without writing data.
  2. 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.
  3. Make collision handling fail closed by default. Abort when a destination exists unless the user separately approves overwrite behavior.
  4. Validate that destination paths are under the user-approved CloudDrive root before invoking robocopy.
  5. Record the approved destination root, manifest hash, collision policy, and approval result in the operation log.
  6. Return a failing exit status when robocopy reports an error instead of only logging the condition.
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Taint TrackingDirect Taint Flow, Variable-Mediated Taint Flow, Credential Exfiltration Chain
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
Findings (16)

Tainted flow: 'req' from os.environ.get (line 69, credential/environment) → urllib.request.urlopen (network output)

Critical
Category
Data Flow
Confidence
90% confidence
Finding

Credentials or environment variables flow to a network sink. This is a high-confidence indicator of credential exfiltration.

Content

Scanner excerpt · scripts/cd2.py (reported line 73)May include surrounding context.

python
'Content-Type': 'application/grpc-web+proto', 'X-Grpc-Web': '1',
        'Authorization': 'Bearer ' + os.environ.get('CD2_TOKEN', '')})
    try:
        resp = urllib.request.urlopen(req, timeout=30)
    except urllib.error.HTTPError as e:
        print('HTTP', e.code, dict(e.headers)); return
    raw = resp.read()

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

The finding indicates the implementation can act as a generic CloudDrive2 API client rather than a narrowly constrained cleanup workflow. That is dangerous because arbitrary API invocation against a local authenticated service can expose additional actions, metadata access, or state changes outside the advertised upload/verify flow, undermining user trust and least-privilege assumptions.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding

The finding indicates the implementation can act as a generic CloudDrive2 API client rather than a narrowly constrained cleanup workflow. That is dangerous because arbitrary API invocation against a local authenticated service can expose additional actions, metadata access, or state changes outside the advertised upload/verify flow, undermining user trust and least-privilege assumptions.

Content

No source excerpt is available for this finding.

Hidden Instructions

High
Category
Prompt Injection
Confidence
60% confidence
Finding

Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Content

Scanner excerpt · scripts/common.ps1 (reported line 1)May include surrounding context.

text
# 只校验不上传:中断后、换网回来后、或删本地前再确认一遍
param([Parameter(Mandatory = $true)][string]$Manifest)
. (Join-Path $PSScriptRoot 'common.ps1')

Hidden Instructions

High
Category
Prompt Injection
Confidence
60% confidence
Finding

Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Content

Scanner excerpt · scripts/reorg-lib.ps1 (reported line 1)May include surrounding context.

text
# 只校验不上传:中断后、换网回来后、或删本地前再确认一遍
param([Parameter(Mandatory = $true)][string]$Manifest)
. (Join-Path $PSScriptRoot 'common.ps1')

Hidden Instructions

High
Category
Prompt Injection
Confidence
60% confidence
Finding

Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Content

Scanner excerpt · scripts/upload.ps1 (reported line 1)May include surrounding context.

text
# 只校验不上传:中断后、换网回来后、或删本地前再确认一遍
param([Parameter(Mandatory = $true)][string]$Manifest)
. (Join-Path $PSScriptRoot 'common.ps1')

Hidden Instructions

High
Category
Prompt Injection
Confidence
60% confidence
Finding

Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Content

Scanner excerpt · scripts/verify.ps1 (reported line 1)May include surrounding context.

text
# 只校验不上传:中断后、换网回来后、或删本地前再确认一遍
param([Parameter(Mandatory = $true)][string]$Manifest)
. (Join-Path $PSScriptRoot 'common.ps1')

Rp1

Medium
Category
MCP Rug Pull
Confidence
90% confidence
Finding

The README instructs users to run npx clawhub install pc-space-cleanup without pinning a specific package version. This creates a supply-chain risk: users may fetch a newer or compromised package version at install time, and because npx executes retrieved package code, a malicious or hijacked release could run immediately on the user's machine.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The trigger phrase C 盘满了,清一下 is broad and maps to a common everyday request, which increases the chance the skill is invoked unintentionally in normal conversation. In this skill's context, accidental invocation is more concerning because the workflow can progress from disk inspection to file packaging, cloud upload, and eventual local deletion after confirmations, so an overly permissive trigger expands the attack surface for unintended destructive or privacy-impacting actions.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
90% confidence
Finding

The skill describes operations that use environment variables, local API access, and network-connected cloud storage, but it declares no explicit tool scope or permission boundaries. In a skill that can inspect disks, upload data, and delete local files, missing scope declarations increases the chance of overbroad execution or accidental invocation with capabilities beyond what the user expects.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The trigger phrases include broad everyday expressions such as '整理空间' or '清理磁盘', which can cause the skill to activate in contexts where the user did not intend a workflow involving disk inspection, cloud uploads, or irreversible deletion. Because this skill includes destructive guidance and handling of sensitive local files, accidental triggering raises the risk of unintended data exposure or deletion steps being proposed or initiated.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
82% confidence
Finding

文件在描述和全文中默认以中文作为唯一交互与文案语言,且未说明可根据用户偏好切换语言,也未声明这是仅面向特定中文区域用户的专用技能。按规则,这类自然语言层面的语言约束若无用户选择或明确正当化,应视为政策问题。

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The comment states the script 'contains Chinese' and all user-facing errors/log messages in the file are written in Chinese, which effectively forces a specific language for operators. The file does not indicate any language choice, opt-in, or documented regional justification for this locale constraint.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
98% confidence
Finding

The script prints status and error messages using Chinese text literals ("条", "顶层", "读取失败"). For a general-purpose utility, forcing a specific language in user-facing output without opt-in or documented locale scope is a natural-language policy violation under the language/locale rule.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
98% confidence
Finding

The script's user-facing comments and log messages are written only in Chinese, which imposes a specific language on users. The file does not indicate that this is a region-specific tool or provide any opt-in or alternative locale, so it constitutes a natural-language policy concern.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
93% confidence
Finding

Line L02 states in natural language that the content is Chinese and must be saved with BOM UTF-8, which imposes a specific language/locale constraint. The file does not offer any user choice or explain a region-specific requirement that would justify forcing this locale-related behavior.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.