Back to skill

Security audit

china-stock-analyzer

Security checks for vulnerabilities and agentic risk

Overview

This skill coherently fetches public A-share market data and produces technical-analysis summaries, with some setup and financial-advice risks users should understand.

Install only in a virtual environment, review or pin dependencies before running setup_env.py, expect stock symbols/names to be sent to external market-data APIs, and treat generated buy/sell/hold signals as technical reference rather than financial advice.

Vulnerability Patterns
  • Insecure DependenciesIntroduces malicious components through unsafe dependency sources
  • 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 (1)

T08 · Insecure Dependencies

Warning
Location
scripts/setup_env.py:24
Finding

Automatic Installation of Unpinned Third-Party Dependencies

Content
View full analysis

Vulnerability Details

File Location: scripts/setup_env.py:24-47
Vulnerability Type: Unpinned dependency installation and mutable supply-chain execution
Risk Level: Medium

Vulnerable Code

python
REQUIRED_PACKAGES: List[str] = [
    "akshare",
    "pandas",
]


def is_package_installed(package: str) -> bool:
    """Use `python -m pip show` to determine whether a package is installed."""

    try:
        subprocess.check_output(
            [sys.executable, "-m", "pip", "show", package],
            stderr=subprocess.DEVNULL,
        )
        return True
    except subprocess.CalledProcessError:
        return False


def install_package(package: str) -> None:
    """Install a package through pip associated with the current interpreter."""

    print(f"[INFO] Installing dependency: {package} ...")
    subprocess.check_call([sys.executable, "-m", "pip", "install", package])

Technical Analysis

The setup script automatically invokes pip for packages specified only by name. It does not constrain dependency versions, verify package hashes, use a reviewed lockfile, disable installation scripts, or explicitly select a trusted package index.

Consequently, the code installed by the Skill can change without any change to the audited repository. Pip may also resolve and install mutable transitive dependencies. Installation can execute package build backends or setup logic with the privileges of the user running the setup script.

The subprocess call uses an argument list rather than a shell and the package names are hardcoded, so this is not command injection or direct dependency confusion through attacker-controlled package names. Exploitation instead requires compromise of an upstream package or dependency, malicious publication through a configured package index, or manipulation of the user's pip index configuration.

Attack Path

  1. The user runs `python3 scripts/setup_e ...[truncated 1173 chars]
Remediation
View remediation

Remediation Suggestions

  1. Pin every direct dependency to a reviewed version rather than installing by package name alone.
  2. Generate a lockfile that includes all transitive dependencies.
  3. Require cryptographic hashes during installation, for example with a hash-locked requirements file and pip install --require-hashes -r requirements.txt.
  4. Configure an explicitly approved HTTPS package index instead of silently inheriting arbitrary user or environment-level pip index settings.
  5. Review dependency updates before changing pinned versions, including transitive dependency changes and published artifacts.
  6. Do not install dependencies automatically without explicit user confirmation. Prefer printing a reproducible installation command or documented environment setup procedure.
  7. Install dependencies in an isolated virtual environment with only the permissions required for market-data analysis.
  8. Where operationally feasible, use prebuilt, reviewed wheels and prevent unexpected source builds.
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • 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 (22)

Tp4

High
Category
MCP Tool Poisoning
Confidence
93% confidence
Finding

If the skill actually installs packages via pip and uses subprocess to inspect or modify the Python environment, that exceeds the declared stock-analysis purpose and introduces supply-chain and execution-scope risk. Undeclared environment mutation can lead to arbitrary code execution through malicious packages, version drift, or unsafe shell invocation, especially in shared agent runtimes.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

If the skill actually installs packages via pip and uses subprocess to inspect or modify the Python environment, that exceeds the declared stock-analysis purpose and introduces supply-chain and execution-scope risk. Undeclared environment mutation can lead to arbitrary code execution through malicious packages, version drift, or unsafe shell invocation, especially in shared agent runtimes.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

If the skill actually installs packages via pip and uses subprocess to inspect or modify the Python environment, that exceeds the declared stock-analysis purpose and introduces supply-chain and execution-scope risk. Undeclared environment mutation can lead to arbitrary code execution through malicious packages, version drift, or unsafe shell invocation, especially in shared agent runtimes.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

If the skill actually installs packages via pip and uses subprocess to inspect or modify the Python environment, that exceeds the declared stock-analysis purpose and introduces supply-chain and execution-scope risk. Undeclared environment mutation can lead to arbitrary code execution through malicious packages, version drift, or unsafe shell invocation, especially in shared agent runtimes.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The README instructs users to interact in unrestricted natural language and broadly says to use this skill whenever users ask about A-share analysis, without clear trigger boundaries, exclusions, or disambiguation rules. In an agent environment, this can cause over-invocation, unintended routing, or execution on prompts that only mention stocks tangentially, increasing the chance of inappropriate tool use and data-fetching actions.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
70% confidence
Finding

Without declared permissions the skill's intent is opaque and cannot be validated.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The markdown instructs the skill to output results in Chinese only ('使用简洁的中文分点说明'). This is a natural-language locale constraint, and the file does not provide any user opt-in or alternative language option, which conflicts with the policy against forcing a specific language without user choice.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

This Python skill contains its primary docstring, field descriptions, and command-line help text in Chinese, which imposes a specific language on users without any opt-in or alternative locale handling. The policy explicitly calls out language or locale constraints as violations when the skill forces one language without user choice.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
83% confidence
Finding

The docstring states that if today's date is already present in the daily dataframe, the function returns the data unchanged. However, in analyze_single the dataframe is sorted before this helper runs, and _append_intraday_bar_if_needed appends a new row without re-sorting; downstream calculations then use df.iloc[-1], so an appended intraday row may become the effective 'latest' row even when the original dataframe already contained newer rows by order or mixed date types. This creates a contradiction between the documented 'no change if already included' behavior and what the effective analysis can do.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The argparse descriptions, help strings, and printed output are all hardcoded in Chinese, with no mechanism for the user to choose another language. This is a natural-language policy issue because the skill enforces a specific language in user interactions rather than offering a documented, justified locale constraint.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
83% confidence
Finding

The manifest describes this skill as fetching and analyzing A-share stock/ETF data for short-term trend analysis, signals, and scoring. In addition to that analysis workflow, the script persists the full fetched dataset to a local CSV file, which is a material behavior beyond pure fetch-and-analyze semantics.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The prompt instructs the agent to provide explicit trading signals and concrete actions such as buying dips, stopping losses, or reducing positions, but it does not require any risk disclosure or warning that the content is not financial advice. In a stock-analysis skill, users may directly act on these recommendations with real assets, increasing the chance of financial harm from overreliance on model output.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · scripts/setup_env.py (reported line 34)May include surrounding context.

python
"""使用 `python -m pip show` 判断包是否已安装。"""

    try:
        subprocess.check_output(
            [sys.executable, "-m", "pip", "show", package],
            stderr=subprocess.DEVNULL,
        )

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · scripts/setup_env.py (reported line 47)May include surrounding context.

python
"""通过当前解释器调用 `pip install` 安装指定包。"""

    print(f"[INFO] 安装依赖包: {package} ...")
    subprocess.check_call([sys.executable, "-m", "pip", "install", package])


def main() -> None:

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The module docstring is entirely prescriptive in Chinese and states what the module returns and forbids, but it does not indicate that Chinese output is optional or required for a region-specific compliance reason. Under the policy, forcing a specific language without user opt-in is a natural-language locale violation.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

The file states that Chinese explanations are shown by default and directs users to English separately. This establishes a default language behavior without indicating user choice or opt-in, which can violate language/locale preference policies.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
81% confidence
Finding

文件标题和开头说明全文以中文固定呈现,未见提供用户语言偏好选择、双语选项或对中文限定场景的说明。按规则,若技能内容强制特定语言且无用户选择或明确合理性说明,可构成自然语言层面的语言/locale 政策问题。

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
89% confidence
Finding

This code sends the user-provided stock identifier to an external HTTP endpoint at hq.sinajs.cn, but the command-line interface and user-facing help do not clearly disclose that an external service will be contacted. For code files, outbound network calls that transmit user data should have some visible disclosure unless the behavior is clearly communicated to the user.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
96% confidence
Finding

The get_today_quote docstring says the function returns 换手率 and 总市值, which implies those values are actually provided. In implementation, the code explicitly notes the real-time interface does not provide them and hardcodes both fields to NaN, so the documentation overstates what the function does.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
97% confidence
Finding

The instruction "请输出一段中文报告" mandates a specific language for all outputs. The policy requires avoiding language or locale restrictions unless the user is given a choice or the constraint is clearly documented as necessary for a region-specific tool.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
92% confidence
Finding

Natural-language policy violations apply to all file types, including code comments, docstrings, and printed strings. This file presents usage and operational messaging only in Chinese, which effectively forces a specific language for users without any opt-in or explanation of a locale-specific scope.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
76% confidence
Finding

The module docstring at L006-L018 strongly limits the module to raw market data collection only, excluding indicator/strategy-oriented behavior. While the code does not compute indicators, the CLI comment and output at L239-L241 characterize the extracted recent slice as '用于策略', which muddies that stated boundary and creates a mild intent/documentation inconsistency.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.