Back to skill

Security audit

财务报表分析技能

Security checks for vulnerabilities and agentic risk

Overview

This skill appears to do the promised financial-report analysis, but it can automatically install unpinned Python packages at runtime and writes unescaped workbook content into a Markdown report.

Install only in an isolated environment where runtime pip installs are acceptable, or preinstall reviewed pinned dependencies and block the script from installing packages automatically. Treat generated Markdown reports as containing sensitive local financial data, and be cautious with reports created from untrusted Excel files because crafted labels could manipulate the report display.

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)

T08 · Insecure Dependencies

Warning
Location
scripts/analyze_financial_report.py:22
Finding
Runtime Installation of Unpinned Third-Party Dependencies## Vulnerability Details **File Location**: `scripts/analyze_financial_report.py:22-29`; behavior is also declared in `SKILL.md:55` **Vulnerability Type**: Supply-chain exposure through automatic dependency installation **Risk Level**: Medium ### Vulnerable Code ```python try: import pandas as pd import openpyxl except ImportError: print("正在安装依赖...") import subprocess subprocess.check_call([sys.executable, "-m", "pip", "install", "pandas", "openpyxl"]) import pandas as pd import openpyxl ``` The corresponding Skill documentation states: ```markdown **环境依赖**:脚本会自动检查并安装 `pandas`、`openpyxl`,无需手动安装。 ``` ### Technical Analysis If either dependency import fails, the script automatically invokes `pip` and installs `pandas` and `openpyxl` into the active Python environment. Neither package versions nor distribution hashes are pinned. Package installation can execute package build or installation logic with the same operating-system privileges as the Agent process. The effective source is determined by the environment's `pip` configuration, including configured package indexes, mirrors, proxy behavior, and trusted-host settings. Consequently, a compromised package release, compromised or malicious mirror, or unsafe package-index configuration could cause unreviewed code to execute during an otherwise local financial-report analysis. The command uses an argument list rather than a shell command, so this is not shell-command injection. The risk arises from automatic retrieval and execution of mutable, unpinned third-party components. ### Attack Path 1. The Skill is invoked to analyze an Excel workbook. 2. At least one required module is unavailable or fails to import in the active environment. 3. The exception handler automatically launches `python -m pip install pandas openpyxl`. 4. `pip` resolves the latest acceptable distributions through the environment's configured index or m ...[truncated 1080 chars]
Remediation
## Remediation Suggestions 1. Remove dependency installation from the report-analysis runtime. If imports fail, terminate with a clear setup error rather than modifying the environment. 2. Declare dependencies in a reviewed dependency manifest and lock exact versions. 3. Require package hashes, for example through a hash-locked requirements file and `pip install --require-hashes`. 4. Install dependencies during a separate deployment or setup phase in an isolated virtual environment or container. 5. Use only an explicitly approved package index or internal mirror, with TLS verification enabled. 6. Regularly scan and update locked dependencies through a controlled review process. 7. Run the analysis process with least privilege and without unnecessary network access. A safer runtime pattern is: ```python try: import pandas as pd import openpyxl except ImportError as exc: raise RuntimeError( "Required dependencies are missing. Install the reviewed, locked " "dependencies before running this script." ) from exc ```

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/analyze_financial_report.py:264
Finding
Unescaped Workbook and Filename Content in Generated Markdown## Vulnerability Details **File Location**: `scripts/analyze_financial_report.py:264-276`, `scripts/analyze_financial_report.py:316-327`, and `scripts/analyze_financial_report.py:753-755` **Vulnerability Type**: Markdown output injection **Risk Level**: Medium ### Vulnerable Code Workbook row labels are inserted directly into Markdown table cells: ```python for _, row in df.iterrows(): label = str(row.iloc[0]).strip() if not label or label in ("nan", "小计", "合计") : continue try: curr = float(row.iloc[1]) if str(row.iloc[1]).strip() not in ("nan","None","") else None prev = float(row.iloc[2]) if str(row.iloc[2]).strip() not in ("nan","None","") else None except Exception: curr, prev = None, None if curr is None and prev is None: continue if curr is not None and prev is not None: delta = curr - prev rate = change_rate(curr, prev) rate_str = pct(rate) if rate is not None else "N/A" flag = "🔺" if (delta > 0) else ("🔻" if delta < 0 else "—") lines.append(f"| {label} | {fmt_num(curr)} | {fmt_num(prev)} | {flag} {fmt_num(delta)} | {rate_str} |") else: lines.append(f"| {label} | {fmt_num(curr)} | {fmt_num(prev)} | — | — |") ``` The same issue exists in the structure table: ```python lines.append( f"| {label} | {fmt_num(curr)} | {pct(r_curr)} | {fmt_num(prev)} | {pct(r_prev)} | {delta_str} |" ) ``` The attacker-influenced input filename is also inserted without Markdown escaping: ```python filename = Path(excel_path).name report_lines.append(f"# 财务报表分析报告\n") report_lines.append(f"> 文件:`{filename}` \n> 生成时间:{pd.Timestamp.now().strftime('%Y-%m-%d %H:%M')}\n") ``` ### Technical Analysis Excel cell values and the source filename are untrusted input. The script converts worksheet labels to strings and embeds them directly into a Markdown document without escaping Mar ...[truncated 2370 chars]
Remediation
## Remediation Suggestions 1. Treat all workbook strings and filenames as untrusted output data. 2. Escape at least pipe characters, backslashes, backticks, angle brackets, and line breaks before inserting values into Markdown. 3. Normalize cell labels to a single line and impose a reasonable maximum length. 4. Encode or remove raw HTML and image syntax when reports do not require them. 5. Configure the Markdown renderer to disable raw HTML, scripts, embedded objects, and automatic loading of remote resources. 6. Consider generating the table through a Markdown library that safely serializes cell values instead of manually interpolating strings. 7. Apply escaping consistently to worksheet labels, filenames, sheet names, and any future workbook-derived narrative fields. 8. Add tests using labels containing pipes, backticks, newlines, links, images, and HTML. For example: ```python def escape_markdown_cell(value): text = str(value) text = text.replace("\\", "\\\\") text = text.replace("|", "\\|") text = text.replace("`", "\\`") text = text.replace("&lt;", "&amp;lt;") text = text.replace("&gt;", "&amp;gt;") text = text.replace("\r", " ").replace("\n", " ") return text safe_label = escape_markdown_cell(label) lines.append( f"| {safe_label} | {fmt_num(curr)} | {fmt_num(prev)} | " f"{flag} {fmt_num(delta)} | {rate_str} |" ) ``` The filename should be escaped with a context-appropriate function before being placed inside backticks. Renderer-level restrictions should remain enabled even after output escaping as defense in depth.
Vulnerability Patterns
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
Findings (9)

Lp3

Medium
Category
MCP Least Privilege
Confidence
93% confidence
Finding
The skill instructs the agent to execute a Python script and produce a report file, but it declares no explicit tool scope or permissions. That creates an authorization gap where shell execution and file writes may occur without clear user-facing restriction, increasing the chance of unintended command execution or filesystem side effects.

Natural-Language Policy Violations

Medium
Confidence
96% confidence
Finding
The description specifies the skill in Chinese and directs it to automatically output a complete financial analysis report, with no indication that the user may choose another language. Forcing a specific language without opt-in can violate language/locale policy expectations when the skill may be used by a broader audience.

Vague Triggers

Medium
Confidence
91% confidence
Finding
The manifest-style description lists triggers such as “财务分析”, “财务指标”, “盈利能力”, and “成长能力”, which are broad topic phrases rather than narrowly scoped invocation terms. Without clearer constraints or negative examples, these phrases could cause unintended activation for general finance discussions that are not requests to analyze an uploaded financial statement Excel file.

Missing User Warnings

Medium
Confidence
89% confidence
Finding
The skill writes a generated Markdown report to disk but does not warn users up front. Undisclosed file creation can surprise users, leak sensitive financial data into local storage, or overwrite/create artifacts in directories the user did not expect.

Context-Inappropriate Capability

Medium
Confidence
91% confidence
Finding
Automatic dependency installation expands the skill's behavior from financial analysis into environment modification and network/package retrieval. This is risky because package installation can introduce unreviewed code, fail unpredictably, or be abused through dependency confusion or compromised package sources.

Missing User Warnings

Medium
Confidence
94% confidence
Finding
The documentation says the script may automatically install Python dependencies but does not warn users before execution. Hidden environment changes and package downloads are security-relevant because they can alter system state and introduce third-party code without informed consent.

Natural-Language Policy Violations

Medium
Confidence
95% confidence
Finding
The module docstring and all user-facing usage text are written only in Chinese, which imposes a specific language on users without any opt-in or alternative. The policy for this category flags language or locale constraints when the skill does not offer a language choice or document a justified region-specific limitation.

Context-Inappropriate Capability

Medium
Confidence
99% confidence
Finding
Automatically installing Python packages during execution is risky because it introduces network-dependent behavior and executes third-party package installation code at run time. For a skill meant only to analyze uploaded Excel files, this behavior is unnecessary in production and increases exposure to supply-chain compromise, package confusion, and unauthorized modification of the runtime environment.

subprocess module call

Medium
Category
Dangerous Code Execution
Content
except ImportError:
    print("正在安装依赖...")
    import subprocess
    subprocess.check_call([sys.executable, "-m", "pip", "install", "pandas", "openpyxl"])
    import pandas as pd
    import openpyxl
Confidence
97% confidence
Finding
The script invokes pip via subprocess at runtime when imports fail, causing code execution outside the normal financial-analysis workflow and fetching packages from external sources. In an agent/skill context, this expands the trust boundary to package indexes and the host environment, and can lead to unexpected installation of unreviewed code or environment tampering.

Static analysis

No suspicious patterns detected.