Back to skill

Security audit

pdf-analysis

Security checks for vulnerabilities and agentic risk

Overview

The skill does what it says, but its documented request examples can send both the API key and extracted PDF text to any endpoint named by an environment variable.

Review this skill before installing if you handle contracts, financial records, personal data, or other confidential PDFs. Only use a trusted API endpoint, check that AI_SKILLS_API_URL is unset or points to the intended HTTPS service, keep the API key revocable, and consider pinning PyMuPDF in controlled environments.

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 (2)

T09 · Insecure Skill Coding Practices

Error
Location
references/HTTP-REQUESTS.md:4
Finding
Environment-Controlled API Endpoint Can Disclose Credentials and Document Contents<![CDATA[ ## Vulnerability Details **File Location**: `references/HTTP-REQUESTS.md:4-8` **Vulnerability Type**: Unvalidated destination URL for authenticated requests **Risk Level**: High ### Vulnerable Code ```sh curl -sS -X POST "${AI_SKILLS_API_URL:-https://ai-skills.open-idea.net}/api/v1/pdf-analysis/pdf.analyze" \ -H "Authorization: Bearer ${PDF_ANALYSIS_API_KEY}" \ -H "Idempotency-Key: $(python3 -c 'import uuid; print(uuid.uuid4())')" \ -H "Content-Type: application/json" \ --data-binary @request.json ``` A second authenticated request uses the same environment-controlled origin at `references/HTTP-REQUESTS.md:15-16`: ```sh curl -sS "${AI_SKILLS_API_URL:-https://ai-skills.open-idea.net}/api/v1/pdf-analysis/pdf.analyze/tasks/任务ID" \ -H "Authorization: Bearer ${PDF_ANALYSIS_API_KEY}" ``` ### Technical Analysis The request destination is taken from `AI_SKILLS_API_URL` without validating its scheme or hostname. Although a legitimate HTTPS endpoint is the default, any existing value of the environment variable overrides that endpoint. The command forwards the `PDF_ANALYSIS_API_KEY` bearer credential to the selected destination. The task creation request also sends `request.json`, which is documented as containing filenames, page numbers, and extracted PDF text. Consequently, control over the environment variable is sufficient to redirect both authentication material and document contents to an unintended server. This does not grant an attacker arbitrary command execution by itself. Exploitation requires the ability to influence the environment or configuration from which the documented command is executed. ### Attack Path 1. An attacker or compromised launcher sets `AI_SKILLS_API_URL` to an attacker-controlled HTTP or HTTPS origin. 2. A user or agent follows the documented request procedure without inspecting the inherited variable. 3. Shell expansion substitutes the attacker-controlled origin into the `curl` command. 4. `curl` sends the `A ...[truncated 859 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Use a fixed, trusted HTTPS API origin whenever endpoint customization is not strictly required. 2. If customization is necessary, parse and validate the URL before use: - Require the `https` scheme. - Permit only explicitly approved hostnames. - Reject embedded credentials, fragments, unexpected ports, and noncanonical host representations. 3. Configure `curl` to reject insecure protocols, for example with `--proto '=https'`. 4. Do not forward authorization headers across cross-origin redirects. Prefer disabling redirects; if redirects are necessary, validate every destination. 5. Run requests from a sanitized environment rather than implicitly trusting inherited variables. 6. Document the security consequences of overriding the API origin. 7. Use narrowly scoped, revocable API keys and rotate a key immediately if it may have been sent to an untrusted endpoint. ]]>

T08 · Insecure Dependencies

Warning
Location
references/LOCAL-EXTRACTION.md:13
Finding
Unpinned PyMuPDF Installation Creates Supply-Chain Exposure<![CDATA[ ## Vulnerability Details **File Location**: `references/LOCAL-EXTRACTION.md:13-17` **Vulnerability Type**: Unpinned third-party dependency installation **Risk Level**: Medium ### Vulnerable Code ```sh python3 -m venv .venv-pdf-analysis .venv-pdf-analysis/bin/pip install PyMuPDF ``` Equivalent unpinned installation guidance also appears at `scripts/extract_pdf.py:6-11`: ```python try: import pymupdf except ImportError: try: import fitz as pymupdf except ImportError: sys.exit("缺少 PyMuPDF。请在独立虚拟环境中安装:python3 -m pip install PyMuPDF") ``` ### Technical Analysis The installation command specifies only the package name and therefore resolves whichever PyMuPDF release is current at installation time. It does not pin a reviewed version, verify package hashes, or use a committed lock file. PyMuPDF is imported directly by `scripts/extract_pdf.py` and is trusted to parse potentially untrusted PDF files. Python package installation can execute package build logic, while subsequent imports execute package initialization code in the user's process. An upstream account compromise, malicious release, compromised package index, or unsafe index configuration could therefore introduce executable code without any change to the audited project. The use of a virtual environment limits dependency conflicts but does not prevent dependency code from accessing files, environment variables, or network resources available to the invoking user. ### Attack Path 1. A user follows the documented installation command. 2. `pip` resolves a package version from its configured package index without a project-enforced version or hash. 3. A malicious or compromised distribution is downloaded and installed. 4. Package build or installation logic may execute during installation. 5. When `extract_pdf.py` imports `pymupdf` or `fitz`, dependency-controlled code executes with the user's privileges. 6. That code could access readable local files, environment v ...[truncated 808 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Pin PyMuPDF to a specifically reviewed version rather than installing the latest available release. 2. Store dependencies in a committed requirements or lock file. 3. Record and enforce cryptographic hashes, for example: ```sh python3 -m pip install --require-hashes -r requirements.txt ``` 4. Generate the lock file from a trusted environment and review dependency updates before adoption. 5. Configure an approved package index explicitly and prevent untrusted extra indexes from participating in resolution. 6. Use binary distributions from trusted sources where appropriate, while still verifying hashes. 7. Run PDF parsing with least privilege and, for sensitive deployments, inside a sandbox or isolated container without unnecessary credentials or filesystem access. 8. Update the error message in `scripts/extract_pdf.py` so it points to the locked installation procedure rather than recommending an unpinned command. ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
Findings (1)

Missing User Warnings

Medium
Confidence
92% confidence
Finding
The example instructs users to POST a locally generated `document` object to a remote API endpoint, but it does not provide any warning that document contents may include sensitive data and will be transmitted off-host. In a PDF-analysis skill, users are especially likely to handle confidential contracts, reports, or personal records, so the omission can lead to unintended disclosure even if the API itself is legitimate.

Static analysis

No suspicious patterns detected.