Back to skill

Security audit

Stock Monitor Skill 0.1.0

Security checks for vulnerabilities and agentic risk

Overview

This is a disclosed stock-monitoring skill that runs a user-started background watcher and contacts market-data providers, with some quality and hardening issues but no hidden or destructive behavior found.

Before installing, be aware that this skill is aimed at Chinese-speaking China-market workflows, runs as a local background process when started, logs under ~/.stock_monitor, and sends your configured watchlist symbols to external market-data/news services. Treat its alerts and advice as informational, and prefer hardening the HTTP endpoint and PID validation before relying on it heavily.

Vulnerability Patterns
  • 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
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (2)

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/analyser.py:123
Finding
Unauthenticated HTTP Transport Allows Market-Data Response Manipulation<![CDATA[ ## Vulnerability Details **File Location**: `scripts/analyser.py`, lines 123-137 **Vulnerability Type**: Cleartext HTTP request without transport authenticity **Risk Level**: Medium ### Vulnerable Code ```python url = f"http://datacenter-web.eastmoney.com/api/data/v1/get" params = { "sortColumns": "NET_BUY_AMT", "sortTypes": "-1", "pageSize": "50", "pageNumber": "1", "reportName": "RPT_DMSK_TS", "columns": "ALL", "filter": f"(TRADE_DATE='{date}')" } try: resp = self.session.get(url, params=params, timeout=10) data = resp.json() return data.get("result", {}).get("data", []) ``` ### Technical Analysis The `fetch_dragon_tiger()` functionality retrieves financial data through unauthenticated cleartext HTTP. HTTP does not provide server authentication, confidentiality, or response integrity. An attacker capable of observing or modifying the network connection can intercept the request and replace the response with attacker-controlled JSON. The implementation accepts the response without checking the HTTP status, content type, response schema, or authenticity. This method is not invoked by the current main monitoring loop, which limits immediate exposure. However, it is a public part of the analysis engine and becomes exploitable whenever a caller uses `fetch_dragon_tiger()`. ### Attack Path 1. A user or another component invokes `StockAnalyser.fetch_dragon_tiger()`. 2. The application sends a cleartext HTTP request to the Eastmoney endpoint. 3. An attacker controlling a network gateway, proxy, wireless access point, or other on-path infrastructure intercepts the request. 4. The attacker returns fabricated JSON matching the expected high-level structure. 5. `resp.json()` parses the malicious response. 6. The application accepts and returns the forged financial records without detecting the manipulation. ### Impact Assessment An attacker can manipulate the Dragon Tiger market data returned by this method, inc ...[truncated 343 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Replace the HTTP endpoint with an HTTPS endpoint supplied by the provider: ```python url = "https://datacenter-web.eastmoney.com/api/data/v1/get" ``` 2. Prevent HTTPS-to-HTTP redirect downgrades, or explicitly verify that the final response URL uses HTTPS. 3. Check the response status before parsing: ```python resp.raise_for_status() ``` 4. Validate that the response content type is JSON. 5. Validate the complete response schema and expected field types before returning records. 6. Treat malformed or unexpected data as an error rather than silently accepting partial structures. 7. If the provider does not support HTTPS, remove or disable the functionality instead of transmitting requests over cleartext HTTP. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/control.sh:24
Finding
Stale or Manipulated PID File Can Terminate an Unrelated User Process<![CDATA[ ## Vulnerability Details **File Location**: `scripts/control.sh`, lines 24-30 **Vulnerability Type**: Unsafe PID-file trust and missing process identity validation **Risk Level**: Medium ### Vulnerable Code ```bash if [ -f "$PID_FILE" ]; then PID=$(cat "$PID_FILE") if kill -0 "$PID" 2>/dev/null; then echo "🛑 停止监控进程 (PID: $PID)..." kill "$PID" rm "$PID_FILE" echo "✅ 已停止" ``` ### Technical Analysis The stop operation trusts the numeric value stored in `~/.stock_monitor/monitor.pid`. The `kill -0` check only establishes that a process with that PID exists and is signalable by the current user. It does not establish that the process is the stock monitor daemon. If the daemon terminates unexpectedly, the PID file is not guaranteed to be removed. The operating system may later assign the same PID to another process. Running `control.sh stop` would then send `SIGTERM` to that unrelated process. A same-user actor able to modify the PID file can also replace its contents with the PID of another process owned by that user. Input is not validated as a strictly positive numeric PID, and the process executable or command line is not checked before signaling it. ### Attack Path #### Stale PID exploitation 1. The monitor starts and writes its PID to `~/.stock_monitor/monitor.pid`. 2. The daemon exits unexpectedly without deleting the PID file. 3. The operating system reuses the recorded PID for an unrelated process. 4. The user later runs `./control.sh stop`. 5. `kill -0` succeeds because the unrelated process exists. 6. The script sends `SIGTERM` to the unrelated process. #### PID-file manipulation 1. A same-user process or actor with write access to the PID file replaces its contents with another same-user process ID. 2. The user invokes the stop command. 3. The script accepts the substituted PID without checking process identity. 4. The selected process receives `SIGTERM`. ### Impact Assessment The issue can te ...[truncated 409 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Validate that the PID consists only of digits and is greater than one before using it: ```bash [[ "$PID" =~ ^[0-9]+$ ]] && [ "$PID" -gt 1 ] || { echo "Invalid PID file" exit 1 } ``` 2. Verify process identity before sending a signal. On Linux, inspect `/proc/$PID/cmdline` or `/proc/$PID/exe` and confirm that it corresponds to the expected `monitor_daemon.py` process. 3. Record additional process identity information, such as the process start time, and verify it to protect against PID reuse. 4. Install an exit trap in the daemon or launcher to remove the PID file during normal shutdown. 5. Use `flock` or another operating-system locking mechanism instead of relying solely on a PID file. 6. Create the state directory with restrictive permissions: ```bash install -d -m 700 "$LOG_DIR" ``` 7. Write the PID file atomically and ensure that it cannot be replaced through a symbolic-link attack. 8. Refuse to signal the process if any identity check fails, and report that the PID file is stale instead. ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Rogue AgentSelf-Modification, Session Persistence
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (18)

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding
If the shipped code is primarily developer QA or validation infrastructure while the skill is presented as end-user monitoring functionality, reviewers and users may misunderstand what actually runs. This is dangerous because test harnesses often have broader access, weaker hardening, or behavior inconsistent with production claims, which can expand attack surface and reduce transparency.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding
If the shipped code is primarily developer QA or validation infrastructure while the skill is presented as end-user monitoring functionality, reviewers and users may misunderstand what actually runs. This is dangerous because test harnesses often have broader access, weaker hardening, or behavior inconsistent with production claims, which can expand attack surface and reduce transparency.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
If the shipped code is primarily developer QA or validation infrastructure while the skill is presented as end-user monitoring functionality, reviewers and users may misunderstand what actually runs. This is dangerous because test harnesses often have broader access, weaker hardening, or behavior inconsistent with production claims, which can expand attack surface and reduce transparency.

Natural-Language Policy Violations

Medium
Confidence
94% confidence
Finding
The README presents the skill name's description, feature list, and setup note entirely in Chinese, which effectively forces a specific language for users. The policy allows locale constraints only when they are optional or clearly documented and justified, which is not present here.

Lp3

Medium
Category
MCP Least Privilege
Confidence
82% confidence
Finding
The skill documentation declares no explicit tool scope or permissions, while the accompanying analysis indicates network-capable behavior exists elsewhere in the skill. Missing scope declarations are dangerous because they hide the true execution and data-access surface from reviewers and users, making unexpected external requests harder to audit and constrain.

Description-Behavior Mismatch

Medium
Confidence
92% confidence
Finding
The manifest describes a stock monitoring and alerting system centered on seven specific warning rules such as cost percentage, moving-average crosses, RSI, volume anomalies, gaps, and trailing take-profit. This file's module description and implemented methods instead expand into broader market-intelligence functions including news scraping, sentiment analysis, capital-flow retrieval,龙虎榜 data, and gold-price correlation analysis, which are materially beyond the described alert-rule scope.

Natural-Language Policy Violations

Medium
Confidence
91% confidence
Finding
The file-level description and class docstring are entirely in Chinese and present the skill as a general-purpose stock analysis engine, with no indication that language is configurable or limited to a China-specific deployment context. Under the policy, forcing a specific language without user opt-in is a natural-language locale violation.

Session Persistence

Medium
Category
Rogue Agent
Content
echo "🚀 启动 Stock Monitor 后台进程..."
        mkdir -p "$LOG_DIR"
        nohup python3 "$SCRIPT_DIR/monitor_daemon.py" > "$LOG_DIR/monitor.log" 2>&1 &
        echo $! > "$PID_FILE"
        echo "✅ 已启动 (PID: $!)"
        echo "📋 日志: $LOG_DIR/monitor.log"
Confidence
65% confidence
Finding
Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Natural-Language Policy Violations

Medium
Confidence
96% confidence
Finding
The file's natural-language description and user-facing alert messages are entirely in Chinese, and locale-specific conventions are embedded in comments and output formatting. There is no indication that the language is configurable or that the skill is intentionally restricted to a Chinese-speaking or China-specific context with explicit user opt-in.

Natural-Language Policy Violations

Medium
Confidence
92% confidence
Finding
The module docstring uses Chinese for core operational descriptions, and the file continues to use Chinese user-facing strings in logs. Under the policy rule, forcing a specific language without opt-in or justification is a natural-language policy violation.

Natural-Language Policy Violations

Medium
Confidence
95% confidence
Finding
The module docstring is entirely in Chinese and presents the test suite description in a single fixed language. This is a natural-language locale policy concern because the file does not offer an opt-in language choice or explain why Chinese is required for a region-specific audience.

Natural-Language Policy Violations

Low
Confidence
92% confidence
Finding
The description states the skill '符合中国投资者习惯(红涨绿跌)', which bakes in a China-specific market display convention by default. The file does not indicate that users can choose their preferred color/locale convention or that this behavior is limited to a region-specific deployment.

Natural-Language Policy Violations

Low
Confidence
95% confidence
Finding
These lines explicitly define '红色 = 上涨 / 盈利' and '绿色 = 下跌 / 亏损' as the skill's convention. Because color semantics vary by market and locale, hardcoding this behavior without opt-in or a documented locale scope creates a language/locale policy issue.

Intent-Code Divergence

Low
Confidence
95% confidence
Finding
The function is documented as analyzing the relationship between gold price and portfolio stocks, implying the input gold_price affects the analysis. In reality, the code never uses gold_price and simply looks up stock codes in a fixed correlation_map, so the documented intent contradicts the actual behavior.

Natural-Language Policy Violations

Low
Confidence
96% confidence
Finding
The script's comments, status messages, and usage output are presented entirely in Chinese, including operational prompts shown during start, stop, status, and help flows. Under the stated policy, forcing a specific language without user opt-in is a natural-language policy violation unless the locale restriction is clearly documented and justified.

Missing User Warnings

Low
Confidence
88% confidence
Finding
The skill sends the user-configured watchlist symbols and market interests to third-party data providers without any user-facing notice or consent flow. While the transmitted data is not highly sensitive by itself, investment interests can still reveal private financial preferences and behavior patterns, especially if correlated over time by external services.

Description-Behavior Mismatch

Low
Confidence
91% confidence
Finding
The manifest describes a stock monitoring and alerting system centered on seven warning-rule types. This function adds a separate news retrieval capability, which is not referenced in the manifest description and is not necessary to implement the stated alert rules.

Context-Inappropriate Capability

Low
Confidence
88% confidence
Finding
The skill's stated purpose is monitoring stocks and generating technical/price-based alerts. Accessing a company survey/news endpoint is a separate informational capability and is not obviously required for the declared alerting behavior, especially since the returned value is only a placeholder string.

Static analysis

No suspicious patterns detected.