Back to skill

Security audit

国内猪肉价格实时查询 - 即刻数据

Security checks for vulnerabilities and agentic risk

Overview

The skill mostly matches its pork-price lookup purpose, but an undocumented API endpoint override can redirect the configured AppKey to another host.

Review this before installing in environments where untrusted users, wrappers, or deployment settings can influence environment variables. Use a narrowly scoped Jike AppKey, avoid storing it in shared files, and prefer a version that removes or validates JIKE_API_BASE_URL and keeps outbound requests pinned to the documented Jike API host.

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/pork_query.py:23
Finding

Arbitrary API Endpoint Override Can Disclose the AppKey

Content
View full analysis

Vulnerability Details

File Location: scripts/pork_query.py, lines 23 and 132–135
Vulnerability Type: Unvalidated API endpoint 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
params = {"appkey": appkey}
if province:
    params["province"] = province
url = f"{API_BASE_URL}{API_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 undocumented JIKE_API_BASE_URL environment variable can replace the trusted API origin with an arbitrary URL. The application does not validate the URL scheme, hostname, port, or destination before appending the AppKey and issuing the request.

Because the AppKey is included in the query string, running the script with an attacker-controlled environment can transmit the credential to an attacker-controlled server. Allowing arbitrary destinations also creates limited server-side request forgery behavior, although exploitation requires the attacker to influence the process environment.

Query-string authentication additionally risks credential exposure through URL logging by HTTP clients, proxies, gateways, and destination servers.

Attack Path

  1. An attacker gains the ability to influence the environment used to launch the Skill, such as through a wrapper, deployment configuration, or compromised process launcher.
  2. The attacker sets JIKE_API_BASE_URL to an attacker-controlled endpoint.
  3. A user or Agent invokes scripts/pork_query.py according to the documented workflow.
  4. The script retrieves the legitimate AppKey from --key, JIKE_PORK_QUERY_KEY, JIKE_APPKEY, or scripts/.env.
  5. The script appends that AppKey to the attacker-selected URL as the appkey query paramete ...[truncated 776 chars]
Remediation
View remediation

Remediation Suggestions

  1. Remove the JIKE_API_BASE_URL override from production code and use the fixed trusted endpoint https://api.jikeapi.cn.
  2. If endpoint configurability is required for testing, require an explicit development mode and enforce an allowlist of approved hosts.
  3. Parse the configured endpoint with urllib.parse.urlparse() and reject:
    • Schemes other than HTTPS.
    • Hostnames other than explicitly approved API domains.
    • Embedded credentials, fragments, and unexpected ports.
    • Loopback, link-local, private-network, and metadata-service addresses where they are not explicitly required.
  4. Disable redirects or validate every redirect destination before forwarding credentials, ensuring credentials are never sent to an untrusted origin.
  5. Prefer transmitting the AppKey in an authorization header rather than the query string if supported by the API.
  6. Ensure deployment systems prevent untrusted users or workloads from altering security-sensitive environment variables.
  7. Rotate the AppKey if the script has previously run in an environment where JIKE_API_BASE_URL may have been controlled by an untrusted party.
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 (5)

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

python
params["province"] = province
    url = f"{API_BASE_URL}{API_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/pork_query.py (reported line 48)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 invokes Python, reads environment variables for API keys, and performs outbound network requests, but it does not declare an explicit tool scope such as permissions or allowed-tools. This creates an authorization ambiguity where the runtime may grant broader capabilities than users or reviewers expect, 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
84% confidence
Finding

The skill sends user-derived query data and an authentication key to an external third-party API endpoint. While this is expected for the feature, it still constitutes external data transmission and introduces privacy, dependency, and secret-handling risk if the request target, transport, or logging behavior is not tightly controlled.

Content

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

直接调用 API:

text
GET https://api.jikeapi.cn/v1/pork/query?province=四川&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_PORK_QUERY_KEY",
  "api_url": "https://api.jikeapi.cn/v1/pork/query",
  "homepage": "https://www.jikeapi.cn/"
}

Static analysis

No suspicious patterns detected.