Back to skill

Security audit

PDF OCR Using Gemini LLM

Security checks for vulnerabilities and agentic risk

Overview

This is a disclosed Gemini-based PDF OCR skill, with privacy and dependency-pinning cautions but no hidden or destructive behavior found.

Before installing, confirm you are comfortable sending PDF page content to Google Gemini and avoid highly sensitive documents unless that is acceptable for your environment. Use an isolated virtual environment, consider pinning or locking dependency versions before production use, and be aware that --output writes to the path you provide.

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
requirements.txt:5
Finding

Unpinned Third-Party Dependencies Permit Supply-Chain Substitution

Content
View full analysis

Vulnerability Details

File Location: requirements.txt:5-12
Vulnerability Type: Unpinned and integrity-unverified dependencies
Risk Level: Medium

Vulnerable Code

text
# Gemini API
google-genai

# PDF Processing
pymupdf

# Pydantic
pydantic-settings
pydantic

The installation instructions execute:

bash
pip install -r requirements.txt

Related locations include SKILL.md:10-19, SKILL.md:34-35, and skill.json:7.

Technical Analysis

Every third-party dependency is declared without an exact version. The project also has no reviewed lockfile, package hashes, or enforced integrity verification. Consequently, each installation resolves whatever compatible release the configured Python package index serves at that time.

The package names are consistent with the documented libraries, and the audit found no evidence that the current names are intentionally malicious. However, the installation process remains mutable. A compromised upstream release, account takeover, malicious package-index configuration, or dependency-resolution change could cause users to install code that was never reviewed as part of this Skill.

Python packages execute imported code at runtime and may also exercise installation-time build behavior. Dependency substitution can therefore turn the documented setup command into a code-execution path.

Attack Path

  1. An attacker compromises a declared package, one of its transitive dependencies, or the package index used by the victim.
  2. The attacker publishes or serves a malicious release that satisfies the unrestricted dependency declaration.
  3. A user follows SKILL.md:35 or skill.json:7 and runs pip install -r requirements.txt.
  4. Because no versions or hashes are enforced, pip accepts the attacker-controlled artifact.
  5. Malicious code executes during installation, import, or normal Skill operation.
  6. The code runs with the privileges of the user installing or invoking the Skill.

Impact

...[truncated 606 chars]

Remediation
View remediation

Remediation Suggestions

  1. Pin every direct dependency to an exact, reviewed version, for example with package==X.Y.Z.
  2. Generate a lockfile that records the complete transitive dependency graph.
  3. Require cryptographic hashes during installation, such as a pip-compatible requirements file used with pip install --require-hashes.
  4. Obtain packages exclusively from an explicitly configured trusted index and enforce TLS certificate validation.
  5. Review dependency provenance and release changes before updating locked versions.
  6. Add automated vulnerability and supply-chain scanning to the release process.
  7. Test dependency updates in an isolated environment before publishing them.
  8. Update SKILL.md and skill.json so all documented installation paths use the same locked, hash-verified dependency set.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (13)

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

The declared description says the skill extracts text from PDFs using Google Gemini OCR, implying OCR/text-recognition behavior and likely interaction with Gemini services. The supplied code chunk does neither. It only sanitizes filenames and splits an input PDF into separate single-page PDF files on disk. This is a materially different primary purpose from OCR/text extraction, so the description does not accurately represent the code.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
91% confidence
Finding

The skill explicitly instructs the agent to activate a local environment, write output files, and send document content to Google's API, but it does not declare any tool scope such as file-write or network permissions. This creates a transparency and governance gap: an agent may perform sensitive file and network operations without the skill metadata clearly constraining or disclosing them to policy enforcement systems.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

This code uploads the entire PDF to Google Gemini (aclient.files.upload) for OCR without any indication in this file that users are warned, consent is obtained, or sensitive-document handling restrictions are enforced. In an OCR skill, documents commonly contain PII, financial, medical, or proprietary data, so silent transmission to a third-party API creates a real privacy and compliance risk even if the implementation is otherwise expected for cloud OCR.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This code file invokes a cloud OCR service to process user-supplied PDFs, which implies transmitting document contents off the local system. While the CLI description mentions Google Gemini OCR, there is no explicit warning, confirmation, or privacy disclosure near the processing step to alert users that their files may be sent to an external service.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

This service sends PDF page content to an external Gemini cloud OCR provider via ocr_pdf_page_async, which can expose potentially sensitive document contents to a third party. In an OCR skill, cloud transmission is functionally expected, but the absence of any consent, disclosure, data-classification check, or documented safeguard in this service increases privacy and compliance risk for users who may assume local-only processing.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
80% confidence
Finding

The code writes OCR results to a user-specified file path, which is a file-write operation covered by the warning requirement for code files. Although the --output argument indicates that a file will be written, there is no runtime notice, confirmation, or broader warning in comments/docstrings describing this side effect.

Content

No source excerpt is available for this finding.

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
96% confidence
Finding

The dependency google-genai is unpinned, which makes builds non-reproducible and allows future installs to silently pull newer releases with breaking changes or newly introduced malicious behavior. In a skill that sends document content to an external LLM provider, dependency drift increases supply-chain risk because core parsing and API behavior directly affect sensitive document handling.

Content

Scanner excerpt · requirements.txt (reported line 5)May include surrounding context.

text
# OCR PDF processing with Google Gemini

# Gemini API
google-genai

# PDF Processing
pymupdf

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
99% confidence
Finding

The dependency pymupdf is unpinned, and this package is directly involved in processing attacker-controlled PDF input. Because PDF parsing libraries are high-risk attack surfaces and PyMuPDF has known advisories, failing to pin a vetted version materially increases the chance of installing a vulnerable release.

Content

Scanner excerpt · requirements.txt (reported line 8)May include surrounding context.

text
google-genai

# PDF Processing
pymupdf

# Pydantic
pydantic-settings

Unverifiable Dependency: pymupdf has 2 known advisory(ies) (CVE-2026-3029 (PyMuPDF has a path traversal in _main_.py); CVE-2026-3029 (PyMuPDF has a path traversal in _main_.py)), but the manifest does not pin a version, so it is unknown whether the installed release is affected

Low
Category
Supply Chain
Confidence
98% confidence
Finding

PyMuPDF has referenced advisories for path traversal, and because the manifest does not pin a version, it is impossible to verify whether deployments are using a vulnerable release. This is more dangerous in an OCR/PDF skill because the library processes untrusted document content and may expose filesystem interaction paths during document handling or CLI-related usage.

Content

No source excerpt is available for this finding.

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
95% confidence
Finding

The dependency pydantic-settings is unpinned, which creates uncertainty about which code is actually installed and whether it contains known flaws. Although settings handling is not the primary attack surface here, configuration libraries can affect secret loading and filesystem behavior, so uncontrolled upgrades remain a supply-chain concern.

Content

Scanner excerpt · requirements.txt (reported line 11)May include surrounding context.

text
pymupdf

# Pydantic
pydantic-settings
pydantic

Unverifiable Dependency: pydantic-settings has 1 known advisory(ies) (CVE-2026-58203 (pydantic-settings: NestedSecretsSettingsSource follows symlinks outside secrets_)), but the manifest does not pin a version, so it is unknown whether the installed release is affected

Low
Category
Supply Chain
Confidence
93% confidence
Finding

pydantic-settings has a known advisory involving NestedSecretsSettingsSource following symlinks outside the intended secrets directory, and the unpinned manifest prevents verification that a safe version is installed. If this skill uses file-based secret loading in deployment, a vulnerable version could lead to unintended secret exposure from the filesystem.

Content

No source excerpt is available for this finding.

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
95% confidence
Finding

The dependency pydantic is unpinned, so installations may resolve to versions with different security and parsing behavior. Since pydantic commonly processes structured input and has had past denial-of-service issues, leaving it unpinned weakens build integrity and can expose the application to avoidable risk.

Content

Scanner excerpt · requirements.txt (reported line 12)May include surrounding context.

text
# Pydantic
pydantic-settings
pydantic

Unverifiable Dependency: pydantic has 4 known advisory(ies) (CVE-2021-29510 (Use of "infinity" as an input to datetime and date fields causes infinite loop i); CVE-2024-3772 (Pydantic regular expression denial of service); CVE-2021-29510 (Pydantic is a data validation and settings management using Python type hinting.) +1 more), but the manifest does not pin a version, so it is unknown whether the installed release is affected

Low
Category
Supply Chain
Confidence
94% confidence
Finding

pydantic has multiple known advisories, including denial-of-service issues, and without version pinning there is no assurance that deployments avoid affected releases. While this is not as directly exposed as the PDF parser, pydantic may still process attacker-influenced data or configuration, making unverifiable versions a legitimate security concern.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.