Back to skill

Security audit

A股(机构主力)股指期货持仓统计-中金所

Security checks for vulnerabilities and agentic risk

Overview

This is a coherent CFFEX public-data reporting skill, but its downloaded financial data is not integrity-protected because it uses HTTP and disables TLS verification.

Install only if you want a Chinese-language CFFEX position-report skill that can fetch public exchange XML and create local cache/report files. Treat the generated report as unauthenticated market data, not trading advice; use explicit invocation, verify important figures independently, and prefer a version that uses HTTPS with normal certificate validation if available.

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
if_netchange.py:48
Finding

Unauthenticated Market Data Retrieval and Disabled TLS Verification

Content
View full analysis

Vulnerability Details

File Location: if_netchange.py:48-60
Vulnerability Type: Insecure network transport and certificate validation
Risk Level: Medium

Complete Code Snippet

python
CTX = ssl.create_default_context(); CTX.check_hostname = False; CTX.verify_mode = ssl.CERT_NONE


# ---------- CFFEX download ----------
def cffex_url(date8, product):
    return f"http://www.cffex.com.cn/sj/ccpm/{date8[:6]}/{date8[6:]}/{product}.xml?id={random.randint(1,99)}"


def download(product, date8, save_path):
    try:
        req = urllib.request.Request(cffex_url(date8, product), headers={
            "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)",
            "Referer": "http://www.cffex.com.cn/cn/ccpm.html"})
        data = urllib.request.urlopen(req, timeout=30, context=CTX).read()
        if b'<positionRank' not in data[:600]:
            raise ValueError("Returned content is not position XML (possibly 404/empty)")

The same insecure context and plaintext endpoint are also used by the availability check at if_netchange.py:75-80.

Technical Analysis

Position data is retrieved over plaintext HTTP, which provides neither server authentication nor transport integrity. The code also creates an SSL context that explicitly disables hostname checking and certificate verification. Although the current URLs use HTTP, retaining this context means changing the endpoint to HTTPS without removing these settings would still leave the connection vulnerable to interception.

Response validation only checks whether the first 600 bytes contain the marker <positionRank. This verifies neither the origin nor the integrity of the XML. An attacker can therefore create a forged document that passes the check. The forged response is written into the local cache and later parsed as authoritative market data.

The downloaded XML is treated as data rather than executable code, so the identified path does ...[truncated 1313 chars]

Remediation
View remediation

Remediation Suggestions

  1. Replace all CFFEX URLs with authenticated HTTPS endpoints, including both data URLs and the Referer value:

    python
    def cffex_url(date8, product):
        return (
            f"https://www.cffex.com.cn/sj/ccpm/"
            f"{date8[:6]}/{date8[6:]}/{product}.xml"
            f"?id={random.randint(1, 99)}"
        )
    
  2. Remove the custom context that disables verification. Use Python's default TLS behavior:

    python
    data = urllib.request.urlopen(req, timeout=30).read()
    

    Alternatively, retain a default context without modifying check_hostname or verify_mode:

    python
    CTX = ssl.create_default_context()
    
  3. Apply the same correction to data_available() so every network request receives equivalent protection.

  4. Strengthen semantic validation before caching:

    • Require the root element to be positionRank.
    • Verify tradingday equals the requested date.
    • Verify productid and contract prefixes match the requested product.
    • Reject malformed, missing, duplicate, or unreasonable numeric fields.
    • Enforce a reasonable maximum response size.
  5. Download to a temporary file in the cache directory, validate it completely, flush it, and atomically replace the existing cache file only after successful validation. This prevents invalid responses from replacing known-good cached data.

  6. If CFFEX publishes checksums, signatures, or another authenticated data interface, verify the downloaded data against that mechanism before using it in reports.

Vulnerability Patterns
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • 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 (8)

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 112)May include surrounding context.

md
分享单元 = 文件夹 `ashare-if-cffex-position/`(含 `SKILL.md` + `if_netchange.py` + `cache/`)。对方放到 `~/.workbuddy/skills/ashare-if-cffex-position/`(Windows:`C:\Users\<用户名>

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
86% confidence
Finding

The skill instructs the agent to execute a local Python script that performs network access to cffex.com.cn and writes an HTML report to the working directory, but the manifest does not declare any tool scope or allowed-tools boundaries. This creates an authorization gap: an agent may run with broader-than-expected capabilities, making unintended file writes or network use harder to audit and constrain.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The description says the skill should be used whenever users need related analysis, which is an expansive activation scope for a skill that performs external downloads and local file generation. Ambiguous scope raises the chance of unintended invocation in routine financial discussions, with unnecessary data access and side effects.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The natural-language triggers like '统计今日股指持仓' and similar broad phrases are likely to match ordinary finance-analysis requests, causing the skill to auto-activate more often than intended. Overbroad activation is dangerous because it may trigger network fetching and report generation without the user clearly requesting this specific workflow.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The document tells the agent '本 skill 只出报告' and '不发邮件', but later states that a related automation script sends email after confirmation. That inconsistency can mislead operators or downstream agents about the actual behavior envelope of the skill package, increasing the risk of unexpected outbound communication if the broader folder contents are trusted or reused.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
99% confidence
Finding

The code explicitly disables TLS hostname verification and certificate validation for outbound requests, allowing a man-in-the-middle attacker to spoof the market data source if HTTPS is ever used. In this file the URLs are currently plain HTTP, which is even worse operationally: integrity and authenticity of downloaded XML are completely unprotected, so generated reports can be silently manipulated.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

The module docstring, command/output descriptions, and generated report text are all written in Chinese, and the HTML output is explicitly marked lang="zh-CN". There is no natural-language indication that users can opt into another language or that the skill is intentionally limited to a Chinese-speaking audience.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
96% confidence
Finding

The header documentation states the HTML output file is written to the current working directory, while nearby usage text says the cache directory is script-local and location-independent; the actual code confirms the report filename is opened without joining to SKILL_DIR and therefore lands in whatever directory the process is run from. This is an intent/documentation inconsistency about output location and side effects, even though it is not high risk.

Content

No source excerpt is available for this finding.