Back to skill

Security audit

ifly-pdf-image-ocr

Security checks for vulnerabilities and agentic risk

Overview

This is a straightforward iFlytek cloud OCR skill, but users should understand that selected images or PDFs are sent to iFlytek for processing.

Install only if you are comfortable sending chosen images, PDFs, or PDF URLs to iFlytek's cloud OCR service. Avoid processing confidential legal, medical, financial, or proprietary documents unless your iFlytek account and data-handling terms are acceptable, and keep the API credentials and generated logs protected.

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

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/image_ocr.py:69
Finding
Authentication Credential Material Exposed in Request URL<![CDATA[ ## Vulnerability Details **File Location**: `scripts/image_ocr.py`, lines 69–81 and 135–140 **Vulnerability Type**: Authentication material exposure through URL query parameters **Risk Level**: Medium ### Vulnerable Code ```python # Build authorization string authorization = f'hmac username="{self.api_key}", algorithm="hmac-sha256", headers="host date request-line", signature="{signature}"' authorization_base64 = base64.b64encode(authorization.encode('utf-8')).decode('utf-8') # Build final URL with query parameters params = { 'authorization': authorization_base64, 'host': host, 'date': date } return f"{self.API_HOST}?{urlencode(params)}" ``` The generated URL is subsequently used for the network request: ```python # Send request response = requests.post( auth_url, json=request_data, headers={"Content-Type": "application/json"}, timeout=60 ) ``` ### Technical Analysis The authorization value contains the API key identifier and an HMAC signature: ```text hmac username="<API key>", algorithm="hmac-sha256", ..., signature="<signature>" ``` This value is Base64-encoded and placed in the URL query string. Base64 is an encoding mechanism, not encryption, so any party that obtains the URL can decode the authorization value without a secret. URLs are frequently recorded by reverse proxies, HTTP debugging infrastructure, application-performance monitoring systems, exception handlers, server access logs, and network observability products. HTTPS protects the request while it is transmitted, but it does not prevent the complete URL from being recorded at endpoints or trusted intermediary infrastructure. The API secret itself is not directly included in the URL. Furthermore, the signature contains a date and may therefore have a limited replay window. These constraints limit the scope of exploitation, but they do not eliminate disclosure of the API key identifier or possible replay of captured signed requests. This behavio ...[truncated 1993 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. **Prefer an authorization header** - Confirm whether the iFlytek endpoint supports authentication through the standard `Authorization` header or another dedicated header. - If supported, place the authorization value in that header instead of the query string. 2. **Redact authentication query parameters** - If the vendor protocol requires query-string authentication, configure clients, proxies, gateways, monitoring systems, and server logs to redact the `authorization` parameter. - Ensure exception-reporting and tracing systems do not capture the complete authenticated URL. 3. **Avoid exposing the generated URL** - Do not print, serialize, persist, or include `auth_url` in errors or diagnostic output. - Add an explicit URL-sanitization helper for any future logging. 4. **Restrict log access and retention** - Apply least-privilege access controls to proxy, application, and observability logs. - Minimize retention of records containing query strings. - Encrypt retained logs and audit access to them. 5. **Strengthen replay resistance** - Use the shortest timestamp validity period supported by the service. - Where supported, include a unique request nonce or request identifier in the signed material. - Monitor for repeated use of identical signatures. 6. **Rotate potentially exposed credentials** - If authenticated URLs may already have entered logs, review those systems and rotate the affected API key and secret as a precaution. ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (11)

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding
The code clearly supports image OCR: it reads an image file, base64-encodes it, submits it to an OCR endpoint, and prints or saves the recognized text. That aligns with the image OCR portion of the description. However, the declared purpose substantially expands scope to PDF recognition and PDF conversion use cases, including PDF to Word/Markdown. This code chunk contains no PDF parsing, no PDF upload handling, no conversion to Word, and no interface suggesting PDF inputs. The only accepted positional argument is an image path, and the payload field is explicitly 'image'. Therefore the description overstates the implemented capabilities in a material way.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding
The code’s primary purpose is PDF OCR task submission and polling against the iFlytek PDF OCR API. That aligns with the PDF-recognition and PDF-to-Word/Markdown parts of the description. However, the description explicitly claims support for both image OCR and PDF OCR, while this code only processes PDFs and has no image input handling, image endpoints, or image OCR workflow. The extra claims about multilingual extraction and layout understanding may be properties of the backend service, but they are not demonstrated by this code chunk. Because a major declared capability—image OCR—is absent from the actual implementation shown, this is a description-behavior mismatch.

Missing User Warnings

High
Confidence
98% confidence
Finding
The skill sends images, PDFs, and possibly URL-referenced documents to an external OCR service, but the description does not clearly disclose this data transfer. For OCR workflows, inputs commonly contain personal, legal, financial, or proprietary information, so lack of disclosure can lead to unintentional exfiltration of highly sensitive documents to a third party.

Lp3

Medium
Category
MCP Least Privilege
Confidence
88% confidence
Finding
The skill documentation advertises capabilities that require environment access, file writes, and network communication, but it does not declare any explicit tool scope or permissions boundaries. This increases the chance an agent invokes the skill with broader-than-expected privileges, making accidental exfiltration of OCR inputs, secrets, or output files more likely.

Vague Triggers

Medium
Confidence
95% confidence
Finding
The activation language is extremely broad ('any OCR tasks on images or PDFs'), which can cause the skill to trigger for many ordinary user requests without clear user intent to send files to a third-party OCR provider. In this context, broad routing is more dangerous because the skill processes sensitive documents and may upload local files or fetch public URLs over the network.

Missing User Warnings

Medium
Confidence
89% confidence
Finding
The examples encourage saving OCR output and generating converted files without warning that the skill will create local artifacts containing extracted document contents. This can leave sensitive OCR text or converted documents persisted on disk unexpectedly, increasing exposure through other tools, backups, or multi-user environments.

Natural-Language Policy Violations

Medium
Confidence
91% confidence
Finding
The response examples and error-code help sections contain Chinese-only strings such as "成功", "任务创建成功", and Chinese troubleshooting text, while the rest of the document is primarily English. This creates an implicit language constraint without opt-in or explanation, which can violate language/locale policy expectations.

External Transmission

Medium
Category
Data Exfiltration
Content
auth_url = self._generate_auth_url()

        # Send request
        response = requests.post(
            auth_url,
            json=request_data,
            headers={"Content-Type": "application/json"},
Confidence
88% confidence
Finding
The requests.post call sends the OCR payload, including base64-encoded image contents and metadata, to an external service. Although external transmission is expected for a cloud OCR client and the endpoint uses HTTPS with HMAC-based authentication, it remains a genuine data exposure boundary because any sensitive document content is disclosed to a remote provider.

Missing User Warnings

Medium
Confidence
92% confidence
Finding
The code uploads the full image contents to a third-party OCR endpoint, but the script provides no explicit disclosure, consent prompt, redaction guidance, or data-handling warning before transmitting potentially sensitive user documents. In an OCR skill, this behavior is functionally necessary, but it still creates a real privacy and compliance risk if users process IDs, financial records, medical documents, or other confidential images without understanding that data leaves the local environment.

Missing User Warnings

Medium
Confidence
95% confidence
Finding
The code uploads user-supplied PDF content or passes a user-provided PDF URL to a third-party OCR endpoint without any explicit warning, consent flow, or privacy notice at the point of use. Because OCR inputs often contain sensitive documents, this can lead to unintended disclosure of confidential data to an external service and associated retention/compliance risks.

Context-Inappropriate Capability

Low
Confidence
77% confidence
Finding
The manifest frames this skill as an OCR and document-recognition capability for images/PDFs, but this script also accesses process environment variables to obtain external-service credentials. While this may be operationally necessary for the vendor API, credential harvesting from environment state is not part of the user-facing OCR purpose and is not declared in the manifest text.

Static analysis

No suspicious patterns detected.