Back to skill

Security audit

Stock Fundamental Analysis

Security checks for vulnerabilities and agentic risk

Overview

Review recommended: the skill is not clearly malicious, but it loads unreviewed local code outside its package and overpromises stock-analysis capabilities it does not ship.

Install only if you trust the local toc-trading/src dependency that this skill will load, understand that the tool is Chinese-language and incomplete versus its description, and are comfortable providing a stock-data API key. Treat its investment output as informational only, and prefer a version that packages or pins dependencies and writes outputs to a safe, user-controlled location.

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

Error
Location
tools/financial_fetcher.py:11
Finding
Untrusted External Module Execution Through Runtime Path Injection## Vulnerability Details **File Location**: `tools/financial_fetcher.py`, lines 11–17 **Vulnerability Type**: Untrusted dependency loading and arbitrary Python code execution **Risk Level**: High ```python _base = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) _trading_src = os.path.join(_base, 'toc-trading', 'src') if _trading_src not in sys.path: sys.path.insert(0, _trading_src) from stock_data_adapter import StockDataAdapter ``` ### Technical Analysis The script derives a location outside the Skill package, prepends that location to `sys.path`, and imports `stock_data_adapter` without verifying its origin, ownership, permissions, or integrity. Given the supplied project location, the derived import directory resolves to `/tmp/toc-trading/src`. Because `/tmp` is normally a shared location, another local user or process may be able to create or replace the expected module. Placing this directory at index zero in `sys.path` gives it precedence over other module locations. Python executes module-level code immediately during an import. Consequently, a malicious `stock_data_adapter.py` in the derived directory can execute arbitrary Python code before `StockDataAdapter` is instantiated. No cryptographic digest, trusted package installation, canonical-path validation, or restrictive permission check protects this import. ### Attack Path 1. An attacker with local write access creates `/tmp/toc-trading/src` if it does not already exist. 2. The attacker places a malicious `stock_data_adapter.py` in that directory. 3. The Agent invokes `tools/financial_fetcher.py` as part of a stock-analysis request. 4. The script inserts `/tmp/toc-trading/src` at the beginning of `sys.path`. 5. Python imports and executes the attacker-controlled module. 6. The malicious module runs with the same operating-system identity and privileges as the Agent process. ### Impact Assessment Successful exploitation provides arbitrary Py ...[truncated 543 chars]
Remediation
## Remediation Suggestions - Package `stock_data_adapter` inside the reviewed Skill or install it as a pinned, trusted dependency through a controlled package-management process. - Do not prepend shared or externally writable directories to `sys.path`. - Use a normal package import from an isolated virtual environment with exact dependency versions and verified hashes. - If external module loading is unavoidable: - Resolve the module directory to a canonical path and require it to be within an explicitly trusted root. - Reject symbolic links and unexpected path components. - Verify that the directory and module are owned by a trusted account and are not writable by untrusted users. - Verify the module against a pinned cryptographic digest or signed manifest before importing it. - Run the Skill under a dedicated least-privileged identity and expose only the environment variables and filesystem locations required for the task.

T09 · Insecure Skill Coding Practices

Warning
Location
tools/financial_fetcher.py:88
Finding
Predictable Shared Temporary Output Permits Symlink-Based File Overwrite## Vulnerability Details **File Location**: `tools/financial_fetcher.py`, lines 88–94 **Vulnerability Type**: Unsafe temporary-file handling **Risk Level**: Medium ```python parser.add_argument('--output', default='/tmp/financial.json', help='输出文件') args = parser.parse_args() result = fetch_financial(args.symbol) with open(args.output, 'w') as f: json.dump(result, f, ensure_ascii=False, indent=2) ``` ### Technical Analysis The default output path is the predictable shared filename `/tmp/financial.json`. The file is opened in write mode without exclusive creation, symbolic-link protection, ownership checks, file-type checks, or atomic replacement. On platforms where `/tmp` is shared, an attacker may create `/tmp/financial.json` as a symbolic link before the script runs. The standard `open(..., 'w')` operation follows symbolic links and truncates the resolved target. Concurrent executions can also overwrite or partially replace each other's output because every default invocation uses the same path. The user-controlled `--output` option broadens the set of writable destinations, although invoking the tool with an arbitrary output path already requires control over its command-line arguments. The directly exploitable default-path condition is the predictable shared temporary filename. ### Attack Path 1. A local attacker identifies a file that the Agent process can write. 2. The attacker creates `/tmp/financial.json` as a symbolic link to that target. 3. The Agent invokes `financial_fetcher.py` without specifying `--output`. 4. The script opens `/tmp/financial.json` in write mode. 5. The operating system follows the symbolic link, and the target is truncated and replaced with JSON output. ### Impact Assessment An attacker may overwrite or corrupt any file writable by the Agent process. Depending on the Agent's privileges and the chosen target, this could cause data loss, corrupt application configuration, alter subsequent workflow inputs, or disrupt ...[truncated 272 chars]
Remediation
## Remediation Suggestions - Replace the fixed `/tmp/financial.json` default with `tempfile.NamedTemporaryFile`, `tempfile.mkstemp`, or a private temporary directory created with restrictive permissions. - Create new files atomically and exclusively. On supported systems, use flags equivalent to `O_CREAT | O_EXCL | O_NOFOLLOW`. - Validate that an explicitly supplied output path resolves to an approved directory and does not reference a symbolic link or non-regular file. - Write to a securely created temporary file in the destination directory, flush and synchronize it as appropriate, and atomically replace the final output. - Apply restrictive permissions, such as owner-only read and write access, when the output may contain sensitive financial or account-related information. - Use unique output filenames for concurrent executions to prevent accidental collision and corruption.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • 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 (9)

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding
声明描述的是一个较完整的投研分析能力,涉及多维度基本面研究与报告生成;但实际代码只是一个“财务/行情数据获取器”,主要调用数据适配器获取实时行情与K线数据,计算少量衍生指标(52周高低点、1年涨跌幅)并给出粗略PE分档。它没有看到财务报表解析、盈利能力/偿债能力/现金流等健康度分析、成长性分析、行业比较、报告组织生成等核心能力。因此该代码与声明的主要用途存在明显实质性不匹配。

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding
声明描述的是一个覆盖基本面研究多个模块的完整投研分析技能,而代码片段只实现了估值子模块。虽然其中确实包含估值分析,且少量使用历史分位和行业平均数据,但并未看到财务健康度、全面成长性分析、财报文本解读、行业深度对标或完整投研报告生成逻辑。因此描述显著宽于实际代码能力,属于能力范围不匹配。

Lp3

Medium
Category
MCP Least Privilege
Confidence
80% confidence
Finding
The skill invokes multiple local Python tools but does not declare an explicit tool scope or permissions boundary, while static analysis indicates file-write capability may exist. Undeclared capabilities increase the chance of over-privileged execution, unexpected side effects, or abuse if any downstream tool writes files or handles untrusted input unsafely.

Missing User Warnings

Medium
Confidence
92% confidence
Finding
The skill depends on an external stock data API and an API credential, but the user-facing documentation does not clearly disclose that network calls will be made using privileged credentials. This transparency gap can undermine informed consent and makes it harder to assess privacy, compliance, and data-handling risks, especially if user-supplied symbols or queries are sent to third-party services.

Vague Triggers

Medium
Confidence
86% confidence
Finding
Overly broad trigger phrases can cause the skill to activate unexpectedly in ordinary conversation, which may lead to unintended tool execution and external data retrieval. In this skill's context, accidental invocation is somewhat mitigated by the domain-specific nature of stock analysis, but it still increases the attack surface and operational unpredictability.

Natural-Language Policy Violations

Medium
Confidence
96% confidence
Finding
The file’s natural-language descriptions and user-facing strings are entirely in Chinese, including the module docstring and command-line interface text. This imposes a specific language on users without any visible opt-in, fallback, or explanation that the tool is region-specific, which matches the language/locale policy violation criteria.

Description-Behavior Mismatch

Medium
Confidence
88% confidence
Finding
The manifest promises deep fundamental analysis including financial health assessment, valuation analysis, growth analysis, industry benchmarking, and earnings-report interpretation. In this file, the implemented behavior is limited to retrieving realtime quote data and daily K-line history, then computing simple fields like 52-week high/low, 1-year change, and a coarse PE comment; it does not perform the broader analysis the skill claims.

Natural-Language Policy Violations

Medium
Confidence
95% confidence
Finding
This code file contains user-facing natural-language descriptions in Chinese, including the module docstring and later result strings, but there is no indication that the skill is region-specific or that users can opt into this language. Under the stated policy, forcing a specific language without user choice is a natural-language policy violation.

Natural-Language Policy Violations

Medium
Confidence
97% confidence
Finding
The final verdict messages, method names, and disclaimer are emitted in Chinese only, which enforces a specific language in user-visible output. The file does not provide an alternative locale, a language-selection mechanism, or a justified region-specific scope.

Static analysis

No suspicious patterns detected.