Back to skill

Security audit

App Order Date Key Stats

Security checks for vulnerabilities and agentic risk

Overview

The skill is a database reporting helper, but its SQL-building instructions can let user input alter the query and its documented outputs do not match the executable query.

Review before installing. Use only with a least-privileged read-only database account, restrict it to the required table or views, and update the skill to use parameterized SQL plus strict date and keyword validation. Also align the documented and executable query outputs and pin dependency versions.

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
SKILL.md:109
Finding
SQL Injection Through Direct Interpolation of User-Controlled Values<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 109–129 **Vulnerability Type**: SQL injection **Risk Level**: High ### Vulnerable Code ```python conditions = [f"(order_title LIKE '%{k}%' OR order_desc LIKE '%{k}%')" for k in keyword.split()] keyword_filter = f"AND ({' OR '.join(conditions)})" ``` ```python sql = f""" SELECT {time_select}, COUNT(DISTINCT user_id) AS 用户, COUNT(CASE WHEN order_state IN ('CREATED', 'PAY_CANCEL', 'PAY_FAILED', 'PAY_WAIT', 'ORDER_CLOSED') THEN 1 END) AS 未支付订单, COUNT(CASE WHEN order_state IN ('ORDER_REFUND_ALL', 'ORDER_REFUND_PART') THEN 1 END) AS 退款订单, ROUND(SUM(CASE WHEN order_state IN ('PAY_SUCCESS', 'ORDER_REFUND_ALL', 'ORDER_REFUND_PART') THEN pay_amount ELSE 0 END) / 100, 0) as 支付金额, FORMAT(SUM(CASE WHEN order_state IN ('ORDER_REFUND_ALL', 'ORDER_REFUND_PART') THEN refunded_amount ELSE 0 END) / 100, 0) AS 退款金额, COUNT(DISTINCT user_id) as 用户数 FROM juss_dw.app_j_order FORCE INDEX (idx_order_title_desc) WHERE create_time >= '{start_time}' AND create_time < '{end_time}' {keyword_filter} GROUP BY {group_by} ORDER BY {order_by}; """ ``` ### Technical Analysis The Skill inserts `keyword`, `start_time`, and `end_time` values directly into an SQL statement through Python f-strings. No parameterized query, escaping mechanism, or strict input validation is applied. The keyword is especially dangerous because every token is placed between SQL string delimiters: ```python f"(order_title LIKE '%{k}%' OR order_desc LIKE '%{k}%')" ``` A token containing a quote can terminate the intended string literal and introduce SQL operators, expressions, or comments. The start and end times are similarly vulnerable because they are embedded directly between single quotes. Restricting the database account to read-only access reduces the potential for database modification, but it does not prevent attackers from changing query semantics, bypassing filters, accessing additional rows available ...[truncated 1984 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Use MySQL parameter placeholders for every user-controlled value: ```python keyword_conditions = [] params = [start_time, end_time] for keyword_item in keywords: escaped_item = ( keyword_item .replace("\\", "\\\\") .replace("%", "\\%") .replace("_", "\\_") ) keyword_conditions.append( "(order_title LIKE %s ESCAPE '\\\\' OR order_desc LIKE %s ESCAPE '\\\\')" ) pattern = f"%{escaped_item}%" params.extend([pattern, pattern]) keyword_filter = "" if keyword_conditions: keyword_filter = "AND (" + " OR ".join(keyword_conditions) + ")" sql = f""" SELECT ... FROM juss_dw.app_j_order FORCE INDEX (idx_order_title_desc) WHERE create_time >= %s AND create_time < %s {keyword_filter} GROUP BY {group_by} ORDER BY {order_by} """ df = pd.read_sql(sql, conn, params=params) ``` 2. Parse dates with `datetime.strptime` or an equivalent strict parser and reject values that do not match the accepted formats. 3. Preserve a strict allowlist mapping for `DATE`, `HOUR`, and `MONTH`; never insert arbitrary user-provided identifier or expression text. 4. Define the keyword delimiter explicitly and impose limits on keyword count and length. 5. Retain the read-only database account and restrict it to only the required table and columns. 6. Configure query timeouts and row/resource limits to reduce denial-of-service exposure. 7. Avoid returning raw database error messages to users because they may disclose schema or connection details. 8. Add automated tests using quotes, comment markers, wildcard characters, malformed dates, and oversized inputs. ]]>

T08 · Insecure Dependencies

Warning
Location
SKILL.md:10
Finding
Unpinned Third-Party Python Dependencies<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 10–14 **Vulnerability Type**: Dependency supply-chain risk **Risk Level**: Medium ### Vulnerable Code ```yaml metadata: { "openclaw": { "emoji": "📈🏟️", "requires": { "bins": ["python"], "python_packages": ["mysql-connector-python", "pandas", "tabulate"] } } } ``` ### Technical Analysis The Skill declares three runtime Python packages without exact version constraints or integrity hashes. Consequently, separate installations can resolve to different package versions over time. The listed package names correspond to established packages, and the audit found no evidence that the Skill intentionally references a typosquatted or known-malicious package. Nevertheless, unconstrained resolution means that future upstream releases, a compromised package distribution channel, or dependency-resolution changes could introduce unreviewed code into the execution environment. Python packages can run code during installation and are imported into the same process that receives database credentials and executes queries. A compromised dependency could therefore act with the operating-system privileges and environment access of that process. ### Attack Path 1. The Skill is installed or executed in an environment that automatically resolves its declared Python dependencies. 2. Because no versions or hashes are specified, the installer retrieves whichever releases currently satisfy the unconstrained package names. 3. An upstream package, transitive dependency, package index, or distribution channel is compromised, or an incompatible release is published. 4. The affected package executes code during installation or when imported. 5. That code runs with the privileges of the Skill process and may access environment variables, query results, files, or network resources available to that process. This is a supply-chain exposure rather than evidence that the ...[truncated 633 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Pin every direct dependency to an explicitly reviewed version, for example: ```yaml "python_packages": [ "mysql-connector-python==<reviewed-version>", "pandas==<reviewed-version>", "tabulate==<reviewed-version>" ] ``` 2. Maintain a lockfile that also pins transitive dependencies. 3. Require package hashes during installation, such as through a hash-locked requirements file and `pip --require-hashes`. 4. Retrieve packages only from an approved, authenticated package repository or internal mirror. 5. Scan dependencies for known vulnerabilities and license or provenance concerns before release. 6. Review and deliberately update pinned versions on a controlled schedule. 7. Run the Skill in a least-privileged, isolated environment with restricted filesystem and outbound-network access. 8. Expose database credentials only immediately before execution and only to the process that requires them. ]]>
Vulnerability Patterns
  • 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
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (5)

Intent-Code Divergence

High
Confidence
96% confidence
Finding
The skill advertises key business indicators including order count and net sales amount, but the actual SQL returns a different metric set and omits some promised fields. In a security context, deceptive or inaccurate capability claims are dangerous because they prevent reliable review, can hide unauthorized logic changes, and may lead downstream systems or users to trust incorrect outputs.

Intent-Code Divergence

High
Confidence
98% confidence
Finding
The skill promises a fixed SQL template where only the time-dimension fields may change, but the executable example materially changes selected metrics, counting logic, and output columns. This mismatch can cause the agent to run a query different from what reviewers or users expect, undermining safety guarantees and enabling unauthorized broadening of behavior under the guise of a 'fixed' template.

Intent-Code Divergence

Medium
Confidence
95% confidence
Finding
The documentation says keywords are comma-separated, but the code splits on whitespace and interpolates each token directly into SQL LIKE clauses. This inconsistency can produce unintended query expansion, incorrect filtering, and increases the risk surface for SQL manipulation because user-controlled fragments are embedded without safe parameterization.

Vague Triggers

Medium
Confidence
83% confidence
Finding
The usage section lists triggers such as “订单量趋势” and “支付金额汇总”, which are broad business-analysis phrases that could match many ordinary requests beyond this skill’s narrow SQL template. Although some domain context is present, the file does not give negative examples or stricter activation boundaries, so unintended invocation risk remains.

Natural-Language Policy Violations

Low
Confidence
96% confidence
Finding
The instructions require the results to be presented as a Markdown table and to add a Chinese summary, which imposes a specific language on the user. This is a natural-language policy issue because no opt-in or alternative locale handling is provided.

Static analysis

No suspicious patterns detected.