Back to skill

Security audit

ifly-ocr-invoice

Security checks for vulnerabilities and agentic risk

Overview

The skill does what it claims, but its troubleshooting instructions can expose iFlytek API secrets and it handles sensitive invoice data through a third-party OCR API.

Review before installing. This skill is appropriate only if you are comfortable sending invoice or receipt images, potentially including medical, bank, tax, or other sensitive financial details, to iFlytek's OCR service. Do not run or share the documented echo commands that print XFYUN_API_SECRET or XFYUN_API_KEY; use presence-only or masked checks instead, and rotate credentials if they were exposed in logs, screenshots, or support chats.

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
SKILL.md:147
Finding
Authentication Secrets Exposed by Troubleshooting Commands## Vulnerability Details **File Location**: `SKILL.md`, lines 147–153 **Vulnerability Type**: Plaintext sensitive-data exposure **Risk Level**: Medium ### Vulnerable Code ```bash # macOS / Linux: echo "XFYUN_APP_ID: $XFYUN_APP_ID | XFYUN_API_KEY: $XFYUN_API_KEY | XFYUN_API_SECRET: $XFYUN_API_SECRET" # Windows cmd: echo XFYUN_APP_ID: %XFYUN_APP_ID% ^|^| XFYUN_API_KEY: %XFYUN_API_KEY% ^|^| XFYUN_API_SECRET: %XFYUN_API_SECRET% ``` ### Technical Analysis The troubleshooting instructions tell users to print the complete values of `XFYUN_API_KEY` and `XFYUN_API_SECRET` to the terminal. This unnecessarily converts credentials stored in environment variables into plaintext output. Terminal output can be exposed through CI logs, shell-session recording, screen sharing, screenshots, copied support transcripts, or other process-output collection. Verifying whether an environment variable is configured requires only a presence check; displaying its full value exceeds the minimum disclosure needed for troubleshooting. The runtime implementation itself reads only the documented credentials and uses the API secret locally to create an HMAC-SHA256 signature. No direct runtime transmission of the unencoded API secret was identified. ### Attack Path 1. A user encounters an authentication failure and follows the documented troubleshooting procedure. 2. The user runs the provided command, causing the full application ID, API key, and API secret to appear in terminal output. 3. That output is retained in a CI log, terminal recording, screenshot, screen-sharing session, or support transcript. 4. An attacker or unauthorized observer obtains access to the retained output. 5. The attacker extracts the credentials and uses them to generate valid authentication signatures for iFlytek API requests. 6. The attacker can consume the victim's OCR quota or paid service allowance and make requests under the victim's application identity until the credentials are revoked. ### Impact A ...[truncated 850 chars]
Remediation
## Remediation Suggestions Replace commands that print credential values with presence-only checks. For example: ```bash for variable in XFYUN_APP_ID XFYUN_API_KEY XFYUN_API_SECRET; do if [ -n "$(printenv "$variable")" ]; then printf '%s is set\n' "$variable" else printf '%s is missing\n' "$variable" fi done ``` For Windows PowerShell, use: ```powershell 'XFYUN_APP_ID', 'XFYUN_API_KEY', 'XFYUN_API_SECRET' | ForEach-Object { if ([string]::IsNullOrEmpty([Environment]::GetEnvironmentVariable($_))) { "$_ is missing" } else { "$_ is set" } } ``` Apply the following additional controls: 1. Remove all documentation that asks users to print, screenshot, or share complete secrets. 2. Instruct users to redact credentials and signed authorization query parameters before sharing diagnostic output. 3. Recommend immediate credential rotation if the existing troubleshooting commands were run in recorded or shared environments. 4. Prefer a dedicated secret manager or protected CI secret store over plaintext shell startup files. 5. Add a safe diagnostic option to the script that reports only whether each required variable is present. 6. Document that invoice images may contain sensitive personal and financial information and are transmitted to the third-party iFlytek service.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (8)

Lp3

Medium
Category
MCP Least Privilege
Confidence
88% confidence
Finding
The skill documents use of environment variables and a remote API endpoint, but declares no tool scope or permissions metadata. That omission can cause an agent platform or user to underestimate that the skill will access secrets and transmit document contents off-host, weakening review and consent controls.

Ssd 3

Medium
Confidence
99% confidence
Finding
The provided troubleshooting commands explicitly echo secret environment-variable values, including the API secret. In the context of an agent skill, users may run these commands verbatim and then paste output back into support channels, causing direct credential disclosure and possible account abuse.

Missing User Warnings

Medium
Confidence
98% confidence
Finding
The troubleshooting guidance tells users to print XFYUN_APP_ID, XFYUN_API_KEY, and XFYUN_API_SECRET directly to the terminal. This risks exposing credentials in shell history, terminal scrollback, screen sharing, logs, or copied support transcripts, enabling unauthorized API use if the values are observed or retained.

External Transmission

Medium
Category
Data Exfiltration
Content
from urllib.parse import urlencode, urlparse
from wsgiref.handlers import format_date_time

API_URL = "https://api.xf-yun.com/v1/private/sc45f0684"


def build_auth_url(request_url: str, api_key: str, api_secret: str, method: str = "POST") -> str:
Confidence
60% confidence
Finding
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

External Transmission

Medium
Category
Data Exfiltration
Content
from urllib.parse import urlencode, urlparse
from wsgiref.handlers import format_date_time

API_URL = "https://api.xf-yun.com/v1/private/sc45f0684"


def build_auth_url(request_url: str, api_key: str, api_secret: str, method: str = "POST") -> str:
Confidence
60% confidence
Finding
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Missing User Warnings

Medium
Confidence
93% confidence
Finding
The script base64-encodes the supplied invoice image and sends it to a third-party OCR endpoint, which can expose sensitive financial and personal data contained in invoices, receipts, and medical or bank documents. While this is the intended functionality, the absence of an explicit user-facing disclosure or consent step makes the data transfer a real privacy/security issue, especially given the highly sensitive document types supported by the skill.

Natural-Language Policy Violations

Low
Confidence
87% confidence
Finding
The description states the tool extracts fields from Chinese invoices and the document's user-facing examples and troubleshooting sections are written in Chinese, but it does not explicitly tell users that the interaction/output is Chinese-only or offer a language preference. This can violate language/locale policy when a skill forces a specific language without opt-in.

Natural-Language Policy Violations

Low
Confidence
86% confidence
Finding
The formatter hard-codes Chinese labels such as '票据类型', which forces a specific output language regardless of user preference. The file does not provide an opt-in, locale switch, or justification that this tool is intentionally limited to Chinese-language usage.

Static analysis

No suspicious patterns detected.