Back to skill

Security audit

ask-data

Security checks for vulnerabilities and agentic risk

Overview

This skill reads user-selected Excel files to answer data questions, with disclosed local-file access and no evidence of hidden persistence, network exfiltration, or file modification.

Install only if you are comfortable letting the skill read the Excel files you explicitly provide. Avoid very large or untrusted workbooks, and do not use it on files containing sensitive rows if showing sample data back to the agent would be inappropriate.

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/query_data.py:70
Finding
User-Controlled Regular Expression Enables Denial of Service<![CDATA[ ## Vulnerability Details **File Location**: `scripts/query_data.py`, lines 70-71 **Vulnerability Type**: Unvalidated regular-expression processing **Risk Level**: Medium ### Vulnerable Code ```python elif op == "contains": df = df[df[col].astype(str).str.contains(str(val), na=False)] ``` ### Technical Analysis The `contains` filter passes the user-controlled query value directly to `pandas.Series.str.contains()`. This API treats its pattern as a regular expression by default because `regex=True` is implicit. The value originates from the supplied query JSON and is not escaped, validated, complexity-limited, or processed with a timeout. An attacker can therefore provide an invalid expression to trigger query failure or a catastrophically backtracking expression, such as `(a+)+$`, to consume excessive CPU when evaluated against suitably long worksheet values. This operation is performed across every applicable value in the selected column, which can amplify the computational cost on large worksheets. ### Attack Path 1. An attacker supplies or influences an Excel workbook containing many long strings, such as strings composed of repeated `a` characters followed by a nonmatching character. 2. The attacker causes a query to use the `contains` operator against that column. 3. The query JSON contains a computationally expensive regular expression, such as `(a+)+$`. 4. `apply_filters()` passes the expression to `Series.str.contains()` with regular-expression processing enabled. 5. The regular-expression engine performs excessive backtracking for each applicable cell. 6. The query process experiences high CPU consumption, stalls, or becomes unavailable. An invalid regular expression can also raise an exception and force the query to fail, although the surrounding query handler returns the error rather than crashing the entire interpreter. ### Impact Assessment Successful exploitation affects availability. It can monopolize CPU resources, substant ...[truncated 418 chars]
Remediation
<![CDATA[ ## Remediation Suggestions Treat `contains` as literal substring matching unless regular-expression support is explicitly required: ```python elif op == "contains": df = df[df[col].astype(str).str.contains(str(val), regex=False, na=False)] ``` Additional hardening should include: 1. Define a maximum length for filter values. 2. Reject unsupported operators before processing the query. 3. If regular expressions are required, expose them through a separate operator and validate expression syntax and complexity. 4. Use a timeout-capable or non-backtracking regular-expression engine where possible. 5. Apply process-level CPU and execution-time limits. 6. Return a clear validation error for rejected patterns rather than evaluating them. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/query_data.py:157
Finding
Unbounded Excel Worksheet Loading Enables Resource Exhaustion<![CDATA[ ## Vulnerability Details **File Locations**: `scripts/query_data.py`, lines 157-158; `scripts/read_excel.py`, lines 35-39 **Vulnerability Type**: Unrestricted processing of attacker-influenced workbook content **Risk Level**: Medium ### Vulnerable Code The query operation loads the complete selected worksheet before filtering or applying the result limit: ```python try: # 读取数据 df = pd.read_excel(file_path, sheet_name=sheet_name) total_rows = len(df) ``` The structure inspection operation opens the workbook and iterates over every worksheet: ```python try: # 读取所有sheet xl = pd.ExcelFile(file_path) sheets = [] for sheet_name in xl.sheet_names: df = pd.read_excel(file_path, sheet_name=sheet_name, nrows=100) ``` The output limit in `query_data.py` is applied only after the complete worksheet has been loaded, cleaned, filtered, aggregated, and sorted: ```python # 应用限制 limit = query_json.get("limit", 1000) df = df.head(limit) ``` ### Technical Analysis `query_data()` calls `pandas.read_excel()` without row, column, file-size, decompressed-size, memory, or execution-time restrictions. As a result, the entire worksheet is materialized in memory before any filtering or output limit takes effect. Although `read_excel_structure()` limits each worksheet to 100 rows, it still opens the workbook and processes every sheet without limiting the number of sheets, columns, workbook size, or decompressed archive size. Modern Excel files are compressed containers. A workbook can therefore have a relatively small on-disk size while expanding into a much larger in-memory representation. Large dimensions, numerous sheets, wide rows, repeated strings, or highly compressed content can produce substantial CPU and memory consumption. The documented warning for files larger than 100,000 rows is not enforced programmatically, so it does not prevent this issue. ### Attack Path 1. An attacker creates or supplies a very large, very wid ...[truncated 1157 chars]
Remediation
<![CDATA[ ## Remediation Suggestions Implement layered resource controls before and during workbook processing: 1. Reject files exceeding a configurable on-disk size threshold before opening them. 2. For `.xlsx` and `.xlsm` archives, inspect archive metadata and reject excessive decompressed sizes or suspicious compression ratios. 3. Inspect workbook dimensions before fully materializing a worksheet. 4. Enforce maximum worksheet, row, and column counts. 5. Limit the number of sheets inspected by the structure-reading operation. 6. Use `nrows` and selected columns where the requested operation permits incremental or restricted loading. 7. Do not rely on the output `limit` as an input-processing limit; enforce limits before aggregation and sorting. 8. Execute parsing in an isolated worker with memory, CPU, and wall-clock limits. 9. Require explicit additional confirmation for unusually large workbooks and clearly state the estimated resource cost. 10. Catch memory and timeout failures and return a controlled error without destabilizing the parent Agent 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
93% confidence
Finding
声明描述的是一个面向用户问句的数据分析/查询能力,例如回答“昨天DAU多少”或“最近7天新增用户趋势”,这需要解析自然语言、将其转成查询、对Excel数据进行计算,并可能输出图表。实际代码没有任何问句处理、查询转换、指标计算、趋势分析或图表生成逻辑。它只是读取本地Excel文件,检查扩展名,遍历sheet,并返回列信息与少量样本数据。虽然这可能是数据问答系统的底层辅助步骤,但就该代码块本身而言,其主要行为与声明的核心用途存在明显差异,因此应判定为不匹配。

Vague Triggers

Medium
Confidence
95% confidence
Finding
The description says the skill activates for data-related questions such as “查询数据,” which is a very generic phrase and can overlap with ordinary conversation. The trigger guidance does not provide clear boundaries or negative examples to distinguish when this skill should activate versus when another general assistant behavior should apply.

Natural-Language Policy Violations

Medium
Confidence
92% confidence
Finding
The skill states “理解中文自然语言查询,” which constrains operation to Chinese-language queries without offering the user a language choice or documenting a justified locale restriction. This is a natural-language policy concern because it imposes a language requirement by default.

Natural-Language Policy Violations

Medium
Confidence
88% confidence
Finding
This markdown file is entirely written as Chinese-only user query examples and follow-up handling patterns, with no indication that other languages are supported or that Chinese is an optional locale. Under the policy, forcing a specific language without user opt-in is a natural-language policy violation unless the locale restriction is clearly documented and justified.

Natural-Language Policy Violations

Medium
Confidence
92% confidence
Finding
This code file contains natural-language instructions and usage text exclusively in Chinese, including the module docstring and query format description. Under the language/locale policy, forcing a specific language without offering a choice or documenting a justified locale constraint is a policy violation.

Natural-Language Policy Violations

Medium
Confidence
90% confidence
Finding
The command-line error output shown to users is only in Chinese and does not offer a language choice. This creates a language-policy issue because the skill enforces a locale in user-facing interaction without opt-in or clear regional justification.

Missing User Warnings

Medium
Confidence
95% confidence
Finding
The script returns column samples and the first five records from every sheet directly to stdout as JSON, which can expose sensitive workbook contents such as PII, credentials, financial data, or internal business information. In this skill’s context, the tool is designed for natural-language querying over local Excel files, so automatic extraction and display of sample data increases the chance of unnecessary data disclosure beyond what the user explicitly asked for.

Static analysis

No suspicious patterns detected.