Back to skill

Security audit

书库扫描入库

Security checks for vulnerabilities and agentic risk

Overview

This skill is not clearly malicious, but it needs Review because its search step can invoke a caller-supplied PowerShell script and a crafted index can make note generation write outside the chosen output folder.

Review before installing. Use only on ebook folders you intentionally choose, write to a dedicated empty output directory, and do not run batch_search.py with a PowerShell script unless you know and trust that script. Treat the JSON index as sensitive because it records titles and full local file paths, and avoid using untrusted index files until path containment is fixed.

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/generate_notes.py:28
Finding

Arbitrary File Creation Through Unvalidated Path Components

Content
View full analysis
:"/\\|?*]', '', author)[:30].strip() safe_title = re.sub(r'[<>:"/\\|?*]', '', title)[:50].strip() if not safe_author: safe_author = '未知作者' if not safe_title: safe_title = '未知书名' # 构建路径 folder = os.path.join(output_dir, category, country, safe_author) note_file = os.path.join(folder, f"{safe_title}.md") if os.path.exists(note_file): skipped += 1 continue # Markdown内容 content = f"""# {title} - **作者**: {author} - **分类**: {category} - **国家**: {country} - **格式**: {book.get('format', '未知')} - **文件**: {book.get('filename', '')} ## 内容简介 {book.get('introduction', '暂无简介')} --- *来源: {book.get('intro_source', '网络')}* """ try: os.makedirs(folder, exist_ok=True) with open(note_file, 'w', encoding='utf-8') as f: ``` ### Technical Analysis The `category` and `country` values are loaded from a caller-supplied JSON index and used directly as filesystem path components. Unlike `author` and `title`, these fields receive no sanitization or structural validation. An attacker can provide values containing parent-directory components such as `..`, or absolute paths. `os.path.join()` does not enforce containment beneath `output_dir`: traversal components are resolved by the filesystem, while an absolute component can cause preceding components—including `output_dir`—to be discarded. The subsequent calls to `os.makedirs()` and `open()` there ...[truncated 1970 chars]
Remediation
View remediation
:"/\\|?*]', '', str(value)).strip() if value in {'', '.', '..'}: return fallback return value[:maximum_length] safe_country = safe_component(country, 'Unknown', 30) safe_author = safe_component(author, 'Unknown Author', 30) safe_title = safe_component(title, 'Unknown Title', 50) root = Path(output_dir).resolve() folder = (root / category / safe_country / safe_author).resolve() note_file = (folder / f"{safe_title}.md").resolve() if root != note_file and root not in note_file.parents: raise ValueError("Generated path escapes the output directory") folder.mkdir(parents=True, exist_ok=True) with note_file.open('x', encoding='utf-8') as output: output.write(content) ``` The allowlist must use the a ...[truncated 176 chars]
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (16)

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

声明描述的是一个“完整工作流”,包含本地扫描、元数据提取、分类整理、联网搜索书籍简介,以及生成 Obsidian 笔记。实际代码只实现了本地目录扫描、部分格式的元数据提取(EPUB/PDF)、基于关键词的简单分类,并输出 JSON 索引。代码中没有任何网络请求、外部搜索、简介抓取逻辑,也没有生成 Markdown/Obsidian 笔记的功能。此外,虽然会识别 MOBI/AZW3 文件并纳入索引,但并未为这两种格式实现元数据提取,因此“支持”与声明相比存在明显落差。总体上,实际行为仅覆盖声明中的一部分,且缺失两个核心能力,因此应判定为不匹配。

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding

声明描述的是“完整工作流”,涵盖扫描书库、提取元数据、分类整理、联网补全简介、再生成 Obsidian 笔记。但提供的代码块功能明显更窄:它只读取 index_file 中的 JSON 数据,筛选已有 introduction 的书籍,按 category/country/author 建目录并写入 Markdown 文件,同时生成一个统计性质的总目录页。代码中没有任何遍历本地电子书文件、解析 EPUB/MOBI/AZW3/PDF、提取元数据、或网络请求搜索简介的逻辑。因此,虽然“生成 Obsidian 笔记”这部分与声明部分一致,但整体声明显著高于代码实际能力,构成描述与行为不匹配。

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
95% confidence
Finding

The skill describes capabilities that imply reading local files, writing notes/indexes, and invoking shell/PowerShell, but it does not declare any explicit tool scope or permissions boundary. That makes the operational blast radius unclear to users and host systems, increasing the risk of over-broad file access or command execution if the skill is enabled.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The manifest description is entirely in Chinese and the workflow is oriented around Chinese metadata conventions, but it does not indicate that the skill is Chinese-only by design or offer language/locale choice. Under the policy, forcing a specific language without opt-in is a natural-language policy concern.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The skill says it will scan and organize a library, but it does not clearly warn that it will create files and potentially reorganize content in the output structure. Users may authorize it without understanding that it performs bulk filesystem writes, which can lead to unintended data modification, clutter, or overwrite risk.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The skill indicates that book metadata and search keywords are sent to an external search API, but it does not provide a clear privacy/network disclosure. This can expose sensitive reading habits, filenames, authors, or local library contents to third parties without informed consent.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
87% confidence
Finding

The code executes an externally supplied PowerShell script path from the command line without validating or constraining which script may run. Although subprocess.run is used without shell=True, this still permits arbitrary local code execution if an attacker can influence the search_script argument, which is especially risky because the skill’s stated purpose is metadata lookup rather than general script launching.

Content

Scanner excerpt · scripts/batch_search.py (reported line 16)May include surrounding context.

python
def search_book(keyword, search_script):
    """调用PowerShell脚本搜索书籍简介"""
    try:
        result = subprocess.run(
            ['powershell', '-File', search_script, '-Keyword', keyword],
            capture_output=True,
            timeout=30

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

This workflow delegates searching to any external PowerShell script, expanding the skill’s capability from book metadata enrichment to arbitrary code execution. In the context of a library scanner, that is broader than necessary and makes the skill dangerous if its parameters or surrounding automation are influenced by untrusted input.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

This code repeatedly rewrites the provided index file during processing and again at the end, which can modify user data if the file path is wrong or the content is undesired. While there are progress prints, there is no explicit warning, confirmation prompt, or comment/docstring disclosing that the input file will be modified in place.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

Natural-language strings throughout the file, including the module docstring and command-line usage, require Chinese comprehension and provide no language/locale opt-in. Under the stated policy, forcing a specific language without user choice is a language policy violation unless the locale restriction is explicitly justified.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

技能清单描述声称该技能会“联网搜索书籍简介,生成Obsidian笔记的完整工作流”,但本文件实际只遍历目录、提取部分 EPUB/PDF 元数据、做简单分类,并写出一个 JSON 索引文件。代码中没有任何网络请求逻辑,也没有创建 Markdown/Obsidian 笔记或执行相关工作流,因此与声明的能力明显不一致。

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

manifest 说明支持 EPUB/MOBI/AZW3/PDF 格式,语义上表示这些格式应进入同一元数据提取整理流程。实际代码虽然会识别 .mobi 和 .azw3 文件扩展名并纳入结果,但没有对应的元数据提取分支,最终主要退回到文件名作为标题,这与“自动提取元数据”的描述不一致。

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

This code file contains natural-language strings and documentation entirely in Chinese, including the module docstring and command-line usage/output. Under the policy, forcing a specific language without user opt-in can be a locale-policy violation when no alternative language choice or justification is provided.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

This code file contains natural-language strings and documentation exclusively in Chinese, including the module docstring and all command-line help text. Under the policy rule, forcing a specific language without opt-in is a natural-language policy violation because users are not offered any locale or language choice.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
93% confidence
Finding

The file's user-facing docstrings and console messages are written exclusively in Chinese, including the usage string and operational status output. Under the stated policy, forcing a specific language without user opt-in is a locale/language policy violation unless the constraint is explicitly documented and justified.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
91% confidence
Finding

The script persists a detailed inventory of the user's local ebook library, including full filesystem paths and extracted metadata, into a JSON file without any consent prompt, warning, or minimization option. In the context of a personal library scanner, this can expose sensitive reading habits, author/title interests, and local directory structure if the output is later shared, synced, or accessed by another user/process.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.