Back to skill

Security audit

圆周率查询 - 即刻数据

Security checks for vulnerabilities and agentic risk

Overview

The skill is a coherent Pi-query integration, but it needs Review because an undocumented API-base override can send the configured AppKey to an arbitrary endpoint.

Install only if you are comfortable sending pi lookup requests and your Jike AppKey to the Jike API. Do not run it in an environment where untrusted users or wrappers can set JIKE_API_BASE_URL, and prefer rotating the key if it may have been run with an unexpected API base URL. The publisher should narrow the activation text to pi queries and validate or remove the API-base override.

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/pi_query.py:21
Finding

Unrestricted API Endpoint Override Can Disclose the AppKey

Content
View full analysis

Vulnerability Details

File Location: scripts/pi_query.py, lines 21 and 135–137
Vulnerability Type: Unvalidated API endpoint override and credential exposure
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})}"
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 without validating its scheme or hostname. It then places the AppKey in the URL query string and sends the request to the configured origin.

An attacker who can influence the process environment can set this variable to an attacker-controlled server. The server would receive the AppKey in the appkey query parameter. The override also accepts a plaintext HTTP URL, allowing network observers or intermediaries to inspect the credential and query data.

Passing credentials in a query string creates additional exposure because complete URLs may be recorded in proxy, web-server, monitoring, or diagnostic logs.

Attack Path

  1. The victim configures a valid JIKE_PI_QUERY_KEY or JIKE_APPKEY.
  2. An attacker, compromised launcher, CI configuration, wrapper script, or otherwise untrusted execution environment sets JIKE_API_BASE_URL to an attacker-controlled URL, such as https://attacker.example.
  3. The victim or agent invokes either supported Pi query command.
  4. The script constructs a URL under the attacker-controlled origin and appends the AppKey as the appkey query parameter.
  5. urllib.request.urlopen() sends the request to that origin.
  6. The attacker obtains the AppKey from the incoming request URL or associated server logs.
  7. The attacker can reuse the credential against the ...[truncated 683 chars]
Remediation
View remediation

Remediation Suggestions

  1. Remove the runtime API-origin override from production builds and use the fixed trusted endpoint https://api.jikeapi.cn.
  2. If endpoint configurability is required for controlled testing:
    • Parse the configured URL before use.
    • Require the https scheme.
    • Reject embedded credentials, fragments, unexpected ports, and malformed hosts.
    • Enforce an explicit hostname allowlist, preferably only api.jikeapi.cn.
    • Keep test endpoint overrides behind a separate development-only option.
  3. Send the AppKey in an API authorization header rather than the query string if the remote API supports it.
  4. If query-string authentication is mandated by the API, ensure that application, proxy, monitoring, and server logs redact the appkey parameter.
  5. Treat process environment configuration as security-sensitive and prevent untrusted users, wrappers, or job definitions from modifying it.
  6. Add automated tests confirming that plaintext HTTP and non-allowlisted hosts are rejected before any credential-bearing request is sent.
  7. Rotate the AppKey if the script has previously run with an untrusted or unexpected JIKE_API_BASE_URL.
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 (9)

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

Critical
Category
Data Flow
Confidence
93% confidence
Finding

The request destination is partially controlled by the JIKE_API_BASE_URL environment variable, and the code appends the AppKey to the query string before calling urllib.request.urlopen. In an agent/runtime context, an attacker who can influence environment variables can redirect requests to an arbitrary host and capture the credential, making this an SSRF-style exfiltration path rather than a harmless configuration option.

Content

Scanner excerpt · scripts/pi_query.py (reported line 154)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/pi_query.py (reported line 51)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
85% confidence
Finding

The skill declares code-relevant capabilities via metadata and documented usage (environment variables, file/script invocation, and outbound API access) but does not define an explicit tool scope such as allowed-tools or permissions. This can cause overbroad execution authority in host environments, making it easier for an agent to access resources or perform network actions beyond what the skill strictly needs.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The description says the skill is for Pi queries, but also claims applicability to unrelated categories like date queries or market quotes. That overly broad activation text can cause the agent to invoke this skill in inappropriate contexts, leading to unnecessary external requests and potential disclosure of user query content to a third-party API.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
78% confidence
Finding

The skill explicitly sends requests to an external API and includes authentication via an app key in the query string example. Even for a legitimate data service, outbound transmission can expose user request content and risks accidental credential leakage through logs, intermediaries, or copied URLs when secrets are placed in GET parameters.

Content

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

直接调用 API:

text
GET https://api.jikeapi.cn/v1/pi/find_number?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_PI_QUERY_KEY",
  "api_url": "https://api.jikeapi.cn/v1/pi/find_number",
  "homepage": "https://www.jikeapi.cn/"
}

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The skill's natural-language documentation and all user-facing messages are fixed in Chinese, with no indication that the user can choose another language. Per the policy, forcing a specific language without user opt-in is a locale/language policy violation.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The AppKey is included directly in the request URL as a query parameter. Query-string credentials are commonly exposed via logs, proxies, browser/history equivalents, monitoring systems, and upstream servers, so the secret may leak even when TLS is used.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
76% confidence
Finding

The natural-language description is entirely Chinese and does not indicate any user language choice or that the skill is intentionally limited to a Chinese-speaking context. Under the policy, forcing a specific language without opt-in can be a locale-policy issue unless the regional constraint is explicitly documented and justified.

Content

No source excerpt is available for this finding.