Back to skill

Security audit

十万个为什么 - 即刻数据

Security checks for vulnerabilities and agentic risk

Overview

The skill mostly does what it claims, but it has an undocumented endpoint override that could send the Jike API key and user queries to an arbitrary host.

Review this skill before installing. Use a dedicated Jike API key with limited quota, do not set JIKE_API_BASE_URL unless you fully trust the destination, and prefer running it in an environment that restricts outbound network access to the intended 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/tenwhy_query.py:19
Finding

Undocumented API Endpoint Override Can Disclose the AppKey

Content
View full analysis

Vulnerability Details

File Location: scripts/tenwhy_query.py, lines 19 and 144
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_MAP[command]}?{urllib.parse.urlencode({**params, 'appkey': appkey})}"

Technical Analysis

The undocumented JIKE_API_BASE_URL environment variable controls the complete origin to which API requests are sent. The script does not validate that the configured URL uses HTTPS or that its hostname is the intended api.jikeapi.cn service.

The request URL includes the AppKey as an appkey query parameter. Consequently, a process capable of influencing the execution environment can redirect the request to an attacker-controlled HTTP or HTTPS server and receive the credential. Query parameters may also be recorded in destination-server access logs, proxy logs, monitoring systems, and other URL-processing infrastructure.

The same redirected request can disclose user-supplied keywords and pagination metadata. The behavior is not needed for the Skill's documented operation and is not disclosed in SKILL.md.

Attack Path

  1. An attacker or compromised launcher sets JIKE_API_BASE_URL to an attacker-controlled endpoint, such as https://attacker.example.
  2. A user or agent invokes the documented query or random command.
  3. load_appkey() obtains a valid AppKey from the command line, environment, or local .env file.
  4. request_api() appends the AppKey and business parameters to the attacker-controlled base URL.
  5. urllib.request.urlopen() sends the request to the attacker's server.
  6. The attacker extracts the AppKey and any keyword or pagination data from the request URL.

Impact Assessment

Successful exploitation exposes the Jike API credential and user query data. The attacker can ...[truncated 476 chars]

Remediation
View remediation

Remediation Suggestions

  1. Remove the JIKE_API_BASE_URL override if custom API origins are not a documented requirement.
  2. Otherwise, parse the URL and enforce an explicit allowlist:
    • Require the https scheme.
    • Require the exact hostname api.jikeapi.cn.
    • Reject embedded user information, unexpected ports, fragments, and deceptive hostname suffixes.
  3. Construct request URLs from a fixed trusted origin and fixed path map rather than concatenating an environment-controlled base URL.
  4. If the upstream API supports it, transmit the AppKey in an authorization header rather than the query string.
  5. Avoid accepting credentials through --key, because command-line arguments may be visible in process listings and shell history; prefer a protected environment variable or restrictive credential file.
  6. Ensure logs, exceptions, and diagnostics never print complete URLs containing credentials.
  7. Add tests confirming that non-HTTPS schemes, unapproved hosts, malformed URLs, and redirect attempts are rejected. Where practical, disable cross-origin redirects or verify the final redirect destination before forwarding credentials.
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 (6)

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

Critical
Category
Data Flow
Confidence
90% confidence
Finding

The request URL is built from JIKE_API_BASE_URL, which is taken directly from the environment and then passed to urllib.request.urlopen. If an attacker can influence the runtime environment, they can redirect requests to an arbitrary host, causing SSRF-style behavior, exfiltration of the AppKey in the query string, or use of insecure/non-approved endpoints. In this skill context, the risk is somewhat limited because the path is fixed and there is no direct user-controlled URL input, but the environment remains a powerful trust boundary.

Content

Scanner excerpt · scripts/tenwhy_query.py (reported line 151)May include surrounding context.

python
"""
    url = f"{API_BASE_URL}{API_PATH_MAP[command]}?{urllib.parse.urlencode({**params, '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/tenwhy_query.py (reported line 52)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
91% confidence
Finding

The skill declares runtime requirements and clearly depends on environment variables, local script execution, and an external network-backed API, but it does not declare an explicit tool/permission scope. That can cause the host agent to grant broader capabilities than intended or make the skill's operational trust boundary unclear, increasing the risk of unintended network access or secret exposure in environments that rely on manifest-level restrictions.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The description states the skill should be used when users request search, random recommendation, or explanation of related Chinese content, which imposes a language/locale constraint in the skill's natural-language behavior. The file does not indicate that users can choose another language or that Chinese-only handling is optional or region-specific.

Content

No source excerpt is available for this finding.

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_TENWHY_QUERY_KEY",
  "api_url": "https://api.jikeapi.cn/v1/tenwhy/query",
  "homepage": "https://www.jikeapi.cn/"
}

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

This Python file contains its docstring, CLI help text, and runtime messages exclusively in Chinese. Under the policy, forcing a specific language without user opt-in is a natural-language locale violation, and there is no indication that the skill offers language selection or that the locale restriction is justified as region-specific.

Content

No source excerpt is available for this finding.