Back to skill

Security audit

文件整理

Security checks for vulnerabilities and agentic risk

Overview

This is a coherent file-organizing skill, but it can move Desktop and Downloads files and may overwrite same-name files despite claiming collisions are safe.

Install only if you are comfortable with a skill that can move files in Desktop and Downloads. Use dry-run first, review the proposed moves, and avoid non-preview execution until the implementation has an explicit same-name collision policy such as skip, rename, or ask before replacing.

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
SKILL.md:76
Finding

Destination Filename Collision May Cause Existing File Overwrite

Content
View full analysis

Vulnerability Details

File Location: SKILL.md, lines 76–85
Vulnerability Type: Unsafe file move and destination collision handling
Risk Level: Medium

python
if category:
    cat_dir = os.path.join(target, f"_{category}")
    if not dry_run:
        os.makedirs(cat_dir, exist_ok=True)
        try:
            shutil.move(fpath, os.path.join(cat_dir, fname))
            report["organized"] += 1
            report["by_category"][category] = report["by_category"].get(category, 0) + 1
        except (shutil.Error, PermissionError) as e:
            report["errors"].append(f"移动失败: {fname} -> {e}")

Technical Analysis

The code moves each classified file to a destination derived directly from its original filename without first checking whether that destination already exists. The accompanying safety documentation claims that shutil.move always raises an error on a same-name conflict and preserves the existing file, but this behavior is not portable.

Depending on the operating system, filesystem, and move implementation selected by Python, the underlying rename operation may replace an existing destination file. In particular, a same-filesystem rename can overwrite the destination on platforms where that behavior is supported. Consequently, the implementation does not enforce its stated no-overwrite guarantee.

The try block does not prevent this condition because an overwrite can succeed without raising shutil.Error or PermissionError. The code also omits an explicit collision policy, unique-name generation, backup creation, and atomic no-replace semantics.

Attack Path

  1. A file such as Downloads/report.pdf exists and is selected for classification.
  2. The destination directory Downloads/_Documents already contains a different file named report.pdf.
  3. The user invokes organize(dry_run=False).
  4. The code constructs Downloads/_Documents/report.pdf as the destination w ...[truncated 941 chars]
Remediation
View remediation

Remediation Suggestions

  • Construct the destination path before moving and explicitly test it with os.path.lexists(destination).
  • Adopt a documented collision policy: skip the source file, generate a unique destination filename, or require explicit user confirmation before replacement.
  • Prefer atomic no-replace filesystem operations where supported to avoid a time-of-check/time-of-use race between the existence check and move.
  • If unique names are generated, use deterministic suffixes such as report (1).pdf and repeat the check until an unused path is reserved safely.
  • Catch relevant OSError subclasses and report collisions separately from permission or filesystem failures.
  • Do not count a file as organized unless the move completes under the selected collision policy.
  • Update the safety documentation so it does not claim that shutil.move universally preserves existing destination files.
  • Add tests covering same-name collisions on every supported operating system and filesystem.
Vulnerability Patterns
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (2)

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The activation phrases are extremely generic ('整理 / 文件整理 / 归类'), especially '整理' and '归类', which can appear in ordinary conversation and may trigger the skill unintentionally. Because this skill performs filesystem reorganization and can move files out of Desktop and Downloads, accidental invocation could cause unexpected bulk file movement and user disruption even though it does not delete data.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
84% confidence
Finding

The natural-language content consistently uses Chinese for the description, trigger text, usage notes, and safety guidance, but does not indicate that this language choice is optional or region-specific. Under the stated policy, forcing a specific language without user opt-in can be a locale-policy issue.

Content

No source excerpt is available for this finding.