Back to skill

Security audit

A 股多空辩论

Security checks for vulnerabilities and agentic risk

Overview

The skill has a coherent stock-analysis purpose, but it asks the agent to run unsafe local proxy and Python execution steps that could execute unintended code.

Review this skill before installing. Its data sources and GLM analysis are aligned with A-share research, but the current instructions should be hardened: use a trusted, verified proxy binary outside `/tmp`; track and stop only the proxy process the skill starts; validate stock identifiers before execution; and understand that stock queries and generated analysis may be sent to BigModel/GLM.

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 (3)

T07 · Tool Hijacking and Spoofing

Error
Location
SKILL.md:47
Finding

Execution of an Unverified Binary from a Predictable Temporary Path

Content
View full analysis

Vulnerability Details

File Location: SKILL.md, lines 47-48
Vulnerability Type: Untrusted executable path and local tool hijacking
Risk Level: High

bash
pgrep -f mihomo_bin > /dev/null && return
nohup /tmp/mihomo_bin -f /tmp/mihomo_config.yaml -d /tmp/mihomo_data > /tmp/mihomo.log 2>&1 &

Technical Analysis

The Skill instructs the Agent to execute /tmp/mihomo_bin and consume /tmp/mihomo_config.yaml without verifying their origin, owner, permissions, signature, or cryptographic checksum. Predictable paths under /tmp are not appropriate trust boundaries for executable files or security-sensitive configuration because local users or previously executed processes may be able to create or replace them.

The preliminary pgrep check does not establish that a matching process is the expected binary. It only checks whether any process command line contains the selected name. The configuration can also affect proxy routing and traffic handling even if the executable itself is legitimate.

Attack Path

  1. An attacker with local write access creates or replaces /tmp/mihomo_bin with an executable payload.
  2. The attacker optionally creates /tmp/mihomo_config.yaml to redirect or inspect proxied network traffic.
  3. A user invokes the stock-analysis Skill.
  4. The Agent follows the documented workflow and launches the attacker-controlled executable.
  5. The payload runs with the same operating-system privileges and access available to the Agent.

Impact Assessment

Successful exploitation permits arbitrary local code execution under the Agent's account. The payload could read files and environment variables accessible to that account, including API credentials such as GLM_API_KEY; alter analysis results; tamper with proxied traffic; invoke additional processes; or modify writable project and user files. This does not independently grant elevated operating-system privileges, but ...[truncated 61 chars]

Remediation
View remediation

Remediation Suggestions

  • Install Mihomo from a trusted, pinned release into an application-owned directory that is not writable by untrusted users, such as a restricted installation directory outside /tmp.
  • Verify the binary against a pinned SHA-256 checksum or trusted signature before every execution.
  • Verify that the binary and configuration are regular files, are not symbolic links, have the expected owner, and are not group- or world-writable.
  • Store generated runtime files in a private directory created with restrictive permissions, such as mode 0700, and use unpredictable names.
  • Keep the proxy configuration in an application-controlled path with restrictive permissions.
  • Replace the process-name test with PID tracking and executable identity verification.
  • Fail securely if any ownership, permission, path, or integrity validation fails.

T09 · Insecure Skill Coding Practices

Error
Location
SKILL.md:72
Finding

Python Code Injection Through Unvalidated Stock Identifier Substitution

Content
View full analysis

Vulnerability Details

File Location: SKILL.md, line 72
Vulnerability Type: Source-code injection through unsafe template substitution
Risk Level: High

python
code = "{CODE}"

Technical Analysis

The Skill instructs the Agent to replace {CODE} with the user-provided stock identifier and then execute the resulting Python script. The trigger accepts a stock code, name, or abbreviation, but the workflow does not validate or escape the value before placing it inside a Python string literal.

Direct textual substitution allows quote characters and Python syntax to terminate the intended string and introduce new statements. For example, a value shaped like "; __import__("os").system("id"); # would transform the generated source into executable injected Python if substituted verbatim.

This vulnerability exists because data is converted into source code rather than passed through a separate data channel. Exploitation is conditional on the Agent following the documented direct-replacement procedure without independently sanitizing the value.

Attack Path

  1. A user invokes the Skill with a crafted value presented as a stock identifier.
  2. The value contains a closing quote, a separator, an arbitrary Python expression, and a comment marker.
  3. The Agent directly replaces {CODE} in the documented Python template.
  4. The generated script is executed through the Skill's instructed execution mechanism.
  5. Python evaluates the injected statement with the same privileges as the Agent.

Impact Assessment

Successful exploitation provides arbitrary Python code execution under the Agent's account. An attacker could execute operating-system commands, inspect accessible environment variables, read or modify files, make network requests, manipulate collected market data, or interfere with other processes. The flaw does not itself bypass operating-system privilege controls, so its scope is limited to resour ...[truncated 35 chars]

Remediation
View remediation

Remediation Suggestions

  • Do not construct executable Python source by substituting user-controlled values.
  • Pass the stock code as a command-line argument, standard input value, or environment variable and read it as data from a fixed script.
  • Resolve stock names and abbreviations through a trusted lookup step, then retain only the resulting canonical numeric code.
  • Enforce a strict allowlist before use, for example:
python
import re
import sys

code = sys.argv[1]
if not re.fullmatch(r"[036]\d{5}", code):
    raise ValueError("Invalid A-share stock code")
  • Reject quotes, whitespace, control characters, shell metacharacters, and any value that does not match the canonical format.
  • Keep user-controlled values out of shell commands, Python source templates, and dynamic evaluation functions.
  • Add tests using malformed identifiers and injection payloads to confirm that validation fails before script execution.

T09 · Insecure Skill Coding Practices

Warning
Location
SKILL.md:53
Finding

Overbroad Process Termination Using Command-Line Pattern Matching

Content
View full analysis

Vulnerability Details

File Location: SKILL.md, lines 53-56
Vulnerability Type: Unsafe process lifecycle management
Risk Level: Medium

bash
stock_stop_proxy() {
    pkill -f mihomo_bin 2>/dev/null
    sleep 1
}

Technical Analysis

The shutdown function uses pkill -f mihomo_bin, which matches the full command line of every accessible process rather than the specific proxy process launched by this Skill. It does not verify a PID, executable path, process owner, launch time, or parent-child relationship.

Consequently, the function can terminate pre-existing Mihomo instances, unrelated commands containing the same text, or proxy services belonging to another workload under the same account. The startup logic also returns when any matching process exists, while the shutdown logic later terminates all matching processes, making it possible to stop a process that the Skill did not start.

Attack Path

  1. A legitimate or unrelated process has mihomo_bin in its command line before the Skill runs.
  2. The startup check treats that process as an already-running proxy and does not create a dedicated process.
  3. The stock-data collection stage finishes.
  4. The mandatory cleanup function executes pkill -f mihomo_bin.
  5. Every matching process accessible to the Agent is terminated, including processes not owned by this Skill's lifecycle.

Impact Assessment

Exploitation or accidental triggering can cause denial of service for unrelated proxy-dependent workloads running under the same account. It may interrupt network access, data collection, or other Agent sessions. The command cannot normally terminate processes outside the invoking account unless the Agent already has elevated privileges, but when run with elevated privileges its disruption scope would increase accordingly.

Remediation
View remediation

Remediation Suggestions

  • Capture the exact PID immediately after starting the proxy with $!.
  • Store the PID in a private runtime directory and terminate only that process.
  • Before termination, verify that the PID is still running, belongs to the current user, and resolves to the expected executable.
  • Track whether the current Skill invocation created the process. Do not terminate a proxy that existed before invocation.
  • Prefer graceful termination with kill -TERM, wait for a bounded interval, and use stronger termination only for the verified PID if necessary.
  • Remove process-name-based pgrep and pkill lifecycle management.

A safer lifecycle pattern is:

bash
nohup /trusted/path/mihomo -f /private/path/config.yaml > /private/path/mihomo.log 2>&1 &
proxy_pid=$!

if kill -0 "$proxy_pid" 2>/dev/null; then
    kill -TERM "$proxy_pid"
    wait "$proxy_pid" 2>/dev/null
fi
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Rogue AgentSelf-Modification, Session Persistence
  • 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 (6)

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

文档在数据架构中声明“财务指标”来源为“Tushare”,且标注“已配置token”,这会让开发者理解该步骤依赖 Tushare 接口与相应凭据。但实际采集代码在财务指标部分导入并调用的是 AkShare,而非 Tushare,属于文档对实现的主动性误导而非单纯遗漏。

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The skill instructs sending collected stock/query data to an external LLM API, but the skill description does not present a clear user-facing privacy disclosure or consent step. Even if the data is not highly sensitive in all cases, user prompts, trading interests, and derived analysis can reveal confidential strategies or personal investment intent when transmitted to a third party.

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
Confidence
81% confidence
Finding

The skill starts a background proxy process with nohup and relies on a later cleanup step to terminate it. If the workflow fails, is interrupted, or cleanup is skipped, the proxy may persist across the session and alter subsequent network routing, creating unintended exposure, cross-task interference, or a lingering covert communications path.

Content

Scanner excerpt · SKILL.md (reported line 48)May include surrounding context.

md
# 启动代理(如未运行)
stock_start_proxy() {
    pgrep -f mihomo_bin > /dev/null && return
    nohup /tmp/mihomo_bin -f /tmp/mihomo_config.yaml -d /tmp/mihomo_data > /tmp/mihomo.log 2>&1 &
    sleep 2
    curl -s --connect-timeout 5 --proxy ${STOCK_PROXY:-http://127.0.0.1:7890} https://httpbin.org/ip | grep -q origin || echo "PROXY_DOWN"
}

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
82% confidence
Finding

The skill reads sensitive environment variables such as GLM_API_KEY and STOCK_PROXY without clearly warning users or operators about credential usage and handling. While merely reading env vars is common, the absence of guidance increases the risk of accidental exposure, misuse, or unsafe deployment practices in shared environments.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
78% confidence
Finding

文档明确声明使用 GLM API、给出 base URL、API Key 来源及模型分工,表述为该 skill 的既定实现方案;但全文执行代码仅包含 shell 与 Python 数据采集示例,没有任何实际 GLM API 调用代码或命令。对于“如何实际执行分析/辩论”的实现意图,文档配置说明与代码内容存在明显落差。

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
87% confidence
Finding

The package description is written entirely in Chinese and presents the skill as Chinese-language-specific, but the file does not indicate that this locale constraint is optional or limited to a justified region-specific use case. Under the policy, forcing a specific language without user opt-in can be a natural-language policy violation.

Content

No source excerpt is available for this finding.