Back to skill

Security audit

C Disk Cleanup

Security checks for vulnerabilities and agentic risk

Overview

This is a local Windows C-drive cleanup helper, but it needs Review because its cleanup powers are broader and less safely scoped than its “only move, never delete” promise.

Install only if you are comfortable reviewing each proposed cleanup item and declining advanced options. Do not run Program Files compression, DISM, CompactOS, cleanmgr automation, recycle-bin cleanup, or folder junction moves unless you understand the impact, have backups, and can restore the affected files. Prefer using the read-only scan first, and require exact source and destination paths before approving any move.

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 (4)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/safe_ops.ps1:45
Finding
Arbitrary Unmatched Paths Are Approved for Relocation by Default## Vulnerability Details **File Location**: `scripts/safe_ops.ps1`, lines 45-64 **Vulnerability Type**: Fail-open path validation **Risk Level**: High ```powershell # AppData main program directories are blocked $progPatterns = @('office6','\WPS Office\','\Kingsoft\','\JianyingPro\','\Microsoft\Office','\Adobe\','\JetBrains\') # Cache and temporary directory characteristics that are explicitly allowed $allow = @('Temp','*Cache','*cache','*-updater','pip','npm','node_modules','临时') # User-file paths that are allowed when confirmed $userPatterns = @('\Desktop','\Downloads','\Documents','桌面','下载','文档','Pictures','图片','Videos','视频','Music','音乐') foreach($pat in $imPatterns){ if($norm -like "*$pat*"){ return @{Ok=$false; Reason="Blocked chat or encrypted database path."} } } foreach($pat in $progPatterns){ if($norm -like "*$pat*"){ return @{Ok=$false; Reason="Blocked application program directory."} } } $name = Split-Path $norm -Leaf foreach($a in $allow){ if($name -like $a){ return @{Ok=$true; Reason=""} } } foreach($u in $userPatterns){ if($norm -like "*$u*"){ return @{Ok=$true; Reason="Confirmed user-file relocation."} } } # All other paths are allowed by default return @{Ok=$true; Reason=""} ``` ### Technical Analysis `Test-SafeToMove` implements a denylist rather than a strict allowlist. Although it blocks several known instant-messaging and application paths, every path that does not match those limited patterns reaches the final successful return value. Consequently, the safety check does not establish that the supplied path is a cache, temporary directory, or approved personal directory. An arbitrary directory accessible to the invoking user can be passed to `MoveToBackup` or `SendToRecycle`. The `-Confirmed` switch proves only that the operation was enabled; it does not make the selected path safe. The function also performs string-based matching before canonical path validation. It does not establish that ...[truncated 1348 chars]
Remediation
## Remediation Suggestions - Change the final result of `Test-SafeToMove` to a denial. - Maintain an explicit allowlist of narrowly defined cache and temporary roots. - Resolve the path with `Resolve-Path` before authorization and compare the canonical path against approved roots. - Reject path traversal, device paths, alternate data streams, symbolic links, junctions, and other reparse points unless specifically supported and validated. - Separate cache operations from personal-file relocation so each action has purpose-specific validation. - Require a fresh, path-specific confirmation that displays the canonical source and destination. - Add tests proving that unknown application, system, profile, and junction-backed paths are rejected.

T09 · Insecure Skill Coding Practices

Error
Location
scripts/safe_ops.ps1:89
Finding
Detected Active Processes Do Not Block Confirmed File Moves## Vulnerability Details **File Location**: `scripts/safe_ops.ps1`, lines 89-94 **Vulnerability Type**: Safety-check bypass through confirmation-state reuse **Risk Level**: High ```powershell if($locks.Count -gt 0){ Write-Host ("[Warning] Potentially related processes are running: $($locks -join ', '). Close them before moving data to avoid a partial move.") -ForegroundColor Yellow if(-not $Confirmed){ Write-Host "Simulation mode: close the processes and rerun with confirmation." -ForegroundColor Yellow exit 0 } } ``` ### Technical Analysis The process-lock check reports related running processes but aborts only when the command is in simulation mode. When `-Confirmed` is present, execution falls through to the relocation logic even though the risk condition remains true. Confirmation of a requested move is incorrectly treated as authorization to bypass an independent integrity invariant. A user can consent to moving a directory without consenting to a partial move while its application is active. The subsequent relocation operates one child at a time. Locked children can remain at the source while unlocked children move to the backup drive, creating precisely the split state the warning claims to prevent. ### Attack Path 1. Keep an application open so that one or more files in the target directory are locked. 2. Invoke `MoveToBackup` with `-Confirmed`. 3. `Test-ProcessLock` returns one or more process names. 4. The script prints a warning but does not exit because confirmation is already present. 5. The child-by-child move begins. 6. Unlocked files move to the backup drive while locked files are skipped. 7. The application or data directory is split between the original and backup locations. ### Impact Assessment This flaw does not grant additional operating-system privileges. It can nevertheless corrupt application installations, caches, profiles, or local data available t ...[truncated 218 chars]
Remediation
## Remediation Suggestions - Abort unconditionally when a relevant process is detected. - Ask the user to close the identified process, then repeat the lock check before any move. - Do not allow the general `-Confirmed` switch to override lock or integrity failures. - Perform a preflight accessibility check for every source item before modifying any of them. - Use a transactional copy-verify-remove design rather than independent destructive moves. - If any item cannot be copied and verified, leave the entire source intact and report the failure. - Recheck for newly opened handles immediately before committing the operation.

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/safe_ops.ps1:95
Finding
Shared Backup Destination and Forced Moves Create Data-Collision Risk## Vulnerability Details **File Location**: `scripts/safe_ops.ps1`, lines 95-111 **Vulnerability Type**: Non-unique backup path and unsafe destination collision handling **Risk Level**: Medium ```powershell $dst = "$($BackupDrive):\C盘整理\备份_$(Get-Date -Format yyyyMMdd)" Write-Host ("Source: {0}" -f $Path) Write-Host ("Destination: {0}" -f $dst) if($Confirmed){ New-Item -ItemType Directory -Path $dst -Force | Out-Null $items = Get-ChildItem $Path -ErrorAction SilentlyContinue $ok=0; $skip=0 foreach($it in $items){ try{ Move-Item -Path $it.FullName -Destination "$dst\$($it.Name)" -Force -ErrorAction Stop $ok++ }catch{ Write-Host ("Skipped item after move failure: {0}" -f $_.Exception.Message) -ForegroundColor Yellow $skip++ } } } ``` ### Technical Analysis Every move performed on the same date and backup drive uses the same directory. The destination preserves only each immediate child's name and does not preserve the canonical source hierarchy. If two source directories contain children with the same name, both operations target the same destination path. The use of `-Force` does not provide safe versioning, collision refusal, checksums, or transactional rollback. Depending on the item type and existing destination state, this can replace content, merge directories, or fail after earlier items have already moved. The backup therefore cannot reliably serve as a reversible representation of multiple source paths. ### Attack Path 1. Move a source directory containing an item named `Cache`, `data`, or another common name. 2. On the same day, move a second source directory containing a child with the same name. 3. Both operations resolve to the same dated backup directory. 4. Both children resolve to the same destination path because the source hierarchy is discarded. 5. The second forced move collides with t ...[truncated 442 chars]
Remediation
## Remediation Suggestions - Create a unique transaction directory for every operation using a timestamp with seconds and a cryptographically random identifier. - Preserve the complete canonical source hierarchy beneath the transaction directory. - Refuse to proceed when any destination path already exists. - Never rely on `-Force` for backup collision handling. - Copy each item first, verify its size and cryptographic hash, and only then remove the source. - Write a machine-readable manifest containing source paths, destination paths, hashes, timestamps, and operation status. - Implement rollback when any item in a batch fails. - Limit each transaction to a clearly identified source root and provide a deterministic restore command.

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/safe_ops.ps1:117
Finding
Windows Cleanup Executes an Unverified Preconfigured Profile## Vulnerability Details **File Location**: `scripts/safe_ops.ps1`, lines 117-123 **Vulnerability Type**: Execution of uncontrolled local cleanup configuration **Risk Level**: Medium ```powershell "WindowsClean" { Write-Host "Windows Disk Cleanup will run for system temporary files, Recycle Bin content, and update caches." if($Confirmed){ Start-Process -FilePath "cleanmgr.exe" -ArgumentList "/sagerun:1" -Wait -ErrorAction SilentlyContinue Write-Host "Disk Cleanup completed." } } ``` ### Technical Analysis `cleanmgr.exe /sagerun:1` executes the cleanup categories stored in Windows cleanup profile 1. The Skill neither creates a dedicated profile nor inspects and displays the categories currently configured for that identifier. As a result, the actual behavior is controlled by preexisting machine state rather than the categories shown by the Skill. Profile 1 may have been configured previously by the user, an administrator, another utility, or another script. Generic confirmation for `WindowsClean` is therefore not necessarily informed consent for every category that `cleanmgr` will process. Because Disk Cleanup deletes selected material rather than moving it into the Skill's backup directory, this action also bypasses the Skill's general recoverability model. ### Attack Path 1. Cleanup profile 1 is configured with broader categories than those represented by the Skill. 2. The user approves the generic `WindowsClean` action based on the displayed description. 3. The script invokes `cleanmgr.exe /sagerun:1`. 4. Windows executes every category stored in profile 1. 5. Content outside the user's expected selection may be deleted. ### Impact Assessment The command runs with the privileges and cleanup capabilities available to the invoking process. It does not itself establish privilege escalation. The affected scope includes all cleanup categories enabled in profile 1, potentially inclu ...[truncated 155 chars]
Remediation
## Remediation Suggestions - Do not execute a shared numeric `sagerun` profile without inspecting it. - Prefer launching the interactive Windows cleanup interface so the user can review and confirm exact categories. - If unattended execution is required, create a dedicated profile identifier and explicitly configure only documented categories. - Display the exact category list and deletion consequences immediately before execution. - Require separate confirmation for irreversible categories such as Recycle Bin cleanup. - Record the selected categories and command result in an operation log. - Treat cleanup-process failure as an error instead of suppressing it with `SilentlyContinue`. - Clearly distinguish permanent Windows cleanup from reversible backup-drive relocation.
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (15)

Description-Behavior Mismatch

High
Confidence
97% confidence
Finding
The workflow instructs applying NTFS compression directly to Program Files subtrees, which contradicts the skill’s stated safety model that software main program directories must not be touched. Even though NTFS compression is a legitimate Windows feature, changing executable/library storage in place can degrade performance, interact badly with updaters or locked files, and cause user-visible breakage if applied broadly by an automation agent.

Description-Behavior Mismatch

High
Confidence
97% confidence
Finding
The workflow includes DISM component cleanup and CompactOS operations, which are system-level modifications rather than the advertised 'only move, never delete' reversible cleanup model. These commands can alter servicing state, reduce rollback flexibility, require elevation, and create a much higher-risk execution path than a novice-friendly disk cleanup assistant suggests.

Description-Behavior Mismatch

High
Confidence
95% confidence
Finding
The script exposes a deletion-capable path via SendToRecycle, which contradicts the skill's stated safety contract of only moving files and never deleting them. Although sending to Recycle Bin is reversible and gated by -Confirmed, it still performs a destructive state change and could mislead users or higher-level agents that rely on the documented guarantee.

Hidden Instructions

High
Category
Prompt Injection
Content
# scan_cdrive.ps1 - C 盘只读体检(不修改任何文件)
# 用法: powershell -ExecutionPolicy Bypass -File scan_cdrive.ps1
# 输出一份给小白看的体检报告:C盘空间 + 占空间大户 + 可清理候选菜单
Confidence
60% confidence
Finding
Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Hidden Instructions

High
Category
Prompt Injection
Content
# scan_cdrive.ps1 - C 盘只读体检(不修改任何文件)
# 用法: powershell -ExecutionPolicy Bypass -File scan_cdrive.ps1
# 输出一份给小白看的体检报告:C盘空间 + 占空间大户 + 可清理候选菜单
Confidence
60% confidence
Finding
Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Hidden Instructions

High
Category
Prompt Injection
Content
# scan_cdrive.ps1 - C 盘只读体检(不修改任何文件)
# 用法: powershell -ExecutionPolicy Bypass -File scan_cdrive.ps1
# 输出一份给小白看的体检报告:C盘空间 + 占空间大户 + 可清理候选菜单
Confidence
60% confidence
Finding
Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Vague Triggers

Medium
Confidence
96% confidence
Finding
The skill declares several broad, everyday trigger phrases such as “电脑卡” and general disk-cleanup requests that could match normal troubleshooting conversations and invoke the skill unintentionally. Because this skill can lead to filesystem operations and scheduled maintenance behavior, accidental activation increases the chance of confusing users, collecting disk inventory without clear intent, or steering them into cleanup flows they did not explicitly request.

Vague Triggers

Medium
Confidence
92% confidence
Finding
The trigger phrases include very broad everyday terms such as '腾空间' and especially '电脑卡', which can match many unrelated user situations outside the intended C-drive cleanup scope. This can cause unintended activation of a filesystem-affecting skill, increasing the chance of confusing users into launching disk operations when they were only asking for general troubleshooting.

Natural-Language Policy Violations

Medium
Confidence
93% confidence
Finding
This markdown file is natural-language guidance, and all operational instructions are presented only in Chinese. Under the policy rule, forcing a specific language without user opt-in or a documented regional justification is a language/locale policy violation.

Intent-Code Divergence

Medium
Confidence
95% confidence
Finding
The documentation asserts a strict 'only move, never delete' model, but later prescribes in-place compression and system cleanup commands that do not fit that promise. This mismatch is dangerous because it undermines user consent and agent safety assumptions: an operator may approve the skill believing it only relocates recoverable files, while it actually performs non-equivalent system modifications.

Natural-Language Policy Violations

Medium
Confidence
96% confidence
Finding
All user-facing comments, usage examples, warnings, and runtime messages in the script are written in Chinese, and there is no indication that the skill is intentionally region-specific or that users may choose another language. This can violate a language/locale policy when used in broader environments where English or user-selected locale is required.

Description-Behavior Mismatch

Medium
Confidence
88% confidence
Finding
WindowsClean delegates cleanup decisions to cleanmgr.exe /sagerun:1, which can delete files outside the script's per-item explanatory and approval workflow. In the context of a skill that promises user-by-user consent and reversible 'move not delete' behavior, this creates a control bypass where actual deletions may occur without equivalent transparency.

Natural-Language Policy Violations

Medium
Confidence
95% confidence
Finding
This is a natural-language policy issue because the script's user-facing comments and output force a specific language/locale. The file does not indicate that Chinese is optional, user-selected, or justified as a region-specific tool.

Natural-Language Policy Violations

Medium
Confidence
86% confidence
Finding
The checklist explicitly says the skill should be '全中文' and frames that as a compliance requirement. This is a natural-language locale policy constraint, but the document does not offer a user language choice or clearly limit the skill to a region-specific audience where Chinese-only behavior is justified.

Natural-Language Policy Violations

Medium
Confidence
90% confidence
Finding
The entire skill-facing promotional copy and the example invocation are written only in Chinese, with no indication that other languages are supported or that the Chinese-only constraint is optional. Under the policy, language or locale constraints should either be user-selectable or explicitly justified as region-specific.

Static analysis

No suspicious patterns detected.