Back to skill

Security audit

夸克扫描王 - 文件扫描增强 Alibaba-Quark-Scan

Security checks for vulnerabilities and agentic risk

Overview

The skill appears to perform disclosed Quark image enhancement, but it needs Review because weak local-file validation and redirect handling could expose unintended files, image data, or the API key.

Install only if you are comfortable sending selected images or document photos to Quark's remote service. Use explicit image files, avoid symlinks or ambiguous paths, avoid highly sensitive documents unless you have consent to upload them, rotate SCAN_WEBSERVICE_KEY if exposure is suspected, and manually clean temporary output images. The publisher should validate image contents, reject symlinks, disable cross-origin redirects, and add a clear confirmation path for sensitive uploads.

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/validators.py:57
Finding

Extension-Only File Validation Permits Unintended Local File Disclosure

Content
View full analysis

Vulnerability Details

File Location: scripts/common/validators.py:57-73; upload occurs at scripts/common/ocr_client.py:191-205
Vulnerability Type: Insufficient file-type validation and symbolic-link traversal
Risk Level: Medium

Vulnerable Code

python
if not os.path.exists(file_path):
    return False, f"File not found: {file_path}"

if not os.path.isfile(file_path):
    return False, f"Not a file: {file_path}"

file_size = os.path.getsize(file_path)
if file_size > MAX_FILE_SIZE:
    return False, f"File size exceeds {MAX_FILE_SIZE / 1024 / 1024}MB limit"

ext = os.path.splitext(file_path)[1].lower()
if ext not in ALLOWED_IMAGE_EXTENSIONS:
    return False, f"File extension '{ext}' not allowed"

return True, None

After validation, the complete file is read, Base64-encoded, and submitted to the remote service:

python
file_path = os.path.expanduser(file_path.strip())

is_valid, error_msg = FileValidator.validate(file_path)
if not is_valid:
    return OCRResult(code="FILE_ERROR", message=f"File validation failed: {error_msg}", data=None)

try:
    with open(file_path, 'rb') as f:
        file_content = f.read()
    base64_content = base64.b64encode(file_content).decode('utf-8')
except (IOError, OSError) as e:
    return OCRResult(code="FILE_READ_ERROR", message=f"Failed to read file: {str(e)}", data=None)

param = self._build_request_param(base64_data=base64_content, input_configs=input_configs)
response = self._send_request(param)

Technical Analysis

The validator determines whether a local file is an image solely by examining its filename extension. It does not inspect image magic bytes, parse the file with an image decoder, or reject symbolic links.

os.path.isfile() follows symbolic links. Therefore, a path with an allowed image extension can be a symbolic link to another readable regular file. A non-image file can also simply be renamed with an ...[truncated 1696 chars]

Remediation
View remediation

Remediation Suggestions

  1. Resolve the submitted path with Path.resolve(strict=True) and explicitly reject symbolic links using Path.is_symlink() before opening the file.
  2. Restrict local-file access to explicitly approved directories or to files selected through a trusted user-consent mechanism.
  3. Validate file contents rather than trusting the extension:
    • Check recognized image magic bytes.
    • Decode the file with a maintained image-processing library.
    • Reject malformed, unsupported, or ambiguous content.
  4. Open and validate the same file descriptor that will be uploaded to reduce time-of-check/time-of-use race conditions.
  5. On supported platforms, use no-follow semantics such as O_NOFOLLOW when opening user-controlled paths.
  6. Preserve the existing size limit and enforce it again while reading to protect against files that change after validation.

T09 · Insecure Skill Coding Practices

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

Cross-Origin Redirects May Forward the API Key and Image Payload

Content
View full analysis

Vulnerability Details

File Location: scripts/common/ocr_client.py:208-245
Vulnerability Type: Sensitive POST-body replay across redirects
Risk Level: Medium

Vulnerable Code

python
def _build_request_param(self, image_url: str = None, base64_data: str = None,
                         input_configs: 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

    if input_configs:
        param["inputConfigs"] = input_configs

    return param

def _send_request(self, param: Dict[str, Any]) -> requests.Response:
    """发送 HTTP 请求到夸克图像增强 API。

    ⚠️ 数据外发:本方法将图片二进制(BASE64 或公网 URL)发送到
    scan-business.quark.cn,服务端处理后不会永久保存。
    调用方需确保已获得用户授权。
    """
    headers = {"Content-Type": "application/json", "X-Appbuilder-From": self.platform}
    if VERSION:
        headers["X-Appbuilder-Version"] = VERSION
    if SKILL_NAME:
        headers["X-Appbuilder-Skill"] = SKILL_NAME
    response = self.session.post(
        API_URL,
        json=param,
        headers=headers,
        timeout=REQUEST_TIMEOUT,
        allow_redirects=True
    )
    return response

Technical Analysis

The request body contains both the API credential (aiApiKey) and either the Base64-encoded image or the user-provided image URL. The HTTP client is configured to follow redirects automatically.

An HTTP 307 or 308 response preserves the original request method and body. If the declared endpoint redirects to a different origin, the requests client may replay the credential-bearing POST body to that destination. This differs from authorization-header stripping because the sensitive credential is embedded directly in the JSON body.

The initial endpoint is a fixed HT ...[truncated 1515 chars]

Remediation
View remediation

Remediation Suggestions

  1. Disable automatic redirects for credential-bearing requests by setting allow_redirects=False.
  2. Treat any redirect as an error unless it is explicitly required and validated.
  3. If redirects must be supported:
    • Parse and validate the destination before following it.
    • Require HTTPS.
    • Require the exact approved hostname scan-business.quark.cn.
    • Reject hostname suffix tricks, embedded credentials, alternate ports, and cross-origin destinations.
    • Never replay a body containing the API key to another origin.
  4. Prefer an authentication mechanism that is not embedded in the application payload, while still ensuring authentication data is never forwarded across origins.
  5. Add automated tests covering 301, 302, 303, 307, and 308 responses, with particular attention to cross-origin 307 and 308 redirects.
  6. Rotate the API key promptly if logs or monitoring indicate that a credential-bearing request was redirected unexpectedly.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • 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
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (17)

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

This duplicate mismatch finding identifies the same core issue: the declared purpose excludes text recognition, but the skill appears to operate as a general scanning/OCR gateway. Misrepresenting functionality weakens informed consent, policy review, and safe handling expectations for potentially sensitive document images.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

This duplicate mismatch finding identifies the same core issue: the declared purpose excludes text recognition, but the skill appears to operate as a general scanning/OCR gateway. Misrepresenting functionality weakens informed consent, policy review, and safe handling expectations for potentially sensitive document images.

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 202)May include surrounding context.

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

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
88% confidence
Finding

The skill declares capabilities that involve environment secrets, local file handling, and outbound network transfer, but it does not define an explicit tool scope or permission boundary. That creates an over-privileged integration surface where the runtime may allow broader access than users or platform policy reviewers expect.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The activation text is overly broad and says the skill should trigger even when users do not explicitly request enhancement, as long as the request loosely involves image quality improvement. This can cause over-triggering on ordinary image or document requests, increasing unintended third-party data transfer and processing of sensitive content without clear user intent.

Content

No source excerpt is available for this finding.

Ssd 3

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill explicitly instructs sending user-provided images to a third-party server and states that returned images are saved in a local temporary directory until manually cleaned. This creates a real data exposure path for sensitive documents, screenshots, IDs, receipts, contracts, or notes, both in transit to the vendor and at rest on the local system.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

This code's natural-language documentation is written only in Chinese, including the primary module description and user-facing privacy notices. Under the stated policy, forcing a specific language without user opt-in can be a locale/language policy violation when no alternative or choice is provided.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

This code sends user-supplied image content, file paths, URLs, or base64 data to a remote OCR/processing service without any explicit warning, consent step, or data-handling notice in the execution path. Given the skill’s purpose includes sensitive documents such as IDs, exams, and contracts, users may unknowingly transmit personal or confidential images to a third party, creating meaningful privacy and compliance risk.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The module docstring is written only in Chinese, and the surrounding comments/docstrings are likewise Chinese-only. This creates a locale/language constraint in the skill file without offering any user choice or documenting a justified region-specific limitation.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

This code file contains user-facing natural-language documentation and class/function descriptions in Chinese, such as the module docstring and validator docstrings. Under the language/locale policy, forcing a specific language without user opt-in or justification can be a policy violation, and this file does not indicate that the skill is region-specific or that users can choose another language.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
90% confidence
Finding

The module docstring is written only in Chinese ("夸克扫描王公共模块", "提供请求客户端、图片落盘、验证器等公共功能") with no indication that language selection is optional or region-specific. This can violate a language/locale policy if organizational guidance requires user choice or documented justification for non-default language use.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
80% confidence
Finding

This Python file contains all human-readable documentation strings and comments in Chinese, including the module docstring and section labels. For an organization with language/locale choice expectations, this can constitute a natural-language policy issue because no opt-in, alternative locale, or justification for a Chinese-only audience is provided.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
93% confidence
Finding

The module title and description are written only in Chinese (图片落盘工具, 用于保存图像增强结果), which imposes a specific language/locale in the user-facing natural-language description without any opt-in or documented regional justification. Under the policy, language-specific constraints should either offer choice or be clearly justified as region-specific.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
96% confidence
Finding

This Python file contains multiple user-facing messages exclusively in Chinese, including CLI description and help text. Under the policy rule for natural-language violations, forcing a specific language without user choice can be a locale-policy issue when no opt-in or alternative is provided.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
74% confidence
Finding

The module documentation is written only in Chinese, and the CLI help strings referenced throughout this file appear to be intended for the same locale, with no indication of language choice or opt-in. The policy forbids forcing a specific language or locale unless the tool offers user choice or clearly documents a justified region-specific constraint.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
83% confidence
Finding

The code loads an API key via CredentialManager.load() and uses it to initialize a network client, but this file provides no user-facing warning, confirmation, or inline disclosure about credential access. Under the code-file criteria, access to sensitive environment variables or credentials should have some form of disclosure unless clearly documented elsewhere, which is not evident from this file alone.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
91% confidence
Finding

The only natural-language description in the file is the Chinese docstring "夸克扫描王 - 图像增强服务入口", which presents the skill in a fixed language without any indication of user opt-in or locale-specific justification. Under the stated policy, forcing a specific language can be a natural-language policy violation when no language choice is offered.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.