Back to skill

Security audit

yanji-kline-data

Security checks for vulnerabilities and agentic risk

Overview

This is a small stock-quote/demo skill with disclosed network use, but its historical K-line and moving-average output should not be treated as reliable financial data.

Use this only as a teaching or lightweight quote helper. It contacts Sina Finance with the requested stock code, does not fetch authenticated historical K-line series, and may show estimated moving averages; do not rely on it for trading, compliance, or automated financial decisions.

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 (1)

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/fetch_kline.py:16
Finding

Unauthenticated HTTP Transport Allows Market Data Manipulation

Content
View full analysis

Vulnerability Details

File Location: scripts/fetch_kline.py, lines 16–20
Vulnerability Type: Unauthenticated plaintext transport
Risk Level: Medium

python
url = f"http://hq.sinajs.cn/list={code}"
try:
    req = urllib.request.Request(url, headers={"Referer": "https://finance.sina.com.cn"})
    with urllib.request.urlopen(req, timeout=5) as resp:
        data = resp.read().decode("gbk")

Technical Analysis

The script retrieves financial quote data through plaintext HTTP. Although the Referer header contains an HTTPS URL, it does not protect the actual request or authenticate the response. An attacker with a network position—such as a malicious access point, compromised proxy, ISP-level interceptor, or local network attacker—can read and modify the response in transit.

The script extracts the first quoted value from the response and converts its comma-separated fields directly into opening, closing, high, low, and volume values. It performs no cryptographic integrity verification and no meaningful validation of the response's origin or financial consistency. Consequently, a modified but syntactically valid response will be accepted as genuine market data.

Attack Path

  1. A user invokes the Skill to retrieve a stock quote.
  2. The script sends a request to http://hq.sinajs.cn/list={code} over an unencrypted connection.
  3. A network-positioned attacker intercepts the request or response.
  4. The attacker replaces the response with a syntactically valid payload containing forged price and volume fields.
  5. The regular expression and comma-separated parser accept the forged response.
  6. The script displays the manipulated quote and calculates moving-average estimates from the attacker-controlled closing price.
  7. A user or downstream agent may rely on the forged output for financial analysis.

Impact Assessment

Exploitation does not grant the attacker local code execution, filesys ...[truncated 310 chars]

Remediation
View remediation

Remediation Suggestions

  1. Replace the plaintext endpoint with an official HTTPS endpoint that provides valid certificate-based server authentication.
  2. Explicitly reject redirects that downgrade the connection from HTTPS to HTTP.
  3. Validate the response format before processing it, including the expected symbol, exact field count, numeric types, nonnegative volume, and coherent price ranges.
  4. Treat malformed, unexpected, or unauthenticated responses as failures rather than producing derived financial values.
  5. Catch specific network, decoding, and parsing exceptions instead of using a bare except, and return a clear error without exposing sensitive diagnostic details.
  6. If the provider does not support authenticated transport, migrate to a provider that does rather than silently accepting plaintext market data.
Vulnerability Patterns
  • 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
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (4)

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

The skill markets itself as providing K-line data, price trends, and configurable period/days support, but the description admits it only fetches a current quote snapshot and fabricates moving averages as demo estimates rather than deriving them from historical OHLC series. This is dangerous because downstream users or agents may treat the output as genuine historical market data and make financial, analytical, or compliance-sensitive decisions based on inaccurate or simulated results.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
92% confidence
Finding

The skill explicitly relies on network access to query 新浪财经 (hq.sinajs.cn) but does not declare any tool scope, permissions, or allowed-tools boundary. This creates a capability-transparency problem: a caller or platform may assume the skill is documentation-only or lower risk, while it actually performs outbound requests to an external service, which can affect privacy, compliance, and execution control.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The docstring claims K-line data collection, but the script explicitly produces estimated, non-historical moving averages rather than genuine K-line-derived indicators. Misrepresentation in tool metadata increases the likelihood that an agent will select and trust this skill for financial analysis when it cannot safely satisfy that purpose.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The skill advertises K-line, volume, and price-trend retrieval, but the implementation only fetches a single realtime quote and then synthesizes moving-average values from the current price. This is a security-relevant integrity issue because downstream agents or users may trust fabricated analytics as real market history, leading to incorrect financial decisions or unsafe automation based on false data.

Content

No source excerpt is available for this finding.