Back to skill

Security audit

Folder Organizer

Security checks for vulnerabilities and agentic risk

Overview

The skill is a coherent folder-organizing tool, but its execution script can perform unsafe local file changes beyond the documented safety boundaries.

Review before installing. Use this only on explicit, user-selected folders, keep reports in a dedicated output directory, inspect and validate every generated plan, avoid --apply until you have backups, and do not pass an existing important file as --log. Prefer sandbox mode and treat the Chinese-only interface as part of the package scope.

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

T09 · Insecure Skill Coding Practices

Error
Location
scripts/execute_plan.py:78
Finding

Caller-Controlled Log Path Allows Arbitrary File Deletion During Dry-Run

Content
View full analysis

Vulnerability Details

File Location: scripts/execute_plan.py, lines 78-81
Vulnerability Type: Arbitrary file deletion through an unrestricted log path
Risk Level: High

Vulnerable Code

python
plan = load_json(args.plan)
log_path = Path(args.log) if args.log else Path(f"organize-log_{now_iso().replace(':', '').replace('-', '')}.jsonl")
if log_path.exists():
    log_path.unlink()

Technical Analysis

The --log argument is fully controlled by the caller. If the selected path already exists, the executor unconditionally deletes it with Path.unlink().

The deletion occurs regardless of whether --apply was specified. Consequently, the documented dry-run mode is not read-only and can perform a destructive filesystem operation. The path is not constrained to the expected report directory, checked for an approved filename, or verified as an existing application-generated log.

After deletion, the program writes execution-log records to the same path. This may recreate the deleted file with unrelated JSONL data, resulting in destructive replacement rather than merely removing it.

Attack Path

  1. An attacker, unsafe automation, or misleading generated command supplies a writable, important file through --log.
  2. The user invokes execute_plan.py, even without the --apply option.
  3. The application sees that the selected path exists and calls unlink().
  4. The original file is deleted.
  5. The logging process may recreate the path and populate it with execution-log content.

Example invocation:

bash
python scripts/execute_plan.py --plan organize-plan.json --log /path/to/writable/important-file

Impact Assessment

The process can delete any existing file for which the current operating-system user has write permission. It does not provide privilege escalation beyond the privileges of the invoking process, but its scope includes user documents, application configur ...[truncated 259 chars]

Remediation
View remediation

Remediation Suggestions

  1. Never unconditionally delete a caller-selected log path.
  2. Create new logs using exclusive creation mode so an existing file causes a safe failure:
    python
    with log_path.open("x", encoding="utf-8") as handle:
        ...
    
  3. Generate collision-resistant log names rather than replacing existing files.
  4. Resolve the requested log path and require it to remain inside an explicitly approved report directory.
  5. If log replacement is required, introduce a separate explicit option such as --overwrite-log and display the resolved path before deletion.
  6. Verify that an existing path is a regular file previously created by this application before permitting replacement.
  7. Ensure dry-run mode performs no destructive filesystem operations. If reports are produced during dry-run, they should use new, non-conflicting output paths.
  8. Add automated tests confirming that existing files cannot be removed through --log, both with and without --apply.

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/execute_plan.py:77
Finding

Executor Trusts Unvalidated Plan Paths and Does Not Enforce Approved Root Boundaries

Content
View full analysis

Vulnerability Details

File Location: scripts/execute_plan.py, lines 77-84; filesystem operations at lines 18-49
Vulnerability Type: Missing mandatory plan validation and path containment enforcement
Risk Level: Medium

Vulnerable Code

The main execution path loads and executes the plan without invoking the available validator:

python
plan = load_json(args.plan)
log_path = Path(args.log) if args.log else Path(f"organize-log_{now_iso().replace(':', '').replace('-', '')}.jsonl")
if log_path.exists():
    log_path.unlink()

for item in plan.get("items", []):
    status, note = execute_item(item, args.apply, args.include_high_risk)

Plan-controlled paths are then used directly for filesystem operations:

python
def execute_item(item: dict, apply: bool, include_high_risk: bool) -> tuple[str, str]:
    action = item.get("action")
    source = Path(item["source"]) if item.get("source") else None
    target = Path(item["target"]) if item.get("target") else None

    if action in {"skip", "manual-review"}:
        return "skipped", "Skip or manual confirmation required"
    if item.get("risk") == "high" and not include_high_risk:
        return "skipped", "High-risk execution is not enabled"
    if action in {"create_dir", "create_sandbox"}:
        if not target:
            return "error", "Missing target path"
        if apply:
            target.mkdir(parents=True, exist_ok=True)
        return "created" if apply else "dry-run", "Create directory"
    if action in {"move", "rename", "copy", "archive", "backup"}:
        if not source or not target:
            return "error", "Missing source or target path"
        if not source.exists():
            return "error", "Source path does not exist"
        if target.exists():
            return "error", "Target path already exists"
        if apply:
            target.parent.mkdir(parents=True, exist_ok=True)
   
...[truncated 3022 chars]
Remediation
View remediation

Remediation Suggestions

  1. Integrate plan validation directly into execute_plan.py; do not rely on callers to run a separate command.
  2. Abort execution when validation produces any error or when the plan lacks verifiable validation metadata.
  3. Canonicalize the target root, source paths, and target paths using Path.resolve().
  4. Enforce containment using Path.is_relative_to() or an equivalent safe check:
    python
    approved_root = Path(plan["target_root"]).expanduser().resolve()
    resolved_target = target.expanduser().resolve()
    if not resolved_target.is_relative_to(approved_root):
        raise ValueError("Target path is outside the approved root")
    
  5. Define explicit approved source roots and enforce the same containment rules for source paths.
  6. Check path components and parent directories for symbolic-link escapes immediately before each operation.
  7. Do not trust the plan's risk or requires_confirmation values. Derive risk from the operation and resolved paths inside the executor.
  8. Require explicit confirmation for each high-risk operation or bind execution to a cryptographic hash of the exact reviewed plan.
  9. Reject plans whose target_root is missing, relative, a filesystem root, a system directory, or outside a user-approved location.
  10. Add tests covering absolute-path escapes, .. traversal, symbolic-link escapes, altered risk labels, execution without validation, and targets outside the approved root.
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
Findings (22)

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

声明的核心能力是“设计和文档化文件夹整理体系”,包括分类模型、命名规范、归档规则、目录说明等高层整理方案。实际代码仅执行一个较窄且不同的任务:扫描目录并识别重复文件候选,输出报告供人工确认。虽然两者都涉及文件系统扫描和 Markdown 输出,但重复文件检测并不等同于文件夹整理体系设计或增量归档支持,属于未声明且与主要目的明显不同的能力。因此应判定为描述与行为不匹配。

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
92% confidence
Finding

The skill clearly instructs use of scanning scripts and report generation that require file read/write capabilities, but it does not declare any tool scope or permissions boundaries. In practice this can cause the skill to run with broader ambient file access than reviewers or users expect, increasing the chance of unintended access to sensitive paths or unauthorized report writes.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
86% confidence
Finding

The activation scope is broad enough to match many ordinary file-management requests, which raises the chance the skill is invoked in contexts involving sensitive directories or destructive follow-on actions. In a filesystem-oriented skill, overbroad triggering is risky because even read-only scans can expose confidential metadata, and later steps include writes, moves, and logs after confirmation.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The text states that the default scheme uses 'number + English' directory names unless the user explicitly chooses Chinese names. This imposes a language preference by default rather than offering a neutral language/locale choice or opt-in.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The display name, description, and default prompt are all written in Chinese, with no indication that the user can choose another language or locale. This may violate language-choice policy because it implicitly constrains the interaction language without documented opt-in or justification.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill enables implicit invocation without any visible trigger constraints, scoping rules, or confirmation requirements. Because this skill is designed to scan, analyze, and reorganize folders or disks, automatic invocation could cause unintended filesystem analysis or organization actions in contexts where the user did not explicitly request this capability.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The guidance states that top-level directories should default to '编号 + 英文', which imposes a specific language convention. Because the document does not present this as optional, configurable, or justified by a region-specific requirement, it is a natural-language language-policy issue.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

This markdown file uses only Chinese for all operational instructions and user-facing guidance. Under the natural-language policy rule, forcing a specific language without user opt-in is a policy concern unless the locale limitation is explicitly documented and justified, which is not present here.

Content

No source excerpt is available for this finding.

Dynamic import via __import__()

Medium
Category
Dangerous Code Execution
Confidence
75% confidence
Finding

Dynamic import() can load arbitrary modules at runtime, bypassing static analysis and potentially importing malicious code.

Content

Scanner excerpt · scripts/classify_files.py (reported line 94)May include surrounding context.

python
root = str(root_path)

    data = {"version": 1, "generated_at": now_iso(), "root": root, "items": items}
    text = to_markdown(data) if args.format == "markdown" else __import__("json").dumps(data, ensure_ascii=False, indent=2)

    if args.output:
        Path(args.output).write_text(text, encoding="utf-8")

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The script unconditionally deletes an existing log file specified by --log before processing the plan. Because the path is fully user-controlled and no warning, confirmation, or safety checks are applied, a user can accidentally destroy unrelated files by pointing --log at an existing important path, causing data loss even in dry-run mode.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The docstring, argument descriptions, and generated markdown content all indicate the skill produces Chinese-only output, such as the title and table headers. This constitutes a language/locale policy concern because the skill does not offer any user choice or opt-in for language selection.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

This Python file contains natural-language descriptions, reasons, headings, and CLI help text entirely in Chinese, with no indication that the skill is region-specific or that users may choose another language. Under the policy, forcing a specific language without opt-in is a natural-language policy violation applicable to all file types.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

This file embeds user-facing labels and descriptions in Chinese across the default directory definitions, and additional Chinese output strings appear in classification results. Because the skill does not offer a language/locale option or justify a China-specific scope, it may violate language/locale policy by forcing a specific language without user opt-in.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The script's docstring, argument descriptions, errors, and generated markdown headings are all hard-coded in Chinese, which imposes a single language on users without opt-in or alternative locale support. The provided rules treat forced language output as a natural-language policy violation unless the constraint is explicitly documented and justified.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

This is a natural-language policy issue because the script forces a specific language in its docstring, CLI description, help text, and generated report content. Users who do not read Chinese are given no opt-in or alternative locale, and the file does not document any region-specific justification for this constraint.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
88% confidence
Finding

This markdown file contains only Chinese-language content and does not indicate that the skill is region-specific or that users may choose another language. Under the natural-language policy check, forcing a specific language without opt-in can be a locale-policy violation.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

The docstring, CLI descriptions, error message, and generated markdown headings are all hard-coded in Chinese, which imposes a specific language on users. The file does not provide any language selection, opt-in, or explanation that this skill is intended only for a Chinese-language environment.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
93% confidence
Finding

The module docstring states the behavior in Chinese and the user-facing CLI description, help text, status notes, and printed messages throughout the file are all fixed in Chinese. This imposes a specific language/locale without offering the user a choice or documenting a justified locale constraint.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
96% confidence
Finding

This code uses Chinese for the module docstring, CLI description, argument help text, and runtime messages, which imposes a specific language on users. The policy allows locale constraints only when documented and justified or when users are given a choice, neither of which is present here.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
93% confidence
Finding

This Python file contains user-facing natural-language strings entirely in Chinese, including the module docstring, CLI description, and help text. That effectively imposes a specific language/locale on users without offering a language choice or documenting a justified region-specific constraint.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
93% confidence
Finding

The module docstring, markdown output, and CLI help strings are all hard-coded in Chinese, which imposes a specific language on users. The file does not offer any language selection or explain that the skill is intentionally limited to a Chinese-speaking context.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
88% confidence
Finding

This code writes the generated inventory to the path supplied by --output, but there is no confirmation prompt, warning message, or explicit disclosure near the write operation itself. Although file output is a normal capability for this script, the specific risk of modifying or overwriting a local file is not surfaced to the user in code-facing messaging.

Content

No source excerpt is available for this finding.