Back to skill

Security audit

夸克扫描王 - OCR文字识别 Alibaba-Quark-OCR

Security checks for vulnerabilities and agentic risk

Overview

This OCR skill mostly matches its stated purpose, but it also contains under-disclosed image-editing scenes and some weak controls around third-party uploads and credentials.

Install only if you are comfortable sending submitted images, including sensitive documents, to Quark's OCR service using your API key. Review or restrict the extra scene registry before use, especially watermark-removal and other image-editing scenes, and prefer explicit user confirmation for IDs, medical records, invoices, and other private documents.

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

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/common/ocr_client.py:158
Finding

Cross-Origin Redirects Can Forward the API Key and Sensitive Image Data

Content
View full analysis

Vulnerability Details

File Location: scripts/common/ocr_client.py:158-180
Vulnerability Type: Sensitive data exposure through unrestricted HTTP redirects
Risk Level: Medium

Vulnerable Code

python
def _build_request_param(self, image_url: str = None, base64_data: str = None) -> Dict[str, Any]:
    """构建请求参数"""
    param = {
        "aiApiKey": self.api_key,
        "dataType": self.data_type,
        "scene": self.scene
    }

    if base64_data:
        param["dataBase64"] = base64_data
    else:
        param["dataUrl"] = image_url

    return param

def _send_request(self, param: Dict[str, Any]) -> requests.Response:
    """发送 HTTP 请求到 OCR API"""
    headers = {"Content-Type": "application/json", "X-Appbuilder-From": "openclaw"}
    response = self.session.post(
        API_URL,
        json=param,
        headers=headers,
        timeout=REQUEST_TIMEOUT,
        allow_redirects=True
    )
    return response

Technical Analysis

The API key is included in the JSON request body together with either the Base64-encoded image or its URL. The request explicitly enables automatic redirects without validating the destination of the redirected request.

HTTP status codes such as 307 and 308 preserve the original request method and body. Therefore, if the configured OCR endpoint returns a cross-origin 307 or 308 redirect, the requests client can resend the POST body—including aiApiKey and dataBase64—to the redirected destination.

This requires the legitimate endpoint, its surrounding infrastructure, or an equivalent trusted network component to be compromised or misconfigured. It is not evidence of intentional exfiltration: the Base64 conversion itself is necessary JSON serialization for the declared OCR functionality. The vulnerability is the unrestricted forwarding of that sensitive body after a redirect.

Attack Path

  1. A user invokes the Skill with a ...[truncated 1107 chars]
Remediation
View remediation

Remediation Suggestions

  1. Disable automatic redirects for requests carrying credentials or image data:
    python
    response = self.session.post(
        API_URL,
        json=param,
        headers=headers,
        timeout=REQUEST_TIMEOUT,
        allow_redirects=False
    )
    
  2. Treat any 3xx response as an error unless redirects are explicitly required by the service contract.
  3. If redirects are necessary, process them manually and require:
    • HTTPS for every destination.
    • An exact hostname allowlist.
    • The expected port.
    • No embedded URL credentials.
    • No downgrade from HTTPS to HTTP.
    • Revalidation at every redirect hop.
  4. Never resend the API key or image body when the origin changes.
  5. Prefer transmitting credentials through an authorization header, while still explicitly preventing credential forwarding across origins.
  6. Add regression tests using 302, 303, 307, and 308 responses to verify that sensitive data never reaches an unapproved host.

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/common/validators.py:15
Finding

Insufficient URL Validation Exposes the OCR Backend to Server-Side Request Forgery Inputs

Content
View full analysis

Vulnerability Details

File Locations: scripts/common/validators.py:15-39, scripts/common/ocr_client.py:158-170
Vulnerability Type: Server-side request forgery input exposure
Risk Level: Medium

Vulnerable Code

python
class URLValidator:
    """URL 基础验证器"""

    @staticmethod
    def validate(url: str) -> Tuple[bool, Optional[str]]:
        """
        验证 URL 格式

        Args:
            url: 待验证的 URL

        Returns:
            (是否有效, 错误信息)
        """
        if not url or not isinstance(url, str):
            return False, "URL cannot be empty"

        url = url.strip()

        try:
            parsed = urlparse(url)
        except ValueError as e:
            return False, f"Invalid URL format: {str(e)}"

        if parsed.scheme.lower() not in {"http", "https"}:
            return False, f"Protocol '{parsed.scheme}' not allowed."

        return True, None

The accepted URL is then forwarded to the OCR service:

python
def _build_request_param(self, image_url: str = None, base64_data: str = None) -> Dict[str, Any]:
    """构建请求参数"""
    param = {
        "aiApiKey": self.api_key,
        "dataType": self.data_type,
        "scene": self.scene
    }

    if base64_data:
        param["dataBase64"] = base64_data
    else:
        param["dataUrl"] = image_url

    return param

Technical Analysis

URL validation verifies only that the scheme is HTTP or HTTPS. It does not validate that a hostname exists or reject destinations involving:

  • Loopback addresses.
  • Private network ranges.
  • Link-local addresses.
  • Cloud metadata endpoints.
  • IPv6 local or reserved ranges.
  • Embedded URL credentials.
  • Unexpected ports.
  • Hostnames that resolve to prohibited addresses.
  • DNS rebinding.
  • Redirects from public hosts to internal destinations.

The URL is not fetched by the local Skill process. Instead, it is forward ...[truncated 1580 chars]

Remediation
View remediation

Remediation Suggestions

  1. Prefer downloading and validating the image in a controlled client component, then submitting the validated bytes instead of delegating arbitrary URL retrieval to the OCR backend.
  2. If URL submission remains supported, require a valid hostname and reject embedded credentials, fragments, unexpected ports, and malformed authority components.
  3. Resolve the hostname and reject every address in loopback, private, link-local, multicast, unspecified, reserved, and documentation ranges for both IPv4 and IPv6.
  4. Explicitly block well-known cloud metadata destinations.
  5. Re-resolve and revalidate the destination at connection time to reduce DNS rebinding risk.
  6. Apply the same validation to every redirect target and enforce a strict redirect-hop limit.
  7. Enforce equivalent protections on the OCR backend because client-side validation alone cannot secure the server-side fetch operation.
  8. Consider an allowlist of approved public image-hosting domains where operationally feasible.
  9. Add tests covering decimal, hexadecimal, octal, mixed IPv6, IPv4-mapped IPv6, user-information, DNS rebinding, and redirect-based bypass techniques.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • 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
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (19)

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

The declared description presents this as an OCR-focused skill and explicitly says it is not applicable to image editing or tasks that do not require text extraction. However, the code registers many non-OCR scenes, including image enhancement and editing operations such as remove-watermark, remove-shadow, remove-screen-pattern, remove-background-color, image-crop-rectify, sketch-drawing, and extract-lineart, as well as document scanning and file conversion scenes. While some of these may support OCR workflows, they are broader capabilities than the declared purpose and materially contradict the claim that the skill is not for image editing. Therefore the description does not accurately represent the full behavior implied by the code.

Content

No source excerpt is available for this finding.

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
- `SKILL.md` — 本文档(意图分析 + 通用规范)

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
86% confidence
Finding

The skill requires environment access and makes outbound network requests to a third-party OCR service, but the manifest does not declare an explicit tool scope such as allowed tools or permissions. This weakens least-privilege controls and makes it harder for a host platform to constrain or audit what the skill is permitted to do.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The trigger description is extremely broad and says the skill should activate whenever a user wants key information from an image, even without explicitly requesting OCR. In a system that auto-routes tasks, this can cause over-triggering and unnecessary transmission of sensitive images, including IDs, medical reports, and licenses, to a third-party service.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
85% confidence
Finding

文档在 L036-L057 规定未配置或缺少输入时必须直接返回固定中文 JSON 消息,且整份执行指南未说明可根据用户语言偏好切换输出语言。这会造成默认强制特定语言/locale 的行为,不符合应提供语言选择或明确用户同意的要求。

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The manifest description consistently scopes the skill to extracting, recognizing, or structuring text and key information from images. The '商品图片识别' scene instead claims object/product identification such as determining what product is shown and its brand/category, which is broader visual classification rather than OCR.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

This code file contains natural-language documentation and messages entirely in Chinese, including the module docstring and multiple returned/logged strings. Under the stated policy, forcing a specific language without user opt-in or a documented justification is a locale-policy violation.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The helper accepts a caller-supplied filepath and writes decoded bytes to it after only creating parent directories, with no restriction that the destination stay under a controlled base directory. If an upstream caller passes untrusted or attacker-influenced paths, this enables arbitrary file write, which can overwrite application files, drop files in sensitive locations, or plant content for later processing. In an OCR skill, this capability is broader than necessary because typical behavior only requires saving outputs in a managed temp/output directory.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The local-file path flow reads a user-specified file, base64-encodes its contents, and sends that content to a remote OCR service via _send_request. While the docstring says the file is converted to BASE64, there is no explicit warning, prompt, or user-facing disclosure that the file's contents will be uploaded off-host.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

This Python file performs a credential load and then sends user-provided image data to an OCR client, which is a network/data-transmission operation covered by the missing-warning rule for code files. Although the module has technical docstrings, there is no confirmation prompt, user-facing disclosure, or warning comment here indicating that image content will be transmitted to an external OCR service.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The skill manifest describes an OCR/text-extraction capability, but the scene map exposes materially broader functions such as watermark removal, handwriting removal, background/color manipulation, sketch extraction, and document conversion. This creates a scope-expansion risk: an agent or orchestrator could invoke editing or transformation capabilities users did not explicitly authorize, including potentially abusive use cases like removing watermarks or altering documents.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
93% confidence
Finding

This Python file contains only Chinese natural-language content in the module docstring, comments, and user-facing error message, with no indication that the skill is China-specific or that users can opt into another language. Under the language/locale policy rule, forcing a specific language without user choice or clear justification is a policy concern.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
88% confidence
Finding

The module docstrings and at least one user-facing error message are written in Chinese only, which imposes a specific language choice without offering the user an alternative. This is a natural-language policy concern because the file does not indicate any locale selection or region-specific justification.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
87% confidence
Finding

This code instantiates a file saver and writes decoded image content to a local path, then returns that path. The file includes no confirmation prompt, logging, or warning comment/docstring indicating that OCR output will be written to disk, which is a safety-relevant side effect for a code file.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
90% confidence
Finding

The function selects a document type and saves base64-decoded OCR output to a local file, then replaces the result data with the saved path. There is no confirmation prompt, print/log statement, or explicit warning in the file that document content will be persisted on disk.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
80% confidence
Finding

The file's primary descriptive text and function documentation are presented exclusively in Chinese. Under the policy rule, forcing a specific language without opt-in or documented locale justification is a natural-language policy concern.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
84% confidence
Finding

The module docstring describes the file as managing OCR/scanning scene configurations, which implies recognition and scan-related processing. In practice, the configuration also exposes image editing-style features such as remove-watermark, remove-shadow, remove-background-color, sketch-drawing, and document conversion scenes, so the documentation understates and partially mischaracterizes what the code supports.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
83% confidence
Finding

This code file contains user/developer-facing natural-language text in Chinese in the module and class/function documentation. Under the policy, forcing a specific language without opt-in or clear region-specific justification can be a locale-policy issue.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
83% confidence
Finding

The top-level description is written only in Chinese ('夸克扫描王 OCR 识别服务'), which may imply a fixed language experience without indicating any user choice or locale flexibility. The policy requires flagging language or locale constraints when they are imposed without opt-in or justification.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.