Back to skill

Security audit

Marriage Certificate Ocr

Security checks for vulnerabilities and agentic risk

Overview

This skill matches its OCR purpose, but it uploads sensitive marriage-certificate documents and an API token to a configurable external endpoint without validating the destination or giving a strong privacy/consent warning.

Review before installing. Use this only for documents you are allowed to send to Scnet, verify the privacy and retention terms for the OCR provider, keep SCNET_API_BASE at the official HTTPS api.scnet.cn endpoint, and avoid processing real identity documents unless you have consent and a data-handling reason.

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

Error
Location
scripts/main.py:78
Finding

Unrestricted OCR API Endpoint Can Expose Credentials and Sensitive Identity Documents

Content
View full analysis

Vulnerability Details

File Location: scripts/main.py, lines 78–112
Vulnerability Type: User-controlled network destination for sensitive data
Risk Level: High

Vulnerable Code

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

def recognize_with_retry(ocr_type, file_path, config, retry_count=0):
    """
    带重试机制的 OCR 识别函数。
    当遇到 429 (Too Many Requests) 时,自动等待后重试。
    调用 Scnet OCR API 进行识别"""
    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"错误: 文件不存在 - {file_path}")

    # 自动检测 MIME 类型
    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)

Technical Analysis

The Skill reads SCNET_API_BASE from its configuration and uses it directly to construct the request URL. It does not validate the URL scheme, hostname, port, or final destination before attaching both:

  • The SCNET_API_KEY bearer credential.
  • The complete user-selected marriage-certificate file.

Marriage certificates can contain highly sensitive personal information, including names, dates of birth, certificate numbers, and government identity numbers. Although uploading the document is necessary for the declared cloud OCR functionality and is disclosed in the documentation, sending it to an arbitrary configurabl ...[truncated 1907 chars]

Remediation
View remediation

Remediation Suggestions

  1. Remove SCNET_API_BASE configurability if alternate service endpoints are not operationally required.
  2. If endpoint customization is necessary, parse the URL with urllib.parse.urlparse and enforce:
    • The https scheme.
    • An explicit hostname allowlist, such as api.scnet.cn.
    • An approved port, normally 443.
    • No embedded username or password.
    • No URL fragments or unexpected path manipulation.
  3. Construct the OCR endpoint from a trusted constant rather than concatenating an unrestricted configuration string.
  4. Reject redirects or verify every redirect destination before forwarding credentials and document content.
  5. Display the verified upload destination and obtain explicit user consent before transmitting identity documents.
  6. Document that the source file and extracted personal information are processed by an external service, including applicable retention and privacy considerations.
  7. Add automated tests confirming that HTTP URLs, unapproved hosts, embedded credentials, alternate ports, and malformed URLs are rejected.
  8. Use a narrowly scoped API token where supported, and provide rotation and revocation guidance in case the token is exposed.
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
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
Findings (17)

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 62)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 124)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 documentation indicates capabilities that involve reading local files, invoking Python from the shell, and sending data over the network, but it does not declare any explicit tool scope such as permissions or allowed-tools. This increases the risk of over-broad execution in an agent environment because the runtime may grant more access than users expect, especially given the skill processes local identity documents and transmits them externally.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

This skill handles highly sensitive personal identity data from marriage certificates, including names, birth dates, and ID numbers, and sends that data to an external OCR service. The description explains how to configure the API but does not prominently warn users that protected personal data will leave the local system, creating a meaningful privacy and compliance risk.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
92% confidence
Finding

The documented configuration explicitly sets an external API endpoint, confirming that local document contents will be transmitted off-host to a third-party service. In this skill's context, the transmitted content is not generic text but government-issued identity document data, which makes external transmission materially more sensitive and potentially subject to legal or contractual restrictions.

Content

Scanner excerpt · SKILL.md (reported line 54)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
90% confidence
Finding

This second reference to the API base reinforces that the skill is designed for remote processing rather than local OCR. Because the workflow centers on marriage certificates containing sensitive PII, repeated undisclosed reliance on a remote endpoint raises privacy, data-governance, and misuse concerns if operators assume processing is local.

Content

Scanner excerpt · SKILL.md (reported line 106)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
96% confidence
Finding

The file defines a remote API endpoint at api.scnet.cn for OCR processing, meaning document images containing marriage and identity information leave the local trust boundary and are transmitted to an external service. In the context of this skill, that transmission is especially sensitive because the expected inputs include government-issued civil records and identity numbers, increasing the consequence of interception, misuse, retention, or third-party compromise.

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

The documentation instructs the skill to upload user-provided marriage certificate images to a third-party OCR API, but it provides no warning, consent flow, data handling notice, or minimization guidance. Because the skill processes highly sensitive personal data such as names, birth dates, and ID numbers, silent external transmission creates a real privacy and compliance risk and could expose users to unauthorized disclosure of regulated PII.

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 152)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
96% confidence
Finding

The script uploads user-supplied marriage certificate images and extracted personally identifiable information to an external third-party API endpoint at api.scnet.cn. In the context of an OCR skill for identity and civil-status documents, this is a real data-exposure risk because highly sensitive personal data leaves the local environment and is transmitted to an external service without any visible consent, minimization, or trust-boundary controls in code.

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 recognize_with_retry(ocr_type, file_path, config, retry_count=0):

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
84% confidence
Finding

This manifest file contains only a general capability description about extracting marriage certificate data, but it does not define specific trigger phrases, activation boundaries, or exclusion conditions. In a manifest context, that lack of specificity can make invocation matching overly broad and increase the risk of unintended activation.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
88% confidence
Finding

The natural-language content begins with a Chinese-only heading ("变更日志"), which imposes a specific language choice without any visible user opt-in or justification. Under the stated policy, fixed language selection can be a locale-policy violation unless the skill explicitly documents that it is region-specific or offers alternatives.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
81% confidence
Finding

The manifest description is written entirely in Chinese and describes the skill behavior without offering any language or locale choice. Under the language/locale policy, this can be a policy concern unless the skill is explicitly documented as region-specific or allows user opt-in for the language.

Content

No source excerpt is available for this finding.