T09 · Insecure Skill Coding Practices
- Location
scripts/surname_query.py:21- Finding
Undocumented API Endpoint Override Can Disclose the AppKey
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
The skill is mostly a straightforward surname lookup tool, but it has an undocumented endpoint override that can redirect the API key to an arbitrary host.
Review before installing. Use this only if you trust the publisher and runtime environment, and avoid setting JIKE_API_BASE_URL. Prefer a version that fixes the API host to https://api.jikeapi.cn or validates the host before attaching the AppKey.
scripts/surname_query.py:21Undocumented API Endpoint Override Can Disclose the AppKey
The request target is built from JIKE_API_BASE_URL, which is taken directly from an environment variable, so whoever controls the runtime environment can redirect requests to an arbitrary host. Because the URL also includes the appkey query parameter, this can exfiltrate the credential to an attacker-controlled server and cause SSRF-like outbound requests from the host running the skill.
"""
url = f"{API_BASE_URL}{API_PATH}?{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": ""}
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
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():
The skill instructs the agent to run a local Python script that uses environment secrets and performs outbound network access, but the manifest does not declare any explicit tool scope such as permissions or allowed-tools. This weakens least-privilege controls and can allow broader-than-expected access to environment variables, local files, or network resources when the skill is executed.
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
"title": "百家姓查询 - 即刻数据",
"description": "百家姓查询。输入姓氏,查询姓氏起源、名人、迁徙分布等信息。",
"env": "JIKE_SURNAME_QUERY_KEY",
"api_url": "https://api.jikeapi.cn/v1/surname/query",
"homepage": "https://www.jikeapi.cn/"
}
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
"title": "百家姓查询 - 即刻数据",
"description": "百家姓查询。输入姓氏,查询姓氏起源、名人、迁徙分布等信息。",
"env": "JIKE_SURNAME_QUERY_KEY",
"api_url": "https://api.jikeapi.cn/v1/surname/query",
"homepage": "https://www.jikeapi.cn/"
}
The AppKey is appended to the URL query string, which can be exposed through logs, proxies, browser/history equivalents, monitoring systems, or error messages. In this skill, that risk is amplified because the base URL is configurable, so a redirected request would leak the credential directly to another endpoint.
Dynamic getattr() with a non-literal attribute name can access arbitrary object attributes, potentially bypassing access controls.
"""
params = {}
for param_name, _ in REQUIRED_PARAMS + OPTIONAL_PARAMS:
value = getattr(args, param_name, "")
value = validate_date_param(param_name, str(value))
if value:
params[param_name] = value