Back to skill

Security audit

OCR Locally

Security checks for vulnerabilities and agentic risk

Overview

This is a local macOS OCR skill that reads user-selected image or PDF files and may write OCR output files, with some documentation and robustness issues but no hidden network, persistence, or unrelated authority.

Install only if you are using macOS and are comfortable giving the skill local files to OCR. Use explicit OCR languages and output paths, avoid reusing filenames you care about, and prefer the dedicated PDF script for PDF files. Invalid PDF page ranges may crash or hang the OCR run, so use simple validated ranges such as 1-5.

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/pdf_ocr.swift:259
Finding

Reversed PDF Page Range Causes a Process Crash

Content
View full analysis
= 1 { pages.append(page) } } } } ``` ### Technical Analysis The page-range parser accepts user-controlled start and end values but does not verify that the start is less than or equal to the effective end. Swift's closed-range operator requires its lower bound not to exceed its upper bound. For example, the input `5-1` evaluates the following expression: ```swift 5...1 ``` Constructing this invalid range triggers a Swift runtime precondition failure and terminates the process. Limiting the end with `min(end, totalPages)` does not prevent the problem and can also make an otherwise increasing range invalid when the start exceeds the document's page count. ### Attack Path 1. An attacker or untrusted caller provides a valid PDF and a reversed or invalid page range, such as: ```bash swift scripts/pdf_ocr.swift document.pdf -p 5-1 ``` 2. `parsePages` converts the two range components to integers. 3. The script evaluates `start...min(end, totalPages)` without validating their order. 4. Swift raises a fatal runtime error. 5. The OCR process terminates before returning a result. ### Impact Assessment The issue affects process availability. It allows an untrusted page-range argument to reliably crash the OCR invocation and interrupt the current Agent task. The vulnerability does not provide code execution, privilege escalation, persistence, or access to additional files. Its s ...[truncated 108 chars]
Remediation
View remediation
= 1, end >= start, start <= totalPages else { // Reject the range and return a clear validation error. continue } let effectiveEnd = min(end, totalPages) for page in start...effectiveEnd { pages.append(page) } ``` Additional hardening should include: 1. Return an explicit error for malformed or reversed ranges instead of silently treating them as all pages. 2. Reject negative, zero, empty, and excessively large page values. 3. Deduplicate parsed page numbers before processing. 4. Add tests for `5-1`, `0-1`, `999-1000`, empty ranges, malformed ranges, and ranges beyond the document page count. 5. Distinguish an invalid page specification from the absence of a page specification so invalid input cannot unexpectedly fall back to processing every page. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/pdf_ocr.swift:153
Finding

Unsignaled Semaphore Can Indefinitely Block PDF OCR

Content
View full analysis
Remediation
View remediation
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (12)

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The instruction to default to zh-Hans,en for Chinese users or en for English users imposes a locale/language behavior based on inference rather than explicit user preference. The policy allows language constraints only when the skill offers a choice or clearly justifies the constraint.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The PDF-processing instructions set a default language list of zh-hans,zh-hant,en without asking the user to choose or confirm. This is a natural-language locale policy issue because it forces a language configuration rather than offering user control.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The script's comments and all user-facing messages are written in Chinese, and the usage output assumes a Chinese-speaking user. This creates a language/locale policy issue because the tool does not offer any user choice or opt-in for language selection.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The usage text and manifest both indicate PDF text extraction is supported, but the implementation loads input exclusively via NSImage(contentsOfFile:), then converts it to CGImage for Vision OCR. This path is suitable for image files, not general PDF document text extraction, so the actual behavior is narrower than the declared capability.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The recognition language list is fixed to zh-Hans, zh-Hant, and en, which imposes a locale/language constraint in the skill behavior. Because the script does not let the user choose languages or document a justified region-specific limitation, this matches the policy category for forced language/locale behavior.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

Comments, error messages, status output, and the full usage/help text are presented only in Chinese throughout the script. This creates a language-policy issue because the skill imposes a specific language on users without opt-in, fallback, or documented justification for being region-specific.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The manifest explicitly claims support for both image OCR and PDF text extraction using Vision/PDFKit frameworks. In code, input is loaded only with NSImage(contentsOfFile:), and all downstream processing uses VNImageRequestHandler on a CGImage; there is no PDFKit usage or PDF page handling despite the help text also claiming PDF support.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The usage text states '支持格式: PNG, JPEG, TIFF, BMP, PDF', which tells users PDF input is supported. However, the actual implementation loads the file as an NSImage and never uses PDFKit or any PDF-specific extraction logic, so the documentation actively overstates what the code does.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

All user-facing messages, errors, status output, and usage instructions are written in Chinese, while the tool itself supports multiple OCR languages and does not indicate that the interface is intentionally China-specific. This creates a natural-language policy concern because the script imposes a specific language/locale on users without opt-in or alternative output options.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
87% confidence
Finding

The skill explicitly instructs writing OCR results to user-specified output files but does not warn about file creation or overwriting. In an agent setting, this can cause unintended data loss or clobber existing files if the path is incorrect or reused, even though the content being written is not inherently dangerous.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
83% confidence
Finding

The usage guide shows console output headings and labels in Chinese, which indicates the skill may emit a fixed locale-specific output format. Because the document does not state that users can select output language or that Chinese output is intentional and optional, this creates a natural-language locale policy concern.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
80% confidence
Finding

The PDF OCR section includes page output examples labeled in Chinese, suggesting the skill may force a specific output language or locale. The surrounding text does not explain whether this is merely an example, a default that can be changed, or a required locale, so the documentation may violate language-choice expectations.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.