Back to skill

Security audit

電子書轉換工具箱

Security checks for vulnerabilities and agentic risk

Overview

This is mostly a local ebook conversion tool, but it needs Review because it overstates some capabilities and has unsafe handling of untrusted EPUB/HTML content and temporary files.

Review before installing. Use it only on ebooks you trust, keep output directories explicit, use dry-run for organization, and avoid opening generated HTML from unknown EPUBs in a browser. Expect EPUB/PDF features to work better than the advertised MOBI/AZW3/FB2 support, and treat sudo dependency installation as a separate system-level choice.

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

Warning
Location
scripts/epub_converter.py:109
Finding

Predictable Shared Temporary Directory Used for EPUB Processing

Content
View full analysis
or first

/

title = "" t = re.search(r"]*>(.*?)", raw, re.DOTALL | re.IGNORECASE) if t: title = _unhtml_entity(t.group(1).strip()) ``` ### Technical Analysis The converter extracts EPUB metadata into the fixed, globally predictable directory `/tmp/_epub_tmp`. This directory is shared by every conversion and is not created through a secure temporary-directory API. It is also never removed after processing. The extracted `container.xml` controls the OPF location used by `_parse_meta`. Chapter and cover paths from that OPF file are subsequently joined to `opf_dir` and read from the filesystem. The code does not verify that resolved paths remain inside a private extraction directory. This design creates several related weaknesses: - Concurrent conversions can overwrite or consume one another's temporary files. - Files left by earlier conversions can affect later conversions. - Another local process with access to the shared temporary hierarchy may pre-create files, directories, or symbolic links to influence filesystem reads. - Extracted ebook metadata remains on disk after conversion. - Manifest-relative paths are not normalized and checked against an approved root befo ...[truncated 1574 chars]

Remediation
View remediation
Path: root = root.resolve() candidate = candidate.resolve() if candidate != root and root not in candidate.parents: raise ValueError("EPUB path escapes the extraction directory") return candidate ``` 3. Prefer reading ZIP members directly with `ZipFile.read()` rather than extracting attacker-controlled archive content to the filesystem. 4. Reject absolute paths, parent-directory components such as `..`, and manifest references that are not valid archive members. 5. Ensure cleanup occurs automatically on success and failure. `TemporaryDirectory` provides this behavior when used as a context manager. 6. Apply resource limits for EPUB size, member count, per-member uncompressed size, and total uncompressed size to reduce archive-based denial-of-service risk. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/epub_converter.py:239
Finding

Insufficient Sanitization Preserves Active Content in Generated HTML

Content
View full analysis
]*>.*?", "", content, flags=re.DOTALL|re.I) clean_html = re.sub(r"]*>.*?", "", clean_html, flags=re.DOTALL|re.I) html_parts.append(clean_html) ``` ### Technical Analysis The EPUB-to-HTML converter embeds chapter markup from an untrusted EPUB directly into the generated HTML document. It only removes conventional `script` and `style` blocks using regular expressions. Removing these two element types is not sufficient HTML sanitization. Active browser behavior can remain in many forms, including: - Event-handler attributes such as `onerror`, `onload`, and `onclick`. - `javascript:` or other unsafe URL schemes. - Iframes and embedded remote resources. - SVG or MathML elements capable of carrying active content. - Forms and navigation elements. - Meta refresh redirects. - Malformed markup that a browser parses differently from the regular expression. Regular expressions are unsuitable for safely parsing and sanitizing HTML because browser parsing rules include malformed markup recovery, nested elements, alternate namespaces, and encoded attribute values. The same output-building function also interpolates EPUB metadata and chapter titles into HTML without contextual escaping. Although this finding is pinpointed at the direct chapter insertion, all EPUB-controlled values included in the generated document should be treated as untrusted. ### Attack Path 1. An attacker creates an EPUB containing active markup in a chapter, such as an image with an `onerror` handler, an iframe, an SVG payload, or an unsafe link. 2. The victim converts the EPUB with the HTML output format. 3. The converter removes only `script` and `style` blocks. 4. The remaining active m ...[truncated 1065 chars]
Remediation
View remediation
Vulnerability Patterns
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • 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 (31)

Tp4

High
Category
MCP Tool Poisoning
Confidence
94% confidence
Finding

此程式與『批量轉換』這一部分描述大致相符,也確實有自動偵測格式、混合輸入、並行處理與轉換報告。但整體宣稱的工具箱能力明顯超出實際程式碼:convert_job 只處理 epub 與 pdf,其他來源格式雖出現在 SUPPORTED 中,實際會被標記 skipped;目標格式也非對所有來源都適用,PDF 沒有 html/json 路徑。另描述中的封面萃取、元資料讀寫、圖書館自動分類在此程式碼中完全未見,因此屬於描述與實際行為不符。

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

描述將此技能定位為『電子書轉換工具箱』,核心能力應是多格式內容轉換與相關處理;但程式碼的主要功能是 EPUB/PDF 元資料讀取、EPUB 元資料編輯、書目匯出,以及批量掃描元資料。雖然描述中提到元資料讀寫,這部分與程式相符,但宣稱的主要能力(格式轉換、更多格式支援、封面萃取、自動分類)均未在程式中實作,屬於明顯的描述與實際行為不符。

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

描述的主功能是『電子書格式轉換工具箱』,但程式碼的主功能明顯是『電子書圖書館管理/整理』。它會掃描目錄中的 .epub/.pdf/.mobi/.azw3/.fb2 檔案,從 EPUB/PDF 擷取作者資訊,然後依作者、格式或展平方式將檔案複製到新目錄或建立符號連結,並產生 JSON 清單與 Markdown 報告。程式中完全看不到將電子書內容轉換成 TXT/Markdown/HTML/JSON 的邏輯,也沒有封面萃取或元資料寫回功能。雖然描述裡提到『圖書館自動分類』,這部分與實作相符,但只是整體描述中的次要一項;整體主用途與多數宣稱能力都不符合,因此屬於明顯不匹配。

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

The supplied code implements an EPUB-specific conversion utility, not a general multi-format ebook toolbox. It can parse EPUB archives, read metadata, extract covers, and convert EPUB content into TXT, Markdown, HTML, or JSON, including batch mode for .epub files. However, the declared description claims support for multiple source formats (PDF, MOBI, AZW3, FB2) that are absent from the code. It also claims metadata read/write, but the code only reads metadata from EPUB and emits it into outputs; there is no capability to modify or write metadata back into ebook files. Likewise, there is no library auto-classification logic. These are material gaps in declared versus actual behavior, so this should be flagged as a mismatch.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

描述將此技能定位為通用電子書轉換工具箱,但提供的程式碼實際上是單一 PDF 轉換/處理腳本。其核心能力集中在 PDF 文字擷取、OCR、Markdown 格式化、轉圖片、分割/合併與資訊讀取,與宣稱的多格式電子書轉換平台相比範圍明顯更窄,且缺少多項關鍵宣稱功能。雖然『PDF → TXT / Markdown』與部分元資料相關能力有重疊,但整體描述明顯高估並錯述了實際行為,因此應判定為描述與行為不符。

Content

No source excerpt is available for this finding.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · README.md (reported line 12)May include surrounding context.

brew install poppler tesseract

安裝依賴(Ubuntu/Debian)

sudo apt install poppler-utils tesseract-ocr tesseract-ocr-chi-tra

text

## 快速開始

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · SKILL.md (reported line 47)May include surrounding context.

brew install poppler tesseract

安裝依賴(Ubuntu/Debian)

sudo apt install poppler-utils tesseract-ocr tesseract-ocr-chi-tra

text

## 快速開始

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
90% confidence
Finding

The skill advertises and invokes capabilities that imply file reads, file writes, and shell execution, but it does not declare any explicit tool scope or permissions boundaries. This is dangerous because an agent or platform may grant broader-than-necessary access by default, increasing the blast radius for file modification or command execution during ebook processing.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill description and usage guidance are entirely presented in Traditional Chinese, with no indication that users may request another language or that the locale restriction is intentional and justified. This can constitute a language-policy issue when the skill appears generally applicable rather than region-specific.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The trigger list contains broad, everyday phrases that can cause accidental invocation outside the user’s intended context. For a skill that can read, write, organize, and possibly invoke shell-backed conversion workflows, unintended activation raises the risk of acting on user files without sufficiently explicit consent.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The skill advertises metadata editing and automated library organization but omits warnings that these features can alter user files, create links, or restructure collections. In a file-manipulating context, lack of disclosure can lead users to authorize actions without understanding the risk of unwanted modifications or data-management side effects.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The manifest describes a toolbox supporting EPUB / PDF / MOBI / AZW3 / FB2 conversions, but the actual conversion logic only dispatches EPUB and PDF handlers. For other declared formats, the code marks jobs as skipped with an unsupported-format error, creating a clear mismatch between advertised behavior and implemented behavior.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The manifest describes an ebook conversion and metadata toolbox, but this PDF path depends on spawning the external pdfinfo executable through subprocess.run. Launching external processes is a broader capability than ordinary file parsing and is not explicitly declared in the stated scope, making it context-inappropriate for this kind of document utility.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · scripts/ebook_metadata.py (reported line 158)May include surrounding context.

python
"pages": 0, "year": "",
    }
    try:
        cp = subprocess.run(
            ["pdfinfo", str(pdf_path)],
            capture_output=True, text=True, timeout=30, errors="replace"
        )

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

This code file contains user-facing natural language in the module docstring and command help text that forces a specific language/locale. The policy allows locale constraints only when justified or when the user is given a choice, neither of which is present here.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The manifest describes an ebook conversion/organization toolbox, but this file shells out to an external binary via subprocess.run to extract PDF metadata. Spawning subprocesses is a higher-risk capability than ordinary local file parsing and is not explicitly justified by the stated purpose.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · scripts/ebook_organizer.py (reported line 55)May include surrounding context.

python
def _pdf_author(pdf_path: Path) -> str:
    import subprocess
    try:
        cp = subprocess.run(["pdfinfo", str(pdf_path)],
                           capture_output=True, text=True, timeout=30)
        for line in cp.stdout.splitlines():
            if ":" in line and "Author" in line:

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The parser description, subcommand help text, argument help text, and log messages are all presented only in Chinese. This is a natural-language locale restriction without opt-in, which violates the stated policy for language choice.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The module docstring and the implementation throughout the file are EPUB-specific: parsing EPUB container.xml/OPF data, reading ZIP-based EPUB contents, and exposing CLI help as EPUB-only conversion. This does not match the manifest's broader claim of supporting EPUB / PDF / MOBI / AZW3 / FB2 conversions and additional library features, so the behavior implemented in this skill file is materially narrower than the described toolbox.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The code parses metadata from EPUB package files and uses it in output generation, but there is no implementation for writing metadata back to books or performing any library auto-classification. Given the manifest explicitly advertises '元資料讀寫、圖書館自動分類', this file's actual behavior falls short of those declared capabilities.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The CLI description, help text, and status messages are presented in Traditional Chinese only, and there is no option for users to select another language. This is a natural-language locale policy issue because the skill forces a specific language without opt-in or justification that it is intended only for a Chinese-speaking context.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The implementation relies on subprocess execution of local binaries such as pdftotext, pdftoppm, tesseract, pdftk, and pdfinfo to perform its work. For a document conversion skill, invoking arbitrary system executables is a materially broader capability than the manifest states, because it depends on host-level command execution rather than an explicitly declared embedded conversion engine.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · scripts/pdf_converter.py (reported line 27)May include surrounding context.

python
def _run(cmd: list[str], capture=True) -> tuple[int, str, str]:
    try:
        cp = subprocess.run(cmd, capture_output=capture,
                          text=True, timeout=120, errors="replace")
        return cp.returncode, cp.stdout or "", cp.stderr or ""
    except Exception as e:

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The manifest describes an ebook conversion toolbox focused on format conversion, cover extraction, metadata read/write, and library classification. This file adds PDF splitting and merging operations, which are document manipulation capabilities not described in the manifest and go beyond straightforward conversion behavior.

Content

No source excerpt is available for this finding.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · scripts/pdf_converter.py (reported line 171)May include surrounding context.

python
def pdf_split(pdf_path: Path, ranges: list[str], out_dir: Path = None) -> list[Path]:
    """ranges: ["1-5", "10-", "20"]"""
    if not _has("pdftk"):
        print("❌ 需要 pdftk(sudo apt install pdftk | brew install pdftk)")
        return []
    out_dir = out_dir or pdf_path.parent
    out_dir.mkdir(parents=True, exist_ok=True)