Back to skill

Security audit

文本识别OCR(增强版)

Security checks for vulnerabilities and agentic risk

Overview

This OCR skill appears purpose-aligned, but needs review because it sends user images to a third-party API and stores the user's API key in a local plaintext .env file.

Install only if you are comfortable sending OCR images and your Xiaobenyang API key to this provider. Do not use it for highly sensitive documents unless you understand the provider's handling of the data, and remove or protect the generated .env file if you stop using the skill or rotate the key.

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

Warning
Location
scripts/config.py:45
Finding

API Key Persisted in Plaintext Without Restrictive File Permissions

Content
View full analysis
bool: """将API key保存到.env文件""" try: env_path = Path(".env") lines = [] if env_path.exists(): lines = env_path.read_text(encoding="utf-8").splitlines() found = False new_lines = [] for line in lines: if line.startswith("XBY_APIKEY="): new_lines.append(f"XBY_APIKEY={api_key}") found = True else: new_lines.append(line) if not found: new_lines.append(f"XBY_APIKEY={api_key}") env_path.write_text("\n".join(new_lines) + "\n", encoding="utf-8") os.environ["XBY_APIKEY"] = api_key return True except Exception as e: print(f"保存API key失败: {e}") return False ``` ### Technical Analysis The function stores the user-provided API key directly in a plaintext `.env` file. `Path.write_text()` does not explicitly enforce owner-only permissions; newly created permissions depend on the process umask, while an existing file retains its current permissions. The implementation also does not verify whether `.env` is a symbolic link before overwriting it. Consequently, the credential may be exposed to other local users or processes that can read the project directory. The file may also be copied into backups or accidentally committed if repository exclusion controls are absent. If an attacker can manipulate the working directory and create a `.env` symlink, the write may be redirected to another file writable by the Skill process. ### Attack Path 1. A user supplies a valid Xiaobenyang API key as required by the Skill. 2. `set_api_key()` passes the credential to `save_api_key_to_env()`. 3. The function writes `XBY_APIKEY= ...[truncated 1051 chars]
Remediation
View remediation

T08 · Insecure Dependencies

Note
Location
requirements.txt:1
Finding

Unpinned Third-Party Dependencies Permit Unreviewed Package Updates

Content
View full analysis
=2.31.0 pydantic>=2.7.0 pydantic-settings>=2.2.0 python-dotenv>=1.0.1 ``` ### Technical Analysis All dependencies use open-ended minimum-version constraints. A future installation can therefore resolve to package releases that were not present during review. This makes builds non-reproducible and may introduce incompatible major releases, newly disclosed vulnerabilities, or compromised package versions without a corresponding project change. The listed package names are established packages, and the audited files contain no evidence of dependency confusion, typosquatting, or an actively malicious release. The issue is the absence of version locking and integrity verification, which increases exposure if an upstream account, release process, or package version is compromised. ### Attack Path 1. An attacker compromises an allowed upstream package release or publishes a release containing malicious installation or runtime behavior. 2. A user installs the Skill dependencies after that release becomes the newest version satisfying the `>=` constraint. 3. The package manager resolves and downloads the unreviewed release because no upper bound, lock file, or hash restriction prevents it. 4. Malicious package code executes during installation, import, or normal Skill operation. 5. The code runs with the privileges of the user or service account installing or executing the Skill. ### Impact Assessment A compromised resolved dependency could execute arbitrary Python code with the privileges of the Skill installer or runtime process. Depending on those privileges, this could expose environment variables, the stored API key, accessible files, network credentials, and other data available to the process. It could also alter OCR requests or respo ...[truncated 175 chars]
Remediation
View remediation
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • 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
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
Findings (31)

Tp2

High
Category
MCP Tool Poisoning
Confidence
85% confidence
Finding

Mixing characters from multiple Unicode scripts in a single identifier is a common technique to create visually ambiguous tool names.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

The skill claims OCR-only behavior, yet the documented structure includes local .env modification and API-key configuration management tied to unrelated service naming. Persistent credential handling and local configuration mutation exceed typical OCR expectations and create risk of secret exposure, unauthorized reuse, or hidden cross-skill behavior.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

The skill claims OCR-only behavior, yet the documented structure includes local .env modification and API-key configuration management tied to unrelated service naming. Persistent credential handling and local configuration mutation exceed typical OCR expectations and create risk of secret exposure, unauthorized reuse, or hidden cross-skill behavior.

Content

No source excerpt is available for this finding.

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/config.py (reported line 13)May include surrounding context.

python
model_config = SettingsConfigDict(
        env_prefix="XBY_GAOKAO_",
        env_file=".env",
        env_file_encoding="utf-8",
        extra="ignore",
    )

Credential Access

High
Category
Privilege Escalation
Confidence
94% confidence
Finding

This code forcibly reads XBY_APIKEY directly from a local .env file, bypassing cleaner secret-management boundaries and increasing the chance that credentials are harvested from the working directory. In the context of an OCR skill, proactively scraping local credential files is more suspicious because it is unrelated to core image recognition functionality.

Content

Scanner excerpt · scripts/config.py (reported line 31)May include surrounding context.

python
default_year: int = 2025

    def model_post_init(self, __context):
        # 强制从 .env 文件读取 XBY_APIKEY
        env_path = Path(".env")
        if env_path.exists():
            content = env_path.read_text(encoding="utf-8")

Credential Access

High
Category
Privilege Escalation
Confidence
94% confidence
Finding

Opening and reading the entire .env file to extract a specific key unnecessarily broadens access to all locally stored secrets in that file. Even if only one value is used, the implementation normalizes direct secret-file access in a skill whose declared purpose does not justify credential-file inspection.

Content

Scanner excerpt · scripts/config.py (reported line 32)May include surrounding context.

python
def model_post_init(self, __context):
        # 强制从 .env 文件读取 XBY_APIKEY
        env_path = Path(".env")
        if env_path.exists():
            content = env_path.read_text(encoding="utf-8")
            for line in content.splitlines():

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/config.py (reported line 39)May include surrounding context.

python
if line.startswith("XBY_APIKEY="):
                    self.api_key = line.split("=", 1)[1].strip()
                    break
        # 如果环境变量有值,覆盖 .env 的值
        env_val = os.getenv("XBY_APIKEY", "")
        if env_val:
            self.api_key = env_val

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The code persists an API key to a local .env file and mirrors it into process environment state, even though the skill is presented as simple OCR. Writing credentials to disk creates a durable secret exposure risk through accidental commit, local file disclosure, shared workspace leakage, or reuse by unrelated components.

Content

No source excerpt is available for this finding.

Credential Access

High
Category
Privilege Escalation
Confidence
98% confidence
Finding

This function explicitly saves an API key into a plaintext .env file, creating durable local credential exposure. In an OCR skill context, persistent secret storage is more dangerous because it is outside reasonable user expectations for a document/image processing tool and can facilitate compromise of the associated external service if the file is leaked.

Content

Scanner excerpt · scripts/config.py (reported line 48)May include surrounding context.

python
def save_api_key_to_env(api_key: str) -> bool:
    """将API key保存到.env文件"""
    try:
        env_path = Path(".env")
        lines = []
        if env_path.exists():
            lines = env_path.read_text(encoding="utf-8").splitlines()

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
93% confidence
Finding

The skill declares no explicit tool scope or permissions while its documented/project capabilities imply access to environment variables, local file reads/writes, and outbound network calls. In an agent setting, missing scope boundaries increases the risk of over-privileged execution and makes it harder for reviewers or users to understand what the skill can access.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The skill asks users to provide image URLs or base64-encoded image content for OCR but does not clearly warn that this data will be transmitted to an external API service. This creates a privacy and data-handling risk, especially if images contain personal, financial, or confidential information.

Content

No source excerpt is available for this finding.

Ssd 3

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The workflow instructs the agent to solicit a user API key and persist it via local configuration, likely into .env or equivalent storage. Collecting and storing user-supplied secrets in this manner is dangerous because it can expose credentials to logs, other skills, local file readers, or future sessions beyond the user's intent.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

References to unrelated gaokao/school-search functionality in workflow examples indicate copy-paste drift and undermine confidence that the documented routing behavior matches the actual skill. Such inconsistencies can conceal unsafe actions, cause wrong-tool invocation, or lead reviewers to miss broader capabilities.

Content

No source excerpt is available for this finding.

Ssd 3

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The instruction to directly present raw API/OCR output may expose sensitive text extracted from user images, including personal identifiers, secrets, or confidential document contents. Raw output may also contain metadata or fields not necessary for the user-facing result, increasing accidental disclosure risk.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The skill metadata claims this is an OCR capability, but the configuration is for an unrelated 'Gaokao' service with a hardcoded external endpoint and service identifier. This mismatch is dangerous because it expands the skill's effective trust boundary beyond text recognition and can conceal unexpected network access or data routing to a third-party backend.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

Instead of OCR logic, this file implements credential loading, persistence, and external service configuration, which materially differs from the advertised skill behavior. That discrepancy is risky because users may grant access expecting local image-to-text processing while the skill actually manages secrets for remote service interaction.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The function silently writes the supplied API key to disk without any warning, consent flow, or disclosure that credentials will be stored in plaintext in .env. This can lead to users unintentionally persisting sensitive secrets in insecure locations, increasing the chance of leakage through backups, logs, repository commits, or multi-user systems.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The function transmits user-supplied image data via URL to an external API endpoint, but this file provides no user-facing disclosure, consent flow, or data-handling warning. OCR inputs often contain sensitive information such as IDs, financial records, or screenshots, so silent third-party transfer creates a real privacy and data-governance risk even if the functionality is expected.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
98% confidence
Finding

This function sends raw base64-encoded image contents directly to an external API, which may include highly sensitive document or screenshot data. Because the transfer is not disclosed in this file and no minimization or consent mechanism is evident, users may unknowingly exfiltrate private content to a third party.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
77% confidence
Finding

All user-facing instructions and descriptions in the skill are written in Chinese, and there is no statement offering multilingual support or clarifying that the skill is intentionally limited to Chinese-speaking users. Under the policy, forcing a specific language without user opt-in can be a natural-language policy violation.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
91% confidence
Finding

The project structure names the package as a gaokao skill rather than an OCR skill, which suggests repurposed or mispackaged code. While not directly exploitable alone, this inconsistency increases supply-chain and review risk because the true purpose and boundaries of the skill become unclear.

Content

No source excerpt is available for this finding.

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
95% confidence
Finding

The dependency is specified with a lower bound only (requests>=2.31.0), which makes builds non-reproducible and allows future installs to pull different versions over time. This increases supply-chain risk and makes it impossible to verify whether a deployed environment is using a vulnerable or safe release of requests.

Content

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

text
requests>=2.31.0
pydantic>=2.7.0
pydantic-settings>=2.2.0
python-dotenv>=1.0.1

Unverifiable Dependency: requests has 16 known advisory(ies) (CVE-2014-1830 (Exposure of Sensitive Information to an Unauthorized Actor in Requests); CVE-2024-47081 (Requests vulnerable to .netrc credentials leak via malicious URLs); CVE-2024-35195 (Requests `Session` object does not verify requests after making first request wi) +13 more), but the manifest does not pin a version, so it is unknown whether the installed release is affected

Low
Category
Supply Chain
Confidence
89% confidence
Finding

requests has multiple known advisories, and because the manifest does not pin an exact version, there is no way to confirm that installations will avoid affected releases. In an OCR skill, network libraries are likely to be used for API calls or remote image retrieval, so an unsafe resolved version could expose secrets or transport security weaknesses depending on code paths.

Content

No source excerpt is available for this finding.

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
94% confidence
Finding

Using pydantic>=2.7.0 without an upper bound or exact pin allows uncontrolled version drift between environments. That weakens reproducibility and may introduce vulnerable or breaking releases into the skill without review.

Content

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

text
requests>=2.31.0
pydantic>=2.7.0
pydantic-settings>=2.2.0
python-dotenv>=1.0.1

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
85% confidence
Finding

pydantic has known advisories, and without a fixed version the actual installed release cannot be validated. The likely impact here is limited by context because this file alone does not show dangerous parsing patterns, but an unverified validation library still increases risk of DoS or parser-related issues if affected versions are installed.

Content

No source excerpt is available for this finding.