Back to skill

Security audit

上海黄金交易所行情 - 即刻数据

Security checks for vulnerabilities and agentic risk

Overview

The skill performs the advertised gold-market lookup, but an undocumented endpoint override can send its API key to an arbitrary server.

Review before installing. Only run this skill in an environment where JIKE_API_BASE_URL cannot be set by untrusted parties, prefer a dedicated low-privilege Jike API key, and avoid passing the key on the command line. Expect the requested date and API credential to be sent to Jike API when the skill runs.

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/gold_shgold_query.py:22
Finding

Unrestricted API Endpoint Override Can Disclose the AppKey

Content
View full analysis

Vulnerability Details

File Location: scripts/gold_shgold_query.py, lines 22 and 109–111
Vulnerability Type: Unvalidated destination override and credential disclosure
Risk Level: Medium

Vulnerable Code

python
API_BASE_URL = os.environ.get("JIKE_API_BASE_URL", "https://api.jikeapi.cn").rstrip("/")
python
url = f"{API_BASE_URL}{API_PATH}?{urllib.parse.urlencode({'date': date_value, 'appkey': appkey})}"
try:
    with urllib.request.urlopen(url, timeout=15) as response:

Technical Analysis

The script accepts an undocumented JIKE_API_BASE_URL environment variable without validating its scheme, hostname, port, or ownership. It concatenates that value with the API path and transmits the AppKey as a URL query parameter.

An inherited or attacker-controlled environment can therefore redirect requests from the declared https://api.jikeapi.cn service to an arbitrary destination. Because the script does not require HTTPS, the override may also use plaintext HTTP.

The AppKey is included directly in the query string of the redirected request. Consequently, a server controlling the selected endpoint can collect the credential. Query-string credentials may also be retained in HTTP server, proxy, monitoring, or diagnostic logs.

Attack Path

  1. An attacker gains the ability to influence the environment used to launch the Skill, such as through a compromised wrapper, deployment configuration, or orchestration layer.
  2. The attacker sets JIKE_API_BASE_URL to an attacker-controlled HTTP or HTTPS origin.
  3. A user or Agent invokes the script for a normal historical market-data query.
  4. The script loads the legitimate AppKey from --key, JIKE_GOLD_SHGOLD_QUERY_KEY, JIKE_APPKEY, or the local .env file.
  5. The script constructs a request to the attacker-selected origin with appkey=<secret> in its query string.
  6. The attacker records the AppKey and may return manipulated JSON market data to the caller.

Impact A

...[truncated 539 chars]

Remediation
View remediation

Remediation Suggestions

  1. Remove the JIKE_API_BASE_URL override from production code and use the fixed declared endpoint:

    python
    API_BASE_URL = "https://api.jikeapi.cn"
    
  2. If endpoint configurability is required for testing, parse and validate it before use:

    • Require the https scheme.
    • Permit only explicitly allowlisted hostnames.
    • Reject embedded usernames or passwords.
    • Reject unexpected ports, fragments, and malformed URLs.
    • Keep test-only endpoint overrides disabled in production builds.
  3. Prefer sending the AppKey in an authorization header rather than a query parameter if the service supports it. This reduces exposure through URL logging and monitoring systems.

  4. Avoid accepting secrets through --key, because command-line arguments may be exposed through process listings, shell history, or execution telemetry. Prefer a protected environment variable or a dedicated secret-management facility.

  5. Ensure .env files containing credentials have restrictive filesystem permissions and are excluded from source control.

  6. Add automated tests confirming that non-HTTPS URLs and unapproved hosts are rejected before any credential-bearing request is made.

Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Taint TrackingDirect Taint Flow, Variable-Mediated Taint Flow, Credential Exfiltration Chain
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
Findings (8)

Tainted flow: 'url' from os.environ.get (line 111, credential/environment) → urllib.request.urlopen (network output)

Critical
Category
Data Flow
Confidence
90% confidence
Finding

Credentials or environment variables flow to a network sink. This is a high-confidence indicator of credential exfiltration.

Content

Scanner excerpt · scripts/gold_shgold_query.py (reported line 113)May include surrounding context.

python
"""
    url = f"{API_BASE_URL}{API_PATH}?{urllib.parse.urlencode({'date': date_value, 'appkey': appkey})}"
    try:
        with urllib.request.urlopen(url, timeout=15) as response:
            return json.loads(response.read().decode("utf-8"))
    except urllib.error.HTTPError as exc:
        return {"code": exc.code, "message": f"接口请求失败: HTTP {exc.code}", "data": ""}

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/gold_shgold_query.py (reported line 49)May include surrounding context.

python
env_value = os.environ.get(env_name, "").strip()
        if env_value:
            return env_value
    env_file = Path(__file__).parent / ".env"
    if not env_file.exists():
        return ""
    for line in env_file.read_text(encoding="utf-8").splitlines():

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
89% confidence
Finding

The skill declares executable behavior that can read environment variables, read files, and make network requests, but it does not constrain those capabilities with an explicit tool scope. In an agent environment, this weakens least-privilege controls and makes it easier for the skill or downstream prompt interpretation to access secrets or perform unintended outbound requests.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The description is broad enough to match generic date, data-query, or market-query requests, which can cause the skill to trigger when the user did not clearly intend to call this external data source. Mis-triggering matters here because the skill performs external API access and may transmit user-supplied query data and use a credentialed backend request.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
86% confidence
Finding

The skill is designed to send requests to an external service, which is an external data transmission boundary. In context this is expected functionality, but it still carries security and privacy risk because user-derived inputs are transmitted off-platform and the example places the appkey in the URL, which can leak via logs, history, or intermediaries.

Content

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

直接调用 API:

text
GET https://api.jikeapi.cn/v1/gold/shgold/history?appkey=YOUR_APPKEY

AI 使用步骤

External Transmission

Medium
Category
Data Exfiltration
Confidence
50% confidence
Finding

Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Content

Scanner excerpt · _meta.json (reported line 8)May include surrounding context.

json
"title": "上海黄金交易所行情 - 即刻数据",
  "description": "按日期查询上海黄金交易所历史行情,返回品种、开盘价、最高价、最低价、收盘价、涨跌幅和成交量等信息。",
  "env": "JIKE_GOLD_SHGOLD_QUERY_KEY",
  "api_url": "https://api.jikeapi.cn/v1/gold/shgold/history",
  "homepage": "https://www.jikeapi.cn/"
}

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
84% confidence
Finding

The instructions tell the AI to execute the script and return results but do not clearly disclose that doing so sends the requested date to a third-party API and uses an API key from the environment. This creates a transparency and privacy issue because users and operators may not realize an external service is involved.

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, argument help text, error messages, and output are all written exclusively in Chinese, which imposes a specific language on users without opt-in. Under the policy, locale or language constraints should either be optional for the user or explicitly justified as region-specific.

Content

No source excerpt is available for this finding.