Back to skill

Security audit

门店Benchmark分析

Security checks for vulnerabilities and agentic risk

Overview

The skill’s retail benchmark purpose is coherent, but its implementation uses unsafe database query construction and imports an unaudited local module from a hard-coded user path.

Review before installing. This skill should only run in a controlled environment with a trusted api_client module, read-only database credentials, parameterized queries, strict date and scope validation, and documentation corrected to match the actual benchmark logic.

Vulnerability Patterns
  • Tool Hijacking and SpoofingModifies or replaces tools so legitimate-looking calls execute attacker logic
  • 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
analyze.py:100
Finding

SQL Injection Through Unparameterized Benchmark Query Inputs

Content
View full analysis

Vulnerability Details

File Location: analyze.py, lines 100-125
Vulnerability Type: SQL injection caused by direct interpolation of caller-controlled values
Risk Level: High

Vulnerable Code

python
if scope == ComparisonScope.CITY:
    where_clause = f"city_name = '{scope_code}'"
elif scope == ComparisonScope.PROVINCE:
    where_clause = f"province_name = '{scope_code}'"
elif scope == ComparisonScope.REGION:
    # 区域需要通过门店ID关联查询
    where_clause = f"region = '{scope_code}'"
else:
    where_clause = "1=1"  # 集团全部

sql = f"""
    SELECT 
        store_id,
        store_name,
        SUM(deal_amount) as total_sales,
        SUM(order_count) as total_orders,
        AVG(customer_unit_price) as avg_atv,
        AVG(deal_attach_rate) as avg_attach
    FROM v_gmv_daily_by_store
    WHERE {where_clause}
      AND biz_date BETWEEN '{from_date}' AND '{to_date}'
    GROUP BY store_id, store_name
    HAVING SUM(deal_amount) > 0
    ORDER BY total_sales DESC
"""

result = query_database(sql)

Technical Analysis

The scope_code, from_date, and to_date values are incorporated directly into an SQL statement using formatted strings. No parameter binding, escaping, or strict input validation is applied before the statement is passed to query_database.

An attacker who can control any of these function arguments can introduce SQL syntax that changes the intended query. For example, a crafted scope_code can terminate the quoted value and inject an always-true condition or another expression. Date arguments provide additional injection points.

Validation of the scope enumeration does not mitigate this issue because the values interpolated into the selected condition remain unconstrained.

Attack Path

  1. The attacker gains access to an interface that invokes analyze or fetch_stores_performance with caller-supplied arguments.
  2. The attacker submits a malic ...[truncated 1129 chars]
Remediation
View remediation

Remediation Suggestions

  • Replace string interpolation with parameterized queries supported by the database client. Bind scope_code, from_date, and to_date as data rather than including them in the SQL text.
  • Keep column selection under application control through the existing enumeration; never accept a column name directly from a caller.
  • Parse dates with a strict format such as %Y-%m-%d, reject invalid values, and verify that the start date does not exceed the end date.
  • Apply reasonable maximum date-range limits to prevent abusive or unexpectedly expensive queries.
  • Run the query through a dedicated, read-only database identity restricted to the required view and rows wherever row-level security is available.
  • Ensure the database client rejects multiple statements per execution.
  • Add tests using quotation marks, SQL comments, Boolean expressions, and malformed dates to confirm that supplied values cannot alter query structure.

A parameterized design should follow this pattern:

python
scope_columns = {
    ComparisonScope.CITY: "city_name",
    ComparisonScope.PROVINCE: "province_name",
    ComparisonScope.REGION: "region",
}

if scope == ComparisonScope.GROUP:
    where_clause = "1=1"
    params = [from_date, to_date]
else:
    where_clause = f"{scope_columns[scope]} = %s"
    params = [scope_code, from_date, to_date]

sql = f"""
    SELECT store_id, store_name,
           SUM(deal_amount) AS total_sales,
           SUM(order_count) AS total_orders,
           AVG(customer_unit_price) AS avg_atv,
           AVG(deal_attach_rate) AS avg_attach
    FROM v_gmv_daily_by_store
    WHERE {where_clause}
      AND biz_date BETWEEN %s AND %s
    GROUP BY store_id, store_name
    HAVING SUM(deal_amount) > 0
    ORDER BY total_sales DESC
"""

result = query_database(sql, params)

The exact placeholder style should be adapted to the database driver's supported parameter API.

T07 · Tool Hijacking and Spoofing

Error
Location
analyze.py:16
Finding

External Module Search-Path Hijacking Through a Hard-Coded Import Directory

Content
View full analysis

Vulnerability Details

File Location: analyze.py, lines 16-17
Vulnerability Type: Python module search-path hijacking
Risk Level: High

Vulnerable Code

python
sys.path.insert(0, '/Users/yangguangwei/.openclaw/workspace-front-door')
from api_client import query_database

Technical Analysis

The code inserts an external, user-specific directory at index zero of sys.path. This gives that directory priority over the normal Python package search locations. The subsequently imported api_client module is not included in the audited project, so its implementation and integrity cannot be established from this package.

Python executes module-level code while importing a module. Consequently, an attacker who can create or replace api_client.py, or an equivalent importable package, in the hard-coded directory can execute arbitrary Python code merely by causing analyze.py to be imported or run.

This is a tool-spoofing condition because a local module can impersonate the expected database client and intercept or alter apparently legitimate calls to query_database.

Attack Path

  1. The attacker obtains write access to /Users/yangguangwei/.openclaw/workspace-front-door, or compromises a process or deployment mechanism that populates that location.
  2. The attacker creates or replaces api_client.py with a malicious implementation.
  3. A user, agent, or service imports or executes analyze.py.
  4. The call to sys.path.insert(0, ...) gives the attacker-controlled directory the highest import priority.
  5. Python resolves from api_client import query_database to the malicious module and executes its module-level code.
  6. The malicious module runs with the operating-system permissions, environment variables, filesystem access, and network access of the process loading the skill. It may also spoof database responses or inspect every SQL query supplied to query_database.

Exploitation requir ...[truncated 744 chars]

Remediation
View remediation

Remediation Suggestions

  • Remove the runtime modification of sys.path.
  • Package api_client as an explicit, trusted dependency or place it in a controlled module within the application package.
  • Pin the dependency to an approved version and verify its integrity through lock files, hashes, signed artifacts, or a trusted internal package registry.
  • Use an unambiguous package import rather than a generic top-level module name, for example:
python
from trusted_application.api_client import query_database
  • Ensure application and dependency directories are owned by a trusted deployment account and are not writable by lower-privileged users.
  • Run the skill under a least-privileged service identity with only the filesystem, database, and network access required for benchmark analysis.
  • Add deployment checks that resolve and log api_client.__file__, then fail closed if the resolved module is outside the approved installation path.
  • Include the external module in future audit scope because its implementation controls database access and executes within the skill process.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (7)

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

The skill promises capabilities that are not actually implemented, including same-level benchmark comparisons and a multi-metric grading model, while apparently using only sales-rank percentile for level assignment. This can mislead downstream users or agents into making business decisions based on inaccurate or incomplete analysis, which is a genuine integrity and trust issue even if it is not classic code execution.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The natural-language instructions and examples are entirely Chinese, which can imply a fixed language expectation for users. The file does not offer opt-in language selection or explain that the skill is intentionally limited to a Chinese-language or region-specific audience.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The trigger phrases are broad enough to match routine retail questions such as ranking or comparison requests that may not actually require this benchmark skill. In an agent environment, over-broad routing can cause unintended invocation, producing irrelevant analysis, exposing unnecessary business context, or crowding out more appropriate skills.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
77% confidence
Finding

The natural-language description and all user-facing report strings are written exclusively in Chinese, indicating the skill is designed to operate in a single language without any opt-in or alternative locale handling. The file does not document that this is a region-specific tool or provide a way for users to choose their preferred language.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The skill manifest claims 门店等级评估 is based on 销售额、订单数、客单价、连带率, but the implemented tier property uses only percentile, which itself comes solely from sales-order ranking. This is not just incomplete documentation: it creates a direct contradiction between the claimed evaluation basis and the actual logic used to assign store grades.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
85% confidence
Finding

The code sends a dynamically constructed SQL query to an external database via query_database(sql), which transmits business/store data off-function, but there is no confirmation prompt, logging, or user-facing notice around this data access. In this file, the docstrings describe analysis behavior but do not warn that store-level performance data will be queried and processed from a backend system.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The manifest lists '同等级门店对比(找出同级别标杆)' as a core capability, but the main analysis only returns the target store, overall ranking, matrix analysis, and top 5 stores overall. There is no logic that filters stores by the target's tier or selects same-tier benchmark peers, so the delivered behavior falls short of the stated functionality.

Content

No source excerpt is available for this finding.