Back to skill

Security audit

EPUB Read

Security checks for vulnerabilities and agentic risk

Overview

The EPUB reader is mostly purpose-aligned, but it needs review because one included test command can delete an arbitrary caller-supplied output directory.

Review before installing if you may run its validation helper or process untrusted EPUB files. Use only isolated output directories, do not pass an existing important folder to test_integration.py --output-dir, and prefer a locked dependency environment when parsing files from unknown sources.

Vulnerability Patterns
  • Insecure DependenciesIntroduces malicious components through unsafe dependency sources
  • 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
Findings (3)

T09 · Insecure Skill Coding Practices

Error
Location
test_integration.py:25
Finding

Caller-Controlled Test Output Path Enables Arbitrary Recursive Deletion

Content
View full analysis
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
utils.py:74
Finding

Unbounded Expansion and Parsing of Untrusted EPUB Archive Members

Content
View full analysis
str: raw = archive.read(member_path) for encoding in ("utf-8-sig", "utf-8", "cp1252", "latin-1"): try: return raw.decode(encoding) except UnicodeDecodeError: continue return raw.decode("utf-8", errors="replace") ``` The function is used repeatedly while parsing archive metadata and chapter content: ```python with zipfile.ZipFile(epub_path, "r") as archive: opf_path = parse_container(archive) metadata, manifest_items, spine = parse_opf(read_zip_text(archive, opf_path)) ``` ```python resolved_path = resolve_href(opf_path, item["href"]) extracted = extract_markdown_from_html(read_zip_text(archive, resolved_path)) body_markdown = extracted["markdown"].strip() stats = extracted["stats"] ``` ### Technical Analysis `archive.read(member_path)` decompresses the complete selected ZIP member into memory. The implementation does not validate: - Individual uncompressed member size - Aggregate uncompressed archive size - Compression ratio - Number of archive members - Maximum XML or HTML document size - Maximum number or size of chapters - Maximum generated JSON and Markdown output size After decompression, the complete byte string is decoded and passed to XML or HTML parsers. Parsed chapter content is then retained in the `chapters` list, included in `book.json`, and combined into `book.md`. This can multiply memory and disk consumption because the same logical content may exist simultaneously as decompressed bytes, decoded strings, parser objects, chapter records, JSON output, and Markdown output. Although the parser does not call `extractall()` and therefore avoids a conventional ZIP path-tr ...[truncated 1524 chars]
Remediation
View remediation
MAX_MEMBER_SIZE: raise ValueError(f"EPUB member is too large: {member_path}") compressed_size = max(info.compress_size, 1) if info.file_size / compressed_size > MAX_COMPRESSION_RATIO: raise ValueError(f"Suspicious compression ratio: {member_path}") ``` 3. Track the aggregate size of every member selected for processing and stop when the configured book-level limit is exceeded. 4. Read members incrementally with a hard byte limit rather than materializing arbitrary amounts of data. 5. Apply time, memory, and output-size limits at the process or container level when parsing untrusted books. 6. Limit the total size of `content_markdown` retained in memory and avoid duplicating the entire book in both JSON and Markdown unless explicitly requested. 7. Add security tests using: - High-compression-ratio ZIP members - Very large XHTML resources - Excessive member counts - Oversized metadata documents - Books that exceed aggregate output limits ]]>

T08 · Insecure Dependencies

Warning
Location
requirements.txt:1
Finding

Broad Dependency Version Ranges Prevent Reproducible and Integrity-Verified Installation

Content
View full analysis
=4.12,<5 lxml>=5.0,<6 ``` The documented installation process is: ```bash python3 -m venv .venv source .venv/bin/activate pip install -r requirements.txt ``` ### Technical Analysis The dependency manifest permits any future `beautifulsoup4` 4.x release from version 4.12 onward and any future `lxml` 5.x release. It does not provide exact reviewed versions or package hashes. Consequently, two installations performed at different times can resolve to different package artifacts despite using the same project revision. The installation also relies on the configured package index and transport trust without verifying that downloaded distributions match an audited lock file. There is no evidence in the reviewed project that either dependency is currently malicious. The security issue is the unresolved supply-chain trust boundary: a compromised eligible release, package index, mirror, or account could introduce code that is installed and later imported by the project without a source change in this repository. ### Attack Path 1. A dependency publisher account, package-index account, or configured package mirror is compromised, or an eligible dependency release is otherwise malicious. 2. A new release satisfying `beautifulsoup4>=4.12,<5` or `lxml>=5.0,<6` becomes available. 3. A user follows the documented `pip install -r requirements.txt` command. 4. The resolver selects the new eligible artifact because no exact version is pinned. 5. No expected cryptographic hash is available to reject the changed artifact. 6. Package installation hooks or imported package code execute with the permissions of the user or CI runner. 7. The compromised dependency could access data and resources available to that environment. ### Impact Assessm ...[truncated 569 chars]
Remediation
View remediation
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • 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 (10)

Tp4

High
Category
MCP Tool Poisoning
Confidence
94% confidence
Finding

The skill advertises a reading/analysis workflow, but the detected behavior includes transforming files, creating manifests, chunking content, and mutating session state and book artifacts. This mismatch is security-relevant because users and orchestration systems may grant trust based on the declared purpose while the skill performs broader write-heavy operations than expected, enabling unexpected data modification or persistence. In this context, artifact generation is plausibly part of EPUB processing, so the issue is more about unsafe under-disclosure than overtly malicious behavior.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
94% confidence
Finding

The skill instructs use of local scripts and stateful file operations but declares no explicit tool/permission scope. That creates an authorization ambiguity where an agent may invoke shell, read arbitrary files, or write artifacts without a clearly constrained boundary, increasing the chance of unintended filesystem access or command execution. The EPUB context makes shell/file access somewhat expected, but the absence of declared limits still leaves the skill more dangerous than necessary.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The build_parse_guidance function returns all user-facing instructional text in Chinese, which imposes a specific language on users regardless of their preferences. This is a natural-language policy issue because the file does not provide any opt-in, fallback, or justification for restricting output to a single locale.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This file contains multiple natural-language strings shown to users exclusively in Chinese, including error messages, CLI descriptions, help text, and status notes. Because the skill does not offer a user language/locale choice or document a justified locale restriction, it violates the language/locale policy criteria.

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 · test_integration.py (reported line 38)May include surrounding context.

python
def run_command(command: list[str], cwd: Path) -> subprocess.CompletedProcess[str]:
    result = subprocess.run(command, cwd=cwd, text=True, capture_output=True)
    if result.returncode != 0:
        raise RuntimeError(
            f"Command failed: {' '.join(command)}\nstdout:\n{result.stdout}\nstderr:\n{result.stderr}"

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
89% confidence
Finding

This markdown file contains a natural-language statement establishing English as the source language. Under the policy, forcing a specific language without user opt-in or a clearly justified locale constraint can be a violation, and no opt-in or justification is provided here.

Content

No source excerpt is available for this finding.

Unverifiable Dependency: lxml has 14 known advisory(ies) (CVE-2021-43818 (lxml's HTML Cleaner allows crafted and SVG embedded scripts to pass through); CVE-2014-3146 (lxml Cross-site Scripting Via Control Characters); CVE-2021-28957 (lxml vulnerable to Cross-Site Scripting ) +11 more), but the manifest does not pin a version, so it is unknown whether the installed release is affected

Low
Category
Supply Chain
Confidence
90% confidence
Finding

The dependency specification allows any lxml release from 5.0 up to, but not including, 6.0 rather than pinning a known-safe version. Because lxml has a history of security advisories and this skill parses EPUB content, an unpinned range makes it impossible to verify at review time that deployments will avoid vulnerable releases or remain reproducible.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Low
Category
Not specified by scanner
Confidence
88% confidence
Finding

The manifest frames the skill around reading and analysis workflows, which suggests primarily read-oriented behavior over EPUB-derived content. This file also persists a generated plan to disk via save_plan(), adding a file-writing behavior not reflected in the high-level description.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

The command-line interface description, help text, and user-facing messages are written only in Chinese. This imposes a specific language on users without any opt-in or documented locale constraint, which matches the language/locale policy violation criterion.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
91% confidence
Finding

This code file contains a natural-language comment in Chinese ('增强统计') while the rest of the file is in English. A mixed-language instruction or documentation style can violate a language/locale policy when the skill does not offer language choice or explain the locale-specific requirement.

Content

No source excerpt is available for this finding.