Back to skill

Security audit

akshare-stock-analyzer

Security checks for vulnerabilities and agentic risk

Overview

This skill is a coherent A-share technical-analysis helper, with ordinary dependency and local-output risks that users should handle carefully.

Install or run this skill in a dedicated virtual environment, review the unpinned akshare/pandas dependency install before running setup_env.py, and expect network calls to public market-data providers plus possible local CSV output when using fetch.py directly. Treat its buy/sell/hold outputs as technical indicators only, not 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:23
Finding

Unpinned Automatic Installation of Third-Party Dependencies

Content
View full analysis

Vulnerability Details

File Location: scripts/setup_env.py, lines 23–47
Vulnerability Type: Unverified and unpinned dependency installation
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 the current interpreter."""

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

Technical Analysis

The environment setup script installs akshare and pandas without version constraints, cryptographic hashes, a lockfile, or an explicitly trusted package index. Consequently, package resolution depends on the invoking environment's current pip configuration and the latest versions available from its configured repositories.

Python package installation can execute package build and installation logic. If a configured package repository, a selected release, or a transitive dependency is compromised, running this script could execute attacker-controlled code. The use of a subprocess argument list prevents shell metacharacter injection through the package argument; therefore, this is a dependency supply-chain issue rather than command injection.

Automatic installation is also unnecessary for the core analysis operation when dependencies are already available. Safer behavior would be to report missing packages and require a separate, explicit installation step based on a reviewed lockfile.

Attack Path

  1. An ...[truncated 1350 chars]
Remediation
View remediation

Remediation Suggestions

  1. Pin every direct and transitive dependency to reviewed versions using a lockfile.
  2. Generate and verify cryptographic hashes for all distributions, and install with pip's --require-hashes option.
  3. Use an explicitly configured, trusted package index rather than inheriting arbitrary pip index settings.
  4. Prefer prebuilt wheels from trusted sources and disable source builds where operationally practical.
  5. Separate dependency checking from installation. Report missing packages and require explicit user confirmation before changing the environment.
  6. Install dependencies in a dedicated virtual environment with ordinary user privileges, never as an administrator or root user.
  7. Add automated dependency vulnerability and provenance scanning to the release process.
  8. Document a reproducible installation command, for example:
bash
python -m pip install \
    --require-hashes \
    --only-binary=:all: \
    -r requirements.lock
Vulnerability Patterns
  • 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
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (15)

Tp4

High
Category
MCP Tool Poisoning
Confidence
90% confidence
Finding

If the associated skill actually installs packages via pip/subprocess despite being described only as a stock-analysis tool, that is a meaningful security-relevant behavior mismatch. Undeclared environment modification and package installation can change the runtime, pull untrusted code from package indexes, and expand impact far beyond the user’s expected data-analysis task.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

If the associated skill actually installs packages via pip/subprocess despite being described only as a stock-analysis tool, that is a meaningful security-relevant behavior mismatch. Undeclared environment modification and package installation can change the runtime, pull untrusted code from package indexes, and expand impact far beyond the user’s expected data-analysis task.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

If the associated skill actually installs packages via pip/subprocess despite being described only as a stock-analysis tool, that is a meaningful security-relevant behavior mismatch. Undeclared environment modification and package installation can change the runtime, pull untrusted code from package indexes, and expand impact far beyond the user’s expected data-analysis task.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

If the associated skill actually installs packages via pip/subprocess despite being described only as a stock-analysis tool, that is a meaningful security-relevant behavior mismatch. Undeclared environment modification and package installation can change the runtime, pull untrusted code from package indexes, and expand impact far beyond the user’s expected data-analysis task.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
88% confidence
Finding

The skill explicitly instructs the agent to execute local Python scripts and shell commands, but it does not declare any tool scope, permissions, or allowed-tools boundary. That creates an authorization gap: a host system may expose shell execution without the skill clearly constraining what commands are permitted, increasing the risk of unintended command execution paths or abuse if the skill or adjacent files are modified.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The activation section includes very general phrases such as “帮我看这只股票最近怎么样” and “分析某只 A 股/ETF 的近期走势,” which are common conversational requests rather than narrowly scoped invocation criteria. Although the file limits scope to A-shares/ETFs, it does not provide clearer boundaries or negative examples distinguishing when this skill should not be used for generic stock discussion versus this specific technical-analysis workflow.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This code file contains user-facing natural-language content such as the module docstring, help text, and printed labels exclusively in Chinese. Under the policy, forcing a specific language without user opt-in is a natural-language policy violation unless the locale constraint is clearly justified, which is not present here.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The command-line interface exposes help descriptions, examples, and printed output only in Chinese, which imposes a fixed language on users. The file does not provide a language selection mechanism or a documented justification for restricting usage to a Chinese locale.

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
88% confidence
Finding

The file’s natural-language instructions and interface are explicitly constrained to Chinese, including field names and usage text, but there is no indication that users can choose another language or that the skill is intentionally limited to a China-specific compliance or locale context. Under the policy, forcing a specific language without opt-in is a natural-language locale violation.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Low
Category
Not specified by scanner
Confidence
92% confidence
Finding

The manifest frames this skill as using built-in fetch.py and analyze.py to perform short-term A-share analysis. In this file, the CLI path additionally persists the full fetched dataset to local disk as a CSV, which goes beyond pure analysis behavior and introduces a data-export side effect not mentioned in the description.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

The module docstring and _get_realtime_df explicitly state that data comes from Sina via stock_zh_a_spot, but the failure message at L079 says the symbol was not found in an Eastmoney realtime list, and L084 says the percentage came from the Eastmoney API. This is a direct documentation/comment contradiction about the actual upstream data source, which can mislead users about provenance and semantics.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
92% confidence
Finding

This code file contains user-facing natural-language text entirely in Chinese in the module docstring and later CLI help/output strings. Under the policy rule, forcing a specific language without user opt-in can be a natural-language policy violation unless the locale restriction is explicit and justified, which is not stated here.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
84% confidence
Finding

The _to_tx_symbol docstring says it converts '代码或名称' into a prefixed Tencent symbol, implying input is only a raw code or company name. In reality, the function also directly accepts already-prefixed values like sh/sz/bj symbols and returns them unchanged, which contradicts the stated input contract in the documentation.

Content

No source excerpt is available for this finding.