Back to skill

Security audit

Pdf Highlight Extractor

Security checks for vulnerabilities and agentic risk

Overview

This skill performs the expected PDF highlight extraction and Markdown note creation, with manageable risks around runtime dependency installation and local file writes.

Install only if you are comfortable with it installing PyMuPDF into the active Python environment and writing a notes file beside the source PDF. Prefer using an isolated environment with a pinned PyMuPDF version, and check whether a same-named highlights Markdown file already exists before running it on important documents.

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

T08 · Insecure Dependencies

Warning
Location
scripts/install_deps.py:10
Finding

Unpinned Third-Party Dependency Installed at Runtime

Content
View full analysis

Vulnerability Details

File Location: scripts/install_deps.py, lines 10–16
Vulnerability Type: Unpinned runtime dependency installation
Risk Level: Medium

Vulnerable Code

python
REQUIRED = ["pymupdf"]

def main():
    print("[INFO] Installing dependency: pymupdf ...")
    result = subprocess.run(
        [sys.executable, "-m", "pip", "install", "--quiet", *REQUIRED],
        capture_output=True,
        text=True,
    )

The installation is also explicitly included in the documented workflow in SKILL.md, lines 25–31:

bash
<python> scripts/install_deps.py

Technical Analysis

The installation script invokes pip to resolve and install pymupdf without pinning an audited version or verifying package hashes. It also does not require a locked dependency file or explicitly constrain package retrieval to a controlled repository.

Consequently, the code installed during each Skill initialization can change independently of the reviewed project. Python package installation may execute third-party build or installation logic, while later importing fitz executes the installed package's runtime code. This creates a supply-chain trust boundary that is not controlled by the audited source tree.

This finding does not establish that the current PyMuPDF package is malicious. The vulnerability is the uncontrolled and non-reproducible dependency resolution process.

Attack Path

  1. The Agent follows the dependency setup instructions in SKILL.md.
  2. It executes scripts/install_deps.py.
  3. The script runs python -m pip install --quiet pymupdf.
  4. pip resolves a package version from its configured package index without a version or hash constraint.
  5. If the selected release, distribution artifact, configured index, or dependency resolution path has been compromised, attacker-controlled package installation logic may execute.
  6. The Skill later imports fitz, causing the installed package's runtime code to execute in the ...[truncated 866 chars]
Remediation
View remediation

Remediation Suggestions

  1. Pin PyMuPDF to a specifically reviewed version rather than resolving the latest release:

    text
    pymupdf==X.Y.Z
    
  2. Store dependencies in a lock or requirements file with cryptographic hashes and install them using hash enforcement:

    bash
    python -m pip install \
      --require-hashes \
      --only-binary=:all: \
      -r requirements.txt
    
  3. Record hashes for every permitted distribution artifact and platform supported by the Skill.

  4. Retrieve packages from an organization-controlled, authenticated repository or an approved package mirror rather than relying on an unconstrained index configuration.

  5. Prefer provisioning dependencies outside Skill execution. Build an isolated virtual environment or container from a reviewed and immutable dependency manifest.

  6. Run installation and PDF processing with least privilege, restricted network access, and filesystem access limited to required input and output locations.

  7. Add automated dependency review, vulnerability scanning, and an explicit upgrade process so version changes are separately assessed before deployment.

Vulnerability Patterns
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
Findings (11)

Tp4

High
Category
MCP Tool Poisoning
Confidence
93% confidence
Finding

整体主功能与声明大体一致:代码的核心确实是读取 PDF 高亮批注、提取文字,并生成 Markdown 文件。但声明中有几个关键行为被表述得比实际实现更强:首先,title 和 tags 并不是由 AI 基于提取内容语义自动生成,实际只是从 PDF 文件名派生;其次,“内容总结”部分并未真正生成总结,只写入了一个待 AI 填写的占位符。除此之外,代码还提供了若干声明未提及的能力,如按颜色筛选高亮、自定义输出目录、JSON 模式输出。虽然这些附加能力不改变主用途,但前两项已构成对核心输出效果的实质性描述偏差,因此应判定为不完全匹配。

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The manifest says to use the skill when the user mentions intents such as 「整理标注」, 「读取标记」, or 「生成读书笔记」. These phrases are not narrowly scoped to PDF highlight extraction and could match ordinary note-taking or annotation requests unrelated to this skill, increasing the chance of unintended activation.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

This Python file contains its main docstring, CLI help text, and status/error messages entirely in Chinese, which imposes a specific language on users. The file does not indicate that the skill is intended only for a Chinese-speaking environment or provide any opt-in or localization choice, which matches the language/locale policy violation criteria.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The manifest says title and tags are automatically generated by AI from semantic content, and that the Markdown includes both extracted text and a content summary. In code, generate_tags_and_title derives title/tags from the filename with simple regex splitting, while build_markdown inserts a literal placeholder for the summary instead of producing one.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The module docstring states the skill behavior in Chinese and all user-facing messages in this file are Chinese-only, implying a fixed language choice. The policy explicitly disallows forcing a specific language without user opt-in, and this file provides no locale selection or justification for a Chinese-only experience.

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/install_deps.py (reported line 14)May include surrounding context.

python
def main():
    print("[INFO] 正在安装依赖: pymupdf ...")
    result = subprocess.run(
        [sys.executable, "-m", "pip", "install", "--quiet", *REQUIRED],
        capture_output=True,
        text=True,

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
90% confidence
Finding

The skill instructs the agent to create a Markdown file next to the source PDF without explicitly requiring user confirmation or warning about filesystem modification. That can lead to unexpected writes in user directories, surprise overwrites of existing notes, or accidental creation of files in sensitive project locations if the PDF path is user-supplied or inferred incorrectly.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
91% confidence
Finding

The instructions specify that the generated title should be '中文优先', which imposes a language preference. Because the skill does not ask for user opt-in or present a language choice, this creates a natural-language locale policy concern.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
90% confidence
Finding

The inline documentation states that WorkBuddy AI will later replace the fallback title and tags, implying an implemented follow-up step. In this file, no such AI call or handoff mechanism exists beyond printing JSON, so the documentation overstates what the code actually does.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Low
Category
Not specified by scanner
Confidence
88% confidence
Finding

The manifest explicitly states the output file is saved in the same directory as the PDF with a fixed naming convention. However, the code exposes an --output option and writes to that resolved directory, allowing behavior beyond the declared destination.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Low
Category
Not specified by scanner
Confidence
87% confidence
Finding

The manifest describes a skill that extracts highlights and generates a Markdown notes file. The code also offers a --json mode that emits raw highlight data only for downstream processing, which is an additional operational mode outside the described user-facing behavior.

Content

No source excerpt is available for this finding.