Back to skill

Security audit

文档整理技能 (document-organizer)

Security checks for vulnerabilities and agentic risk

Overview

This appears to be a real document-conversion skill, but it can unexpectedly delete a local temp directory even during dry-run and its guidance increases local data-loss risk.

Review before installing. Use it only from a controlled working directory with no valuable `temp_batch` folder, avoid running as admin/root, pin the CLI and Python dependencies, and back up important source/output data before bulk conversion.

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/batch_convert.py:349
Finding
Unsafe Recursive Deletion of a Predictable Working Directory## Vulnerability Details **File Location**: `scripts/batch_convert.py`, lines 349-353 **Vulnerability Type**: Unsafe temporary-directory handling and recursive deletion **Risk Level**: Medium ```python temp_root = Path("./temp_batch").resolve() if temp_root.exists(): shutil.rmtree(temp_root) temp_root.mkdir(parents=True, exist_ok=True) ``` ### Technical Analysis The script uses the fixed path `./temp_batch` as its temporary directory. If that path already exists, the script recursively deletes it without verifying that it was created by this application, that it contains only disposable conversion data, or that it is safe to remove. The path is resolved relative to the process's current working directory rather than being created as a unique, process-owned temporary directory. Consequently, a legitimate directory named `temp_batch` may be mistaken for temporary application data. This deletion also occurs before the `--dry-run` early return at lines 377-385. Therefore, a mode described as performing only a scan can still delete and recreate a directory. The program does not use shell interpolation for this operation, so this is not command injection. The defect is unsafe filesystem lifecycle management involving an untrusted, predictable path. ### Attack Path 1. A user has a directory named `temp_batch` under the directory from which the Skill will be launched, and that directory contains unrelated files. 2. Alternatively, a local attacker who can write to the working directory creates or replaces `temp_batch` before execution. 3. The user or an Agent invokes `batch_convert.py`, including potentially with `--dry-run`. 4. The script resolves `./temp_batch` and sees that it exists. 5. `shutil.rmtree(temp_root)` recursively removes its contents without ownership or provenance validation. 6. The script recreates an empty directory at the same path, concealing the fact that the former contents were unrelated appli ...[truncated 620 chars]
Remediation
## Remediation Suggestions 1. Replace the fixed working-directory path with a unique, process-owned temporary directory: ```python import tempfile with tempfile.TemporaryDirectory(prefix="document-organizer-") as temp_dir: temp_root = Path(temp_dir) # Perform conversion work within this context. ``` 2. Do not create, delete, or otherwise modify temporary paths before handling the `--dry-run` early return. 3. If a persistent temporary location is required, create a unique child directory using `tempfile.mkdtemp()` rather than deleting the parent directory. 4. Before cleanup, verify that the target: - Is beneath an explicitly designated temporary root. - Was created by the current process. - Is not the temporary root itself, the source directory, the output directory, or the current working directory. - Has not been replaced with an unexpected filesystem object. 5. Avoid recommending privileged execution as a general response to permission errors. Require only read access to the source and write access to dedicated output and temporary directories. 6. Add regression tests confirming that: - An existing `./temp_batch` directory is not deleted. - `--dry-run` performs no filesystem modifications. - Cleanup cannot remove the source or output directory.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Output HandlingUnvalidated Output Injection, Cross-Context Output, Unbounded Output
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (88)

Unvalidated Output Injection

High
Category
Output Handling
Content
def convert_and_reindex(source, output, index_file):
    """转换 + 重建索引"""
    # 1. 转换
    subprocess.run([
        "npx", "skills", "run", "document-organizer",
        "--source", source,
        "--output", output
Confidence
85% confidence
Finding
Model output is used without validation or sanitization. Unvalidated output injected into downstream contexts (SQL, shell, HTML) enables injection attacks and arbitrary code execution.

Tool Parameter Abuse

High
Category
Tool Misuse
Content
2. **清理临时文件**:
```bash
# 手动清理旧的转换临时文件
rm -rf ./temp_batch/*
```

3. **移动临时目录**:
Confidence
94% confidence
Finding
`rm -rf ./temp_batch/*` is a high-risk destructive command because it forcefully and recursively deletes files without confirmation. In a troubleshooting guide, this is especially dangerous since users are likely to execute it verbatim; if run from the wrong directory, against a replaced symlink, or after path confusion, it can cause substantial irreversible data loss.

Natural-Language Policy Violations

Medium
Confidence
95% confidence
Finding
The natural-language instructions and user-facing documentation are entirely in Chinese, and the file does not indicate that language selection is optional or that the skill is intentionally restricted to a Chinese-speaking or region-specific context. Per SQP-3, forcing a specific language without user opt-in is a locale policy concern.

Rp1

Medium
Category
MCP Rug Pull
Confidence
90% confidence
Finding
The README instructs users to run the skill via `npx skills` without pinning an exact package version. This can cause execution of a newer or compromised package version from the registry, creating a supply-chain risk at the moment users invoke the tool.

Rp1

Medium
Category
MCP Rug Pull
Confidence
90% confidence
Finding
This command example uses `npx skills` with no pinned version, so the executed package may vary over time or be replaced upstream. In a skill that processes large numbers of files, that expands the blast radius if a malicious or broken release is fetched.

Missing User Warnings

Medium
Confidence
91% confidence
Finding
This markdown file documents a skill that performs batch conversion and creates output files, preserving directory structure and generating logs. Under SQP-2 for markdown files, descriptions should warn about behaviors affecting user data or system state, but the examples and parameter docs present the write behavior without any explicit caution about disk writes, overwriting/creating outputs, or reviewing with dry-run first.

Rp1

Medium
Category
MCP Rug Pull
Confidence
90% confidence
Finding
The README again relies on unpinned `npx skills`, which is a known supply-chain weakness because `npx` resolves packages dynamically. If the package changes or is hijacked, users may execute attacker-controlled code while believing they are only running a document conversion skill.

Rp1

Medium
Category
MCP Rug Pull
Confidence
90% confidence
Finding
This usage example invokes an unversioned package through `npx`, allowing non-reproducible and potentially unsafe package resolution. Because the skill is intended for bulk document handling, users may grant broad file-system access, increasing the impact of a compromised package.

Rp1

Medium
Category
MCP Rug Pull
Confidence
90% confidence
Finding
The command at this line also fetches and runs `skills` without version pinning. This exposes users to upstream package drift and registry compromise, which is especially relevant for tooling that recursively processes directories.

Rp1

Medium
Category
MCP Rug Pull
Confidence
90% confidence
Finding
The README continues to recommend floating `npx skills` execution. Unpinned execution is dangerous because the effective code path can change between runs without review, undermining trust and reproducibility.

Rp1

Medium
Category
MCP Rug Pull
Confidence
90% confidence
Finding
This example still references `npx skills` without a fixed version, preserving the same supply-chain exposure. Since the tool converts potentially sensitive documents, any malicious package update could exfiltrate file contents or tamper with outputs.

Rp1

Medium
Category
MCP Rug Pull
Confidence
90% confidence
Finding
The invocation at this line dynamically resolves the `skills` package, which is a true security concern rather than a purely stylistic issue. The context makes it more dangerous because the tool is designed to traverse and transform many files, so compromised execution could affect large data sets.

Rp1

Medium
Category
MCP Rug Pull
Confidence
88% confidence
Finding
The FAQ example also uses an unpinned `npx skills` command, perpetuating supply-chain risk throughout the documentation. Repetition across the README increases the chance that users will copy an unsafe invocation directly into production environments.

Natural-Language Policy Violations

Medium
Confidence
92% confidence
Finding
SQP-3 适用于所有文件类型,需检查自然语言层面的语言/地区策略问题。该技能说明从标题到全部用法均固定为中文,未提供多语言选项、未说明仅面向中文用户,也没有用户可选择语言的提示。

Rp1

Medium
Category
MCP Rug Pull
Confidence
88% confidence
Finding
The documentation instructs users to run `npx skills` without pinning an exact package/version. `npx` may fetch and execute the latest published package or resolve unexpectedly from the environment, creating a supply-chain risk if a malicious or compromised release is served. In this skill context, the command is presented as the primary execution path, so the risk is materially relevant.

Rp1

Medium
Category
MCP Rug Pull
Confidence
88% confidence
Finding
This example again uses `npx skills` without an exact version, which can result in executing unreviewed code from the npm ecosystem at runtime. That exposes users to package substitution, malicious updates, or compromised upstream releases. Because this is operational guidance, users are likely to copy-paste it directly.

Rp1

Medium
Category
MCP Rug Pull
Confidence
88% confidence
Finding
The command shown at this line invokes `npx skills` without version pinning, preserving the same supply-chain execution risk. If the package namespace or latest version is compromised, the user may run attacker-controlled code locally. Since the skill is about bulk file processing, such code would likely receive access to many documents.

Rp1

Medium
Category
MCP Rug Pull
Confidence
88% confidence
Finding
Unpinned `npx skills` usage here creates a repeat instance of the same supply-chain vulnerability: runtime resolution of code that may change over time. In the context of a document conversion skill, compromise could expose or alter processed files, logs, and output directories. The danger is increased by the likelihood of users trusting documentation examples.

Rp1

Medium
Category
MCP Rug Pull
Confidence
88% confidence
Finding
This line repeats unpinned `npx skills` execution, which is a genuine security concern because it may download and run a different package version than the author tested. That creates avoidable risk of arbitrary local code execution through dependency compromise. The skill’s file-processing role means sensitive local content may be accessible if exploited.

Rp1

Medium
Category
MCP Rug Pull
Confidence
88% confidence
Finding
The documentation again recommends unversioned `npx skills`, which can execute mutable upstream code. This is a classic supply-chain weakness and is especially relevant when the command processes user-controlled directories containing potentially sensitive files. Even if the author’s intent is benign, the pattern is unsafe.

Rp1

Medium
Category
MCP Rug Pull
Confidence
88% confidence
Finding
Using `npx skills` without a pinned version at this line exposes users to the same risk of unintended or malicious package resolution. Because the example concerns environment configuration for document conversion, successful exploitation could grant access to file paths, document contents, and generated outputs. The issue is documentation-driven but still real.

Rp1

Medium
Category
MCP Rug Pull
Confidence
88% confidence
Finding
This occurrence instructs users to run unpinned npm-hosted code via `npx`, making the executed payload dependent on the current state of upstream package publication. That can enable arbitrary code execution if the package or dependency chain is compromised. Since this skill operates over bulk document sets, the blast radius can include confidentiality and integrity of many files.

Rp1

Medium
Category
MCP Rug Pull
Confidence
88% confidence
Finding
The command at this line continues the unsafe pattern of unpinned `npx skills` execution. That is dangerous because it delegates trust to whatever package version is resolved at runtime, which may change or be malicious. The skill’s purpose increases practical risk because users may run it on large, sensitive archives.

Rp1

Medium
Category
MCP Rug Pull
Confidence
88% confidence
Finding
This final `npx skills` example has the same unpinned-package supply-chain risk as the earlier ones. A compromised package could execute arbitrary commands with the user’s privileges and access input/output document trees. The repeated presence throughout the document makes accidental unsafe use more likely.

Natural-Language Policy Violations

Medium
Confidence
87% confidence
Finding
All user-facing instructions in this file are presented exclusively in Chinese, with no indication that another language is available or that Chinese is a justified region-specific requirement. Under the policy for natural-language content, forcing a specific language without user opt-in is a locale policy violation.

Static analysis

No suspicious patterns detected.