Back to skill

Security audit

Csi Stock Analyzer

Security checks for vulnerabilities and agentic risk

Overview

This stock-analysis skill needs review because it can turn simulated or hardcoded market data into concrete buy/sell-style recommendations.

Install only if you treat it as a demo or prototype. Do not rely on its ratings, scores, or buy/sell suggestions for financial decisions unless the publisher replaces the simulated market and financial data with verified sources, labels synthetic/demo output clearly, constrains report writes, and documents network and file permissions.

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)

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/analyze_stock.py:48
Finding
Path Traversal Through Unsanitized Default Report Filename<![CDATA[ ## Vulnerability Details **File Location**: `scripts/analyze_stock.py:48-55`; additional affected entry point: `core/stock_analyzer.py:365-368` **Vulnerability Type**: Path traversal and unintended file overwrite **Risk Level**: Medium ### Vulnerable Code `scripts/analyze_stock.py:48-55`: ```python if args.output: output_path = args.output else: from datetime import datetime output_path = f"{args.stock}_分析报告_{datetime.now().strftime('%Y%m%d_%H%M%S')}.txt" with open(output_path, 'w', encoding='utf-8') as f: f.write(report) ``` `core/stock_analyzer.py:365-368`: ```python output_file = f"{stock_query}_分析报告_{datetime.now().strftime('%Y%m%d')}.txt" with open(output_file, 'w', encoding='utf-8') as f: f.write(report) print(f"\n报告已保存到: {output_file}") ``` ### Technical Analysis Both command-line entry points incorporate an untrusted stock argument directly into the default output filename. The input is not restricted to a stock-code format, stripped of path separators, or resolved against a dedicated report directory. Consequently, values containing `../`, absolute-path components where supported, or platform-specific path separators can influence where the report is written. Python opens the resulting path in `w` mode, which creates a new file or truncates an existing file. The automatically appended timestamp and suffix constrain the exact filename an attacker can target, but they do not prevent directory traversal or unintended file creation outside the project directory. The explicit `--output` option is intentionally designed to accept a caller-selected path. The vulnerability concerns the supposedly safe default path derived from the positional stock argument. ### Attack Path 1. An attacker or untrusted caller supplies a stock value containing traversal components, such as `../../target`. 2. The application performs stock analysis using that string. 3. The same unvalidated string is interpolated into the default report fi ...[truncated 1002 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Validate stock identifiers against a strict allowlist where possible, such as letters, digits, dots, underscores, and hyphens. 2. Convert display names to safe filenames by removing path separators, `..`, control characters, and platform-specific reserved characters. 3. Write default reports beneath a dedicated directory such as `reports/`. 4. Resolve both the report directory and candidate path to canonical absolute paths, then verify that the candidate remains inside the report directory. 5. Create the destination directory with restrictive permissions. 6. Consider exclusive file creation with mode `x` or explicit overwrite confirmation when overwriting is unnecessary. 7. Apply the same helper function to both affected entry points. Example: ```python from pathlib import Path import re REPORT_DIR = (Path(__file__).resolve().parent.parent / "reports").resolve() REPORT_DIR.mkdir(mode=0o700, parents=True, exist_ok=True) safe_stock = re.sub(r"[^A-Za-z0-9._-]", "_", args.stock) safe_stock = safe_stock.replace("..", "_").strip("._") if not safe_stock: raise ValueError("Invalid stock identifier") candidate = ( REPORT_DIR / f"{safe_stock}_analysis_{datetime.now().strftime('%Y%m%d_%H%M%S')}.txt" ).resolve() if REPORT_DIR not in candidate.parents: raise ValueError("Output path escapes the report directory") with candidate.open("x", encoding="utf-8") as report_file: report_file.write(report) ``` ]]>

T08 · Insecure Dependencies

Note
Location
requirements.txt:4
Finding
Unpinned and Unhashed Third-Party Dependencies<![CDATA[ ## Vulnerability Details **File Location**: `requirements.txt:4-25`; installation instruction at `README.md:37-40` **Vulnerability Type**: Non-reproducible dependency installation and supply-chain exposure **Risk Level**: Low ### Vulnerable Code `requirements.txt:4-25`: ```text pandas>=2.0.0 numpy>=1.24.0 # Network requests requests>=2.28.0 # Data parsing beautifulsoup4>=4.11.0 lxml>=4.9.0 # Optional data sources # tushare>=1.2.89 # akshare>=1.9.0 # baostock>=0.8.8 # Data visualization (optional) # matplotlib>=3.7.0 # seaborn>=0.12.0 # Utility libraries pyyaml>=6.0 python-dotenv>=1.0.0 ``` `README.md:37-40`: ```bash pip install -r requirements.txt ``` ### Technical Analysis Every active dependency is specified with an open-ended minimum version. No lock file, upper bound, artifact hash, or reviewed dependency snapshot is supplied. As a result, the documented installation command can resolve to package releases that did not exist when the Skill was audited. This weakens reproducibility and permits future upstream changes to alter the installed code without any corresponding change to this repository. The package names reviewed are conventional, and the project does not configure an untrusted package index or contain evidence that any listed dependency is malicious. The finding is therefore a hardening and supply-chain risk rather than evidence of an active dependency attack. ### Attack Path 1. A user follows the documented installation command. 2. `pip` queries its configured package index and resolves the newest versions satisfying the open-ended minimum constraints. 3. A future compromised, malicious, or unexpectedly incompatible release satisfies those constraints. 4. The release is downloaded and installed without repository-level hash verification. 5. The dependency's code executes during installation, import, or normal Skill operation with the privileges of the user running the installation or application. ### Impact Assessment T ...[truncated 527 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Pin every direct dependency to a reviewed version rather than using only minimum constraints. 2. Generate and commit a lock file containing resolved transitive dependencies. 3. Use package hashes, such as a requirements file generated for `pip install --require-hashes`. 4. Install only from trusted package indexes and explicitly configure the permitted index where appropriate. 5. Run dependency vulnerability and license scanning in continuous integration. 6. Update packages through a controlled process that reviews changelogs, security advisories, and lock-file differences. 7. Perform installation inside an isolated virtual environment and avoid installing as an administrator or root user. 8. Separate optional dependencies into dedicated extras or requirements files to minimize installed attack surface. A hardened installation workflow could use: ```bash python -m venv .venv . .venv/bin/activate python -m pip install --require-hashes -r requirements.lock ``` ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • 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 (42)

Tp4

High
Category
MCP Tool Poisoning
Confidence
93% confidence
Finding
The skill claims broad stock-analysis functions, including real-time quotes, technical indicators, CSI 2000 batch analysis, and sentiment analysis, but the finding states these are absent or only partially present, while external network access to third-party endpoints is used without declaration. This combination is risky because it couples deceptive capability claims with undisclosed outbound communication in a domain where users may act on the results financially.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
The skill claims broad stock-analysis functions, including real-time quotes, technical indicators, CSI 2000 batch analysis, and sentiment analysis, but the finding states these are absent or only partially present, while external network access to third-party endpoints is used without declaration. This combination is risky because it couples deceptive capability claims with undisclosed outbound communication in a domain where users may act on the results financially.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding
The skill claims broad stock-analysis functions, including real-time quotes, technical indicators, CSI 2000 batch analysis, and sentiment analysis, but the finding states these are absent or only partially present, while external network access to third-party endpoints is used without declaration. This combination is risky because it couples deceptive capability claims with undisclosed outbound communication in a domain where users may act on the results financially.

Intent-Code Divergence

High
Confidence
99% confidence
Finding
The function is documented and named as if it retrieves real historical stock market data, but it actually fabricates synthetic random OHLCV values. In an investment-analysis skill, this can directly mislead downstream indicator calculations and trading decisions while presenting false data as authentic market information.

Intent-Code Divergence

High
Confidence
99% confidence
Finding
The function claims to return company financial statements but instead returns hardcoded placeholder values, creating a false impression of factual financial analysis. In a stock analysis tool, fabricated revenue, profit, and ratio data can materially distort recommendations and cause users to act on nonexistent fundamentals.

Natural-Language Policy Violations

Medium
Confidence
92% confidence
Finding
The entire skill description, examples, and operational guidance are written exclusively in Chinese, and there is no indication that users may choose another language or that the skill is intentionally limited to a Chinese-speaking or China-only compliance context. Under the policy, a language constraint without user opt-in or explicit justification is a natural-language policy violation.

Description-Behavior Mismatch

Medium
Confidence
97% confidence
Finding
The manifest describes the skill as supporting real-time market data retrieval, technical indicator analysis, caching, and news sentiment analysis. This README adds a substantial separate capability area—financial statement analysis including ROE, debt service, cash flow, R&D spending, PEG, and free cash flow—which is not reflected in the manifest description and materially broadens the skill’s stated purpose.

Description-Behavior Mismatch

Medium
Confidence
88% confidence
Finding
The manifest focuses on obtaining quotes, technical signals, batch analysis, sentiment monitoring, and caching. The README’s sample output goes further by claiming concrete investment ratings and action recommendations such as '建议买入,逢低加仓', which changes the skill from an analysis utility into an advisory/recommendation system.

Context-Inappropriate Capability

Medium
Confidence
95% confidence
Finding
The stated purpose is stock analysis, sentiment monitoring, technical indicators, and caching. Mentioning extension to real brokerage/trading interfaces and automated trading introduces a materially different capability with real-world action-taking consequences that is not justified by the declared scope of an analysis skill.

Lp3

Medium
Category
MCP Least Privilege
Confidence
83% confidence
Finding
The skill advertises capabilities that imply network access, local file writes, and possible environment use, but it does not declare any tool scope or permissions. This is dangerous because users and the host platform cannot accurately constrain or review what the skill may access, increasing the risk of unintended data exposure or unauthorized external communication.

Natural-Language Policy Violations

Medium
Confidence
94% confidence
Finding
The manifest description and main documentation are written entirely in Chinese and present the skill as a general stock analysis tool, but they do not offer any language or locale choice. Under the policy, forcing a specific language without user opt-in is a natural-language policy violation unless the locale constraint is clearly documented and justified.

External Transmission

Medium
Category
Data Exfiltration
Content
return []
            
        try:
            url = "https://api.tavily.com/search"
            headers = {"Content-Type": "application/json"}
            payload = {
                "api_key": self.tavily_api_key,
Confidence
60% confidence
Finding
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

External Transmission

Medium
Category
Data Exfiltration
Content
"max_results": 20
            }
            
            response = requests.post(url, json=payload, headers=headers, timeout=30)
            if response.status_code == 200:
                data = response.json()
                return data.get('results', [])
Confidence
80% confidence
Finding
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Natural-Language Policy Violations

Medium
Confidence
95% confidence
Finding
This Python file contains natural-language descriptions entirely in Chinese, beginning with the module docstring and continuing through generated summary strings. Because the skill does not provide any user opt-in, language selection, or justification that it is intended only for a Chinese-language context, it violates the language/locale policy criterion.

Description-Behavior Mismatch

Medium
Confidence
95% confidence
Finding
The manifest describes a stock analysis tool centered on real-time行情、技术指标分析(MACD/KDJ/RSI/EMA)、缓存和新闻舆情, but this module performs extensive fundamental financial-statement analysis such as ROE、资产负债率、现金流、研发支出、PEG and management/strategy scoring. That is a meaningful capability expansion beyond the declared behavior, not just an implementation detail of technical analysis.

Natural-Language Policy Violations

Medium
Confidence
96% confidence
Finding
This code hard-codes Chinese natural-language strings throughout the module, including the main description, generated report text, CLI usage, and disclaimer, without offering any language selection or opt-in. That creates a locale policy issue because the skill effectively mandates a specific language for all users rather than allowing a choice or documenting a justified region-specific restriction.

Natural-Language Policy Violations

Medium
Confidence
90% confidence
Finding
This code's natural-language description specifies the module behavior entirely in Chinese, and the generated user-facing report is also hard-coded in Chinese throughout the file. Under the policy rule for language/locale, forcing a specific language without user opt-in is a violation unless a justified region-specific constraint is documented, which is not present here.

Natural-Language Policy Violations

Medium
Confidence
96% confidence
Finding
The report content, labels, recommendations, and disclaimer are all emitted as Chinese strings, with no mechanism for the user to choose another language. This constitutes a language/locale policy issue because the skill imposes a specific language on end users without opt-in or documented justification.

Natural-Language Policy Violations

Medium
Confidence
95% confidence
Finding
This Python file contains multiple Chinese docstrings, comments, error messages, and CLI usage text, which effectively forces a specific language for users and maintainers. Under the policy, language constraints should either offer user choice or be clearly documented as region- or locale-specific.

Natural-Language Policy Violations

Medium
Confidence
95% confidence
Finding
This code presents its description, argument help text, and user-facing messages entirely in Chinese, which imposes a specific language on users without any opt-in or alternative locale path. Under the policy, forcing a language without user choice is a natural-language policy violation unless clearly justified as region-specific.

Natural-Language Policy Violations

Low
Confidence
82% confidence
Finding
The file’s human-facing comments and labels are entirely in Chinese, which indicates a fixed language/locale presentation. Under the stated policy, forcing a specific language without user opt-in can be a natural-language policy violation when no alternative or opt-in is documented.

Natural-Language Policy Violations

Low
Confidence
82% confidence
Finding
This code file contains natural-language documentation entirely in Chinese ('数据获取模块 - 从公开数据源获取股票数据、新闻、财报等信息') with no indication that language choice is optional. Under the policy rule for language/locale, forcing a specific language without user opt-in can be a violation when no justification or alternative is provided.

Intent-Code Divergence

Low
Confidence
88% confidence
Finding
The comment and returned fields suggest dynamic adjustment based on news or analyst forecast data (e.g. '可根据新闻调整', '可接入分析师预测数据'), but the code always returns fixed values like '正面' and fixed growth forecast strings. This documentation signals a capability or behavior that the function does not actually implement.

Natural-Language Policy Violations

Low
Confidence
91% confidence
Finding
This Python file contains user-facing natural-language descriptions in Chinese, and the module appears oriented around Chinese-language output without any indication that users can opt into another language. The policy requires flagging language or locale constraints when a specific language is forced without user choice or explicit justification.

Description-Behavior Mismatch

Low
Confidence
88% confidence
Finding
The manifest describes stock analysis, technical indicators, news sentiment, and data caching, but does not mention generating and persisting report files to the local filesystem. Writing a dated report file is additional behavior beyond the described analysis-focused scope, even though it is not highly risky.

Static analysis

No suspicious patterns detected.