Back to skill

Security audit

Education Certificate Ocr

Security checks for vulnerabilities and agentic risk

Overview

This cloud OCR skill is purpose-aligned, but it uploads sensitive certificate files and the API credential to a configurable remote endpoint without strong privacy or destination guardrails.

Install only if you are comfortable sending certificate images/PDFs and extracted personal information to Scnet's OCR service. Keep `config/.env` private, do not paste the API key into chat, avoid changing `SCNET_API_BASE` unless you fully trust the destination, and confirm each sensitive file before uploading.

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

Error
Location
scripts/main.py:78
Finding

Configurable OCR Endpoint Can Exfiltrate API Credentials and Sensitive Documents

Content
View full analysis

Vulnerability Details

File Location: scripts/main.py:78-112
Vulnerability Type: Unrestricted external endpoint configuration and sensitive-data transmission
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 SCNET_API_BASE value is read from configuration and used directly to construct the request URL. The code does not validate:

  • Whether the scheme is HTTPS
  • Whether the destination hostname belongs to SCNet
  • Whether the URL contains embedded credentials or unusual components
  • Whether the endpoint is part of an approved allowlist

The resulting request includes both the bearer API credential and the complete user-selected document. Education certificates may contain names, birth dates, certificate numbers, institutional details, and other personally identifiable information.

Remote transmiss ...[truncated 1766 chars]

Remediation
View remediation

Remediation Suggestions

  1. Pin the production endpoint in code to the official HTTPS origin whenever endpoint customization is not required.
  2. If endpoint overrides are operationally necessary, parse the URL and enforce:
    • The https scheme
    • An explicit hostname allowlist
    • The expected port
    • No embedded username or password
    • A fixed or validated path prefix
  3. Reject loopback, link-local, private-network, and non-approved destinations unless explicitly required for a controlled development mode.
  4. Disable redirects or validate every redirect destination before forwarding credentials or documents.
  5. Separate development endpoint support from production operation and require an explicit opt-in flag for non-production environments.
  6. Display or log the validated destination before upload without logging the API key or document contents.
  7. Document that files are transmitted to a third-party OCR service, including available privacy, retention, deletion, and data-processing terms.
  8. Apply restrictive permissions to config/.env and verify them before reading credentials where the operating system supports such checks.

T08 · Insecure Dependencies

Warning
Location
SKILL.md:67
Finding

Unpinned Third-Party Dependency Installation Creates Supply-Chain Risk

Content
View full analysis

Vulnerability Details

File Location: SKILL.md:67-70
Vulnerability Type: Unpinned dependency installation
Risk Level: Medium

Vulnerable Code

markdown
本技能需要 Python 3.6+ 和 requests 库。请运行以下命令:

```bash
   pip install requests
text

### Technical Analysis

The documented installation command retrieves the latest version of `requests` and its transitive dependencies without a version constraint, integrity hash, lock file, or reviewed package index configuration.

This makes installation non-reproducible. The package versions installed at one point may differ from those installed later, and future releases or transitive dependencies may contain vulnerabilities, incompatible behavior, or malicious modifications following a package or publishing-account compromise.

The project also does not provide a dependency manifest containing reviewed versions and hashes. Although the referenced package name is legitimate and no malicious dependency is currently identified in the audited files, the installation process lacks standard supply-chain controls.

### Attack Path

1. A dependency release, transitive dependency, publishing account, package index, or package-resolution path becomes compromised.
2. A user follows the documented `pip install requests` instruction.
3. `pip` resolves and downloads the compromised or unsafe version because no approved version or hash is enforced.
4. Malicious code may run during source-package build or installation, or later when `scripts/main.py` imports and uses the installed package.
5. The code executes with the permissions of the user running the installation or Skill.

### Impact Assessment

A compromised dependency could obtain the same privileges as the Skill process, including the ability to:

- Read the OCR API credential available to the process
- Read documents submitted for OCR
- Intercept or modify network requests and OCR results
- Access other files 
...[truncated 367 chars]
Remediation
View remediation

Remediation Suggestions

  1. Add a reviewed dependency file with exact package and transitive-dependency versions.
  2. Generate and verify cryptographic hashes for all distributions.
  3. Install dependencies with hash enforcement, for example:
    bash
    python -m pip install --require-hashes -r requirements.txt
    
  4. Use an isolated virtual environment rather than installing into a shared or privileged Python environment.
  5. Configure an approved package index explicitly and require TLS certificate validation.
  6. Regularly scan and update locked dependencies through a controlled review process.
  7. Avoid running pip as root or with administrative privileges.
  8. Consider distributing a reproducible environment or signed package with reviewed dependencies.
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 63)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 125)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
93% confidence
Finding

The skill documentation indicates capabilities to read local files, invoke Python via shell, and send data over the network, but it does not declare any explicit tool scope such as permissions or allowed-tools. This creates a least-privilege gap: an agent may invoke broader capabilities than users expect, especially since the skill processes local certificate images containing sensitive personal data and transmits them to a remote API.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The skill description and setup sections do not prominently warn that local certificate images and extracted personal information will be transmitted to a remote OCR provider. Since graduation certificates contain names, certificate numbers, schools, majors, and dates, omission of an explicit privacy notice can lead to uninformed disclosure of sensitive personal data.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
50% confidence
Finding

Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Content

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

Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Content

Scanner excerpt · SKILL.md (reported line 107)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(仅所有者可读写)

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The auto-trigger guidance is overly broad: a natural-language request like 'help me recognize this certificate image' can cause the agent to read a local file and upload highly sensitive identity data to a third-party OCR service without an explicit consent checkpoint. Because the skill handles educational certificates, the data includes PII and credential-like documents, making unintended invocation more harmful than for low-sensitivity OCR tasks.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
84% confidence
Finding

The skill relies on an external API endpoint, which means uploaded certificate images and extracted OCR contents are transmitted outside the local trust boundary. In an OCR skill for education certificates, this is materially sensitive because the transmitted files and results can contain personal and academic records, so undisclosed external transfer increases confidentiality and compliance 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
90% confidence
Finding

The documentation describes sending identity-document and certificate images to a third-party OCR endpoint and shows responses containing highly sensitive personal data, but it does not warn users about privacy, retention, consent, or regulatory handling requirements. In this skill context, the risk is elevated because education certificates commonly contain names, certificate numbers, schools, majors, and dates, and the sample response also demonstrates even more sensitive identity data, increasing the chance of inappropriate collection or disclosure.

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 certificate files to an external OCR API at api.scnet.cn. Because the skill processes education certificates containing sensitive personal data, this is a real data-exfiltration/privacy risk unless users explicitly expect remote processing and proper controls are in place. The skill context increases the sensitivity because graduation certificates commonly contain names, IDs/certificate numbers, institutions, majors, and dates.

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):

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
82% confidence
Finding

This markdown file contains user-facing natural language entirely in Chinese, including the title and feature description. Under the stated policy, forcing a specific language without user opt-in can be a locale-policy violation when no justification or alternative language option is provided.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
85% confidence
Finding

The manifest description is written only in Chinese, which indicates a language-specific presentation without any accompanying opt-in, alternative locale, or justification that the skill is intended solely for Chinese-speaking users. Under the policy, language constraints should be optional or clearly documented as region-specific.

Content

No source excerpt is available for this finding.