Back to skill

Security audit

medical_invoice_scene_ocr

Security checks for vulnerabilities and agentic risk

Overview

The skill performs the advertised medical OCR, but it uploads sensitive medical documents to an external configurable endpoint without an enforced confirmation step.

Review this before installing in any environment that handles real medical records. Use it only when each file owner has authorized third-party OCR processing, keep SCNET_API_BASE at the official HTTPS Scnet endpoint unless you have independently vetted another endpoint, and add an external consent gate before each upload. Store the API key outside chat, restrict config file permissions, and prefer a pinned dependency or isolated environment.

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

T09 · Insecure Skill Coding Practices

Error
Location
scripts/main.py:108
Finding

Configurable OCR Endpoint Can Exfiltrate Medical Records and API Credentials

Content
View full analysis

Vulnerability Details

File Location: scripts/main.py:78, scripts/main.py:108-137
Vulnerability Type: Unvalidated configurable network destination
Risk Level: High

python
config.setdefault('SCNET_API_BASE', 'https://api.scnet.cn/api/llm/v1')
return config
python
def recognize_with_retry(ocr_type, file_path, config, retry_count=0):
    api_base = config['SCNET_API_BASE']
    api_key = config['SCNET_API_KEY']
    url = f"{api_base}/ocr/recognize"

    if not os.path.isfile(file_path):
        sys.exit(f"Error: File does not exist - {file_path}")

    print_upload_warning(file_path)

    mime_type, _ = mimetypes.guess_type(file_path)
    if mime_type is None:
        mime_type = 'application/octet-stream'

    headers = {
        'Authorization': f'Bearer {api_key}'
    }

    try:
        with open(file_path, 'rb') as f:
            files = {
                'file': (os.path.basename(file_path), f, mime_type)
            }
            data = {
                'ocrType': ocr_type,
                'channelTag': "scnetSkills"
            }
            response = requests.post(
                url,
                headers=headers,
                data=data,
                files=files,
                timeout=60
            )
    except Exception as e:
        sys.exit(f"Network request failed: {str(e)}")

Technical Analysis

The SCNET_API_BASE configuration value controls the complete destination of the OCR request. The code does not parse or validate its URL scheme, hostname, port, or final resolved destination before attaching the bearer credential and medical document.

Although the documentation identifies https://api.scnet.cn as the third-party processor, a modified configuration can redirect requests to any HTTP or HTTPS server. A plaintext HTTP destination would additionally expose the credential and uploaded document to network inter ...[truncated 1422 chars]

Remediation
View remediation

Remediation Suggestions

  1. Remove SCNET_API_BASE configurability if alternate deployments are not required.
  2. If configurability is necessary, parse the URL with urllib.parse.urlparse and require:
    • The https scheme.
    • An exact allowlisted hostname such as api.scnet.cn.
    • An approved port, normally 443.
    • No embedded username or password.
  3. Validate the destination before creating or attaching the Authorization header.
  4. Display the validated destination to the user before consent is collected.
  5. Consider rejecting redirects or validating every redirect destination so credentials cannot be forwarded to another host.
  6. Add automated tests confirming that HTTP URLs, look-alike domains, embedded credentials, unexpected ports, and non-allowlisted hosts are rejected.
  7. Document any legitimate private deployment endpoints and require a separate credential scoped specifically to those deployments.

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/main.py:115
Finding

Sensitive Medical Document Upload Proceeds Without Enforced Affirmative Consent

Content
View full analysis

Vulnerability Details

File Location: scripts/main.py:115-137, with the consent requirement documented in SKILL.md:100-116
Vulnerability Type: Missing runtime enforcement of consent for sensitive-data transmission
Risk Level: Medium

python
if not os.path.isfile(file_path):
    sys.exit(f"Error: File does not exist - {file_path}")

print_upload_warning(file_path)

mime_type, _ = mimetypes.guess_type(file_path)
if mime_type is None:
    mime_type = 'application/octet-stream'

headers = {
    'Authorization': f'Bearer {api_key}'
}

try:
    with open(file_path, 'rb') as f:
        files = {
            'file': (os.path.basename(file_path), f, mime_type)
        }
        data = {
            'ocrType': ocr_type,
            'channelTag': "scnetSkills"
        }
        response = requests.post(
            url,
            headers=headers,
            data=data,
            files=files,
            timeout=60
        )
except Exception as e:
    sys.exit(f"Network request failed: {str(e)}")

Technical Analysis

The Skill documentation requires the user to understand that the file will be uploaded to Scnet and to provide explicit consent before execution. The implementation only writes a warning to standard error. It does not prompt for confirmation, require a consent flag, receive a consent token from the invoking Agent, or otherwise fail closed when affirmative consent is absent.

Printing a warning is not equivalent to obtaining consent because non-interactive execution, automated Agent calls, and direct command-line calls continue immediately. The sensitive file is uploaded regardless of whether the warning was seen or acknowledged.

Attack Path

  1. An Agent, automation process, or user directly invokes the script with a readable medical document path.
  2. The script verifies only that the path points to a file.
  3. A warning is printed to standard error ...[truncated 845 chars]
Remediation
View remediation

Remediation Suggestions

  1. Require an explicit command-line option such as --consent-to-upload and terminate without performing a request when it is absent.
  2. For interactive use, show the normalized file path and validated destination, then require an unambiguous confirmation.
  3. For Agent invocation, define a structured consent parameter that can only be set after the Agent has disclosed the destination and obtained user approval.
  4. Keep warnings on standard error, but treat them as supplemental disclosure rather than consent.
  5. Avoid silently accepting consent through general OCR intent; require consent specifically for third-party upload.
  6. Add tests proving that requests are never initiated when the consent flag or structured consent value is missing.
  7. Record only minimal consent metadata when legally appropriate, and never log document contents or the API key.

T08 · Insecure Dependencies

Note
Location
SKILL.md:83
Finding

Unpinned Requests Dependency Creates Avoidable Supply-Chain Exposure

Content
View full analysis

Vulnerability Details

File Location: SKILL.md:83-88
Vulnerability Type: Unpinned third-party dependency installation
Risk Level: Low

bash
pip install requests

Technical Analysis

The installation instructions resolve requests without a fixed version, lock file, or integrity hash. Consequently, installation is not reproducible and can select a different release over time.

No evidence shows that the currently named package is malicious. The risk is that a future compromised, malicious, or incompatible release from the configured package index could be installed without review. Because Python package installation and import both execute package-controlled code, dependency compromise can affect the Skill environment.

Attack Path

  1. A user follows the documented installation command.
  2. pip contacts its configured package index and resolves the latest acceptable requests release.
  3. If the selected release or package-index path has been compromised, package-controlled installation or runtime code executes under the installing or invoking account.
  4. The compromised dependency could access the Skill process, API credential, selected medical file, or network traffic available to that account.

Impact Assessment

Potential impact depends on the privileges used for installation and execution. A compromised dependency could execute code with the installer or Skill process privileges, access files readable by that account, steal SCNET_API_KEY, inspect uploaded medical data, or alter OCR network requests.

The finding is rated Low because the audit found no malicious dependency or active dependency-confusion package; the confirmed weakness is the absence of version and integrity controls.

Remediation
View remediation

Remediation Suggestions

  1. Pin requests to a reviewed version or tightly controlled compatible range.
  2. Provide a lock file or requirements file containing cryptographic hashes.
  3. Install with hash verification, for example through pip install --require-hashes -r requirements.txt.
  4. Use a trusted package index and explicitly configure it where deployment policy requires.
  5. Run dependency vulnerability scanning and review updates before changing the lock file.
  6. Install dependencies in an isolated virtual environment under a non-privileged account.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (15)

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/main.py (reported line 20)May include surrounding context.

python
# 获取技能根目录(脚本所在目录的上一级)
SKILL_ROOT = Path(__file__).parent.parent.absolute()
ENV_FILE = SKILL_ROOT / "config" / ".env"

# --- 新增:重试配置 ---
MAX_RETRIES = 3            # 最大重试次数

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 · SKILL.md (reported line 80)May include surrounding context.

md
# --------------------

def load_config():
    """从 .env 文件加载配置,若文件不存在则抛出友好错误"""
    if not ENV_FILE.exists():
        error_msg = (
            "\n===============================================\n"

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 · SKILL.md (reported line 148)May include surrounding context.

md
# --------------------

def load_config():
    """从 .env 文件加载配置,若文件不存在则抛出友好错误"""
    if not ENV_FILE.exists():
        error_msg = (
            "\n===============================================\n"

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/main.py (reported line 29)May include surrounding context.

python
# --------------------

def load_config():
    """从 .env 文件加载配置,若文件不存在则抛出友好错误"""
    if not ENV_FILE.exists():
        error_msg = (
            "\n===============================================\n"

Autonomous Decision Making

Medium
Category
Excessive Agency
Confidence
80% confidence
Finding

Skill enables autonomous high-impact decisions without human-in-the-loop verification. Critical operations (destructive commands, financial transactions, data deletion) should require explicit user confirmation.

Content

Scanner excerpt · README.md (reported line 38)May include surrounding context.

md
* [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/)
* [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
* [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
* [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
* [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
95% confidence
Finding

The skill documents capabilities that imply local file access, network exfiltration to a third-party OCR API, and shell execution, but it does not declare any explicit tool scope or permission boundaries. In an agent environment, this weakens enforceable least-privilege controls and increases the chance the skill can be invoked with broader access than users or operators expect, especially given it handles highly sensitive medical documents.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The skill description, usage examples, warnings, and operational instructions are entirely in Chinese, and the interaction examples implicitly require Chinese-language invocation. There is no statement that users may choose another language or that the Chinese-only constraint is intentional for a region-specific compliance reason, which matches the language/locale policy concern.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
97% confidence
Finding

The skill explicitly transmits user-provided local medical invoice images to an external third-party endpoint, and those documents are described as containing PHI/PII such as identity numbers, diagnosis, hospitalization details, and billing data. Even though the documentation warns users and requires consent, external transmission of highly sensitive healthcare data remains a real security and privacy risk if consent is not properly enforced, if the endpoint is misconfigured, or if data handling by the third party is insufficient.

Content

Scanner excerpt · SKILL.md (reported line 72)May include surrounding context.

SCNET_API_KEY=your_scnet_api_key_here

API 基础地址(一般无需修改)

SCNET_API_BASE=https://api.scnet.cn/api/llm/v1

text
2. 添加:`SCNET_API_KEY=你的密钥`
3. 设置文件权限为 600(仅所有者可读写)

External Transmission

Medium
Category
Data Exfiltration
Confidence
96% confidence
Finding

This configuration section again confirms that the skill is designed to send sensitive medical records to an external API endpoint. In the context of OCR for reimbursement documents, the danger is elevated because the transferred content can include regulated health and identity data, making any unintended disclosure or overbroad transmission potentially severe.

Content

Scanner excerpt · SKILL.md (reported line 130)May include surrounding context.

md
| 变量名 | 默认值 | 说明 |
|--------|--------|------|
| SCNET_API_KEY | 必需 | Scnet API 密钥 |
| SCNET_API_BASE | https://api.scnet.cn/api/llm/v1 | API 基础地址(一般无需修改) |

### 输出

External Transmission

Medium
Category
Data Exfiltration
Confidence
89% confidence
Finding

This skill is explicitly wired to send user-supplied documents to https://api.scnet.cn, which is an external network destination. In the context of medical reimbursement documents, that transmission carries sensitive health, billing, and identity information, so the external transfer materially increases privacy, compliance, and data-leak risk even if the endpoint itself is legitimate.

Content

Scanner excerpt · references/api-docs.md (reported line 4)May include surrounding context.

md
# Sugon-Scnet OCR API 文档摘要

## 接口地址
`POST https://api.scnet.cn/api/llm/v1/ocr/recognize`

## 请求头
- `Content-Type: multipart/form-data`

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The document instructs callers to upload local files containing medical invoices and settlement sheets to an external OCR API, but it provides no privacy, consent, retention, or third-party data-handling warning. Because the sample OCR outputs include highly sensitive medical and identity data, this omission can cause unintentional exfiltration of regulated personal information if users or integrators invoke the skill without informed consent and proper controls.

Content

No source excerpt is available for this finding.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
80% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · scripts/main.py (reported line 45)May include surrounding context.

python
"   b) 配置文件:\n"
            f"      mkdir -p {SKILL_ROOT}/config\n"
            f"      echo 'SCNET_API_KEY=你的密钥' > {ENV_FILE}\n"
            f"      chmod 600 {ENV_FILE}\n"
            "\n配置完成后重新运行。"
        )
        sys.exit(error_msg)

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
80% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · scripts/main.py (reported line 177)May include surrounding context.

python
"   b) 配置文件:\n"
            f"      mkdir -p {SKILL_ROOT}/config\n"
            f"      echo 'SCNET_API_KEY=你的密钥' > {ENV_FILE}\n"
            f"      chmod 600 {ENV_FILE}\n"
            "\n配置完成后重新运行。"
        )
        sys.exit(error_msg)

External Transmission

Medium
Category
Data Exfiltration
Confidence
98% confidence
Finding

The script uploads user-specified medical invoice files to an external OCR API endpoint, which creates a real data-exfiltration/privacy risk because those files can contain sensitive personal and health information. In this skill context, the transmission is intentional and disclosed, but it is still security-relevant because compromise, misconfiguration, or accidental use could expose regulated medical data to a third party.

Content

Scanner excerpt · scripts/main.py (reported line 78)May include surrounding context.

python
)
        sys.exit(error_msg)

    config.setdefault('SCNET_API_BASE', 'https://api.scnet.cn/api/llm/v1')
    return config

def print_upload_warning(file_path):

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
91% confidence
Finding

The file content is entirely in Chinese, including the title and feature description, with no indication that this skill is region-specific or that users can choose their preferred language. This can violate a language/locale policy when the skill documentation implicitly mandates a single language without opt-in.

Content

No source excerpt is available for this finding.