Back to skill

Security audit

Seal Ocr

Security checks for vulnerabilities and agentic risk

Overview

This seal OCR skill mostly matches its stated purpose, but it uploads local documents and an API key to a configurable external service without strict endpoint controls.

Install only if you are comfortable sending the selected image, PDF, or archive to Scnet's OCR service. Keep the API key out of chat, protect `config/.env`, do not change `SCNET_API_BASE` unless you fully trust the destination, and avoid using this skill on confidential or regulated documents without confirming the provider's data handling terms.

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/main.py:77
Finding

Unrestricted OCR API Endpoint Can Expose Documents and Credentials

Content
View full analysis

Vulnerability Details

File Location: scripts/main.py, lines 77-112
Vulnerability Type: Unvalidated external service endpoint
Risk Level: Medium

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 accepts SCNET_API_BASE from its configuration without validating its scheme, hostname, port, or trust boundary. It then appends /ocr/recognize and sends both the complete user-selected document and the SCNET_API_KEY bearer credential to that destination.

Uploading the document and sending an authorization token to the documented Scnet API is necessary for the declared remote OCR functionality. However, allowing an arbitrary endpoint exceeds the minimum privileges needed to access that service. A modified or incorrectly configured .env file can redirect the request to an attacker-controlled server. A plaintext http:// ...[truncated 1576 chars]

Remediation
View remediation

Remediation Suggestions

  1. Parse the configured endpoint with a standard URL parser before issuing any request.
  2. Require the https scheme and reject plaintext HTTP.
  3. Allowlist api.scnet.cn as the default and expected hostname.
  4. Reject embedded user information, fragments, unexpected ports, malformed hosts, and ambiguous URL forms.
  5. If custom endpoints are a legitimate requirement, require an explicit security opt-in and display the exact destination before transmitting a document.
  6. Do not send the production Scnet credential to a custom hostname. Require a separate credential scoped to that endpoint.
  7. Disable redirects for upload requests or validate the scheme and hostname of every redirect target before following it.
  8. Document clearly that submitted files leave the local environment and are processed by an external service.
  9. Add automated tests covering HTTP endpoints, lookalike domains, user-information URL tricks, unexpected ports, and cross-host redirects.

T08 · Insecure Dependencies

Note
Location
SKILL.md:66
Finding

Unpinned Third-Party Dependency Installation

Content
View full analysis

Vulnerability Details

File Location: SKILL.md, lines 66-72
Vulnerability Type: Unpinned and integrity-unverified dependency
Risk Level: Low

Vulnerable Code

bash
   pip install requests

Technical Analysis

The installation instructions resolve requests without a version constraint, lock file, or package hash. Consequently, installation is not reproducible and depends on the package version and metadata available from the configured Python package index at installation time.

The reviewed package name is not an apparent typographical error, and the instructions do not specify a suspicious custom package index. Therefore, this finding does not establish that the current dependency is malicious. The risk is that a future compromised, malicious, or incompatible release could be selected automatically, or that a user operating with an untrusted package-index configuration could retrieve an unintended artifact.

Python package installation may execute package build logic under the privileges of the user running pip. Runtime compromise of requests could also expose uploaded documents and authorization headers because the dependency handles the Skill's outbound request.

Attack Path

  1. A user follows the documented pip install requests command.
  2. pip resolves the dependency using the user's currently configured package index and selects a mutable latest-compatible release.
  3. The selected release or one of its transitive dependencies has been compromised, replaced on an untrusted index, or contains malicious build behavior.
  4. Installation-time code executes with the invoking user's privileges, or malicious runtime code is imported when scripts/main.py starts.
  5. The compromised package can access process data and intercept the API credential and documents handled by the Skill.

Impact Assessment

Installation-time malicious code could act with the filesystem and process privil ...[truncated 438 chars]

Remediation
View remediation

Remediation Suggestions

  1. Add a reviewed dependency manifest with exact versions for requests and relevant transitive dependencies.

  2. Generate cryptographic hashes for every approved distribution.

  3. Install dependencies with an integrity-enforcing command such as:

    bash
    python -m pip install --require-hashes -r requirements.txt
    
  4. Use a trusted package index explicitly in deployment documentation and reject unexpected extra indexes in controlled environments.

  5. Review and update locked dependencies through a defined maintenance process rather than resolving the newest release during installation.

  6. Run dependency installation in an isolated virtual environment with the minimum necessary user privileges.

  7. Add automated dependency and vulnerability scanning to release checks.

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
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (19)

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

The skill documentation indicates capabilities that read local files, invoke Python from the shell, and send data to a remote API, but it does not declare any explicit tool scope such as permissions or allowed-tools. This creates a trust and containment gap: an agent may grant broader access than users expect, increasing the chance of unintended file access or data exfiltration when processing arbitrary local paths.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
85% confidence
Finding

The skill is designed to transmit user-provided local image content to an external OCR service at api.scnet.cn. Because the input is a local file path and the feature targets potentially sensitive documents or seals, this creates a real data-exposure boundary that users must understand and explicitly approve.

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

This configuration section again confirms dependence on a remote API endpoint, meaning the skill sends OCR inputs and possibly metadata outside the local environment. In the context of seal recognition, the uploaded files may contain regulated, proprietary, or identity-linked information, making the external transmission security-relevant.

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

The skill references an external API endpoint, which confirms that document data will be transmitted outside the agent's local trust boundary. External transmission is not inherently malicious, but in an OCR skill focused on seals and document contents it becomes security-relevant because users may submit confidential contracts, IDs, or other sensitive records to a third party.

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 documentation instructs users to upload files containing potentially sensitive document images to a third-party OCR endpoint, but it does not clearly disclose that the full file contents and extracted data leave the local environment. In this skill context, that is materially risky because the examples include identity-document fields and seal text, which may contain personal, corporate, or regulated information.

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

The skill transmits user-supplied image files and an API bearer token to an external third-party service at api.scnet.cn. This is a real data exfiltration boundary: if the input images contain sensitive seals, documents, or personal data, that content leaves the local environment and is exposed to the provider and network path.

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

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The manifest description is written entirely in Chinese and does not indicate that the skill is region-specific or provide any user language/locale opt-in. This can violate language/locale policy because it forces a specific language in the skill metadata without documented justification.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
84% confidence
Finding

This markdown file contains user-facing natural language entirely in Chinese, including the title and change description. Under the policy rule for language or locale violations, forcing a specific language without user opt-in or justification can be a concern.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
97% confidence
Finding

The repository documentation is presented as the project's README, but it is a boilerplate GitLab onboarding template rather than documentation for a skill that recognizes seal information from images. This actively misrepresents the repository's intent to readers by documenting repository setup/template guidance instead of the advertised OCR capability.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
92% confidence
Finding

The file’s natural-language description and usage instructions are presented exclusively in Chinese, which can constitute a language/locale policy issue when no user choice or opt-in is offered. There is no note that the skill is intended only for Chinese-speaking users or a region-specific audience.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
96% confidence
Finding

Lines L025-L027 label the skill as '社保卡识别 OCR' and say it exposes one recognition capability, while the rest of the manifest and documentation consistently describe '印章识别'. This is an active documentation contradiction about the skill's purpose, even though the later sections appear to reflect the intended behavior.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
90% confidence
Finding

This markdown file presents all user-facing documentation in Chinese and does not indicate that the language is optional or limited to a region-specific audience. Under the policy, forcing a specific language without user opt-in is a natural-language policy concern.

Content

No source excerpt is available for this finding.