T09 · Insecure Skill Coding Practices
- Location
scripts/_auth.py:11- Finding
Unrestricted API Base Override Can Exfiltrate Credentials and Access Tokens
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
The skill appears to support the stated Chanjing API workflow, but its handling of API secrets is too broadly configurable and could expose credentials if the API endpoint environment is unsafe.
Review before installing. Use this only with credentials you intend to grant to Chanjing AI creation APIs, keep ~/.chanjing private, and do not set CHANJING_API_BASE unless it is a trusted HTTPS Chanjing-controlled endpoint. Consider using limited-scope or test credentials, and expect the skill to submit tasks, list task history, poll results, cache tokens locally, and consume API quota.
scripts/_auth.py:11Unrestricted API Base Override Can Exfiltrate Credentials and Access Tokens
scripts/_auth.py:49Credential File Is Written Without Enforcing Restrictive Permissions
The token request destination is derived from CHANJING_API_BASE, an environment variable, and the code sends app_id and secret_key to that URL. If an attacker can influence the environment, they can redirect the request to an attacker-controlled server and exfiltrate long-lived credentials over HTTPS or HTTP-equivalent endpoints they control.
headers={"Content-Type": "application/json"},
method="POST",
)
with urllib.request.urlopen(req, timeout=30) as resp:
return json.loads(resp.read().decode("utf-8"))
The skill explicitly instructs use of a local credentials file containing AK/SK material, which confirms access to sensitive secrets during execution. Even if this is functionally necessary, exposing broad credential-file consumption inside a general-purpose skill raises the risk of accidental disclosure, misuse by downstream scripts, or execution in contexts where secret access was not clearly authorized.
本 Skill 使用:
* 配置文件:`~/.chanjing/credentials.json`
* 若设置环境变量 `CHANJING_CONFIG_DIR`:使用 `$CHANJING_CONFIG_DIR/credentials.json`
* API 基础地址:`https://open-api.chanjing.cc`(可用 `CHANJING_API_BASE` 覆盖)
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
#!/usr/bin/env python3
# 鉴权:从 CONFIG_DIR/credentials.json 读取 AK/SK
# 实现:AK/SK 校验、Token 校验与刷新;无 AK/SK 或 AK/SK 无效时在默认浏览器打开蝉镜官方登录页
import json
import os
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
#!/usr/bin/env python3
# 鉴权:从 CONFIG_DIR/credentials.json 读取 AK/SK
# 实现:AK/SK 校验、Token 校验与刷新;无 AK/SK 或 AK/SK 无效时在默认浏览器打开蝉镜官方登录页
import json
import os
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
#!/usr/bin/env python3
# 鉴权:从 CONFIG_DIR/credentials.json 读取 AK/SK
# 实现:AK/SK 校验、Token 校验与刷新;无 AK/SK 或 AK/SK 无效时在默认浏览器打开蝉镜官方登录页
import json
import os
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
#!/usr/bin/env python3
# 鉴权:从 CONFIG_DIR/credentials.json 读取 AK/SK
# 实现:AK/SK 校验、Token 校验与刷新;无 AK/SK 或 AK/SK 无效时在默认浏览器打开蝉镜官方登录页
import json
import os
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
#!/usr/bin/env python3
# 鉴权:从 CONFIG_DIR/credentials.json 读取 AK/SK
# 实现:AK/SK 校验、Token 校验与刷新;无 AK/SK 或 AK/SK 无效时在默认浏览器打开蝉镜官方登录页
import json
import os
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
#!/usr/bin/env python3
# 鉴权:从 CONFIG_DIR/credentials.json 读取 AK/SK
# 实现:AK/SK 校验、Token 校验与刷新;无 AK/SK 或 AK/SK 无效时在默认浏览器打开蝉镜官方登录页
import json
import os
The skill advertises scripts that read environment variables, access local credential files, write outputs, and make network requests, but it does not declare any explicit tool scope or permission boundaries. This weakens reviewability and can cause an agent runtime to invoke a capability-rich skill without clear least-privilege constraints, increasing the chance of unintended local file access, credential handling, or outbound requests.
SQP-3 applies to all file types and covers language or locale policy violations. The natural-language trigger section presents only Chinese trigger phrasing and says these utterances should trigger the skill, with no opt-in, multilingual alternative, or explanation that the skill is intentionally restricted to a Chinese-language context.
The natural-language instructions throughout the file are presented in Chinese, which effectively forces a specific language for users reading the skill reference. SQP-3 applies to all file types and flags language-policy issues when no user opt-in, alternative language, or explicit justification for the locale constraint is provided.
Data from a source is assigned to a variable that is later passed to a sink, creating a variable-mediated taint flow.
def write_config(data):
CONFIG_DIR.mkdir(parents=True, exist_ok=True)
with open(CONFIG_FILE, "w", encoding="utf-8") as f:
json.dump(data, f, indent=2, ensure_ascii=False)
This code reads credentials from a local file and sends them in an HTTP POST request to obtain a token. While the operation is core to authentication, this file provides no user-facing disclosure via print/logging, prompt, or explanatory docstring/comment near the network transmission itself that sensitive credentials will be sent to a remote service.
Dynamic import() can load arbitrary modules at runtime, bypassing static analysis and potentially importing malicious code.
from _auth import clear_cached_token, get_token
API_BASE = __import__("os").environ.get("CHANJING_API_BASE", "https://open-api.chanjing.cc")
RUNNING_STATUSES = {"Queued", "Ready", "Generating"}
SUCCESS_STATUSES = {"Success"}
This is a markdown file, so SQP-2 applies to omitted warnings in the skill description. The section on explicit download says the command downloads output and reports a local file path, but it does not warn that the operation writes files to the local system or note any implications such as destination handling or overwriting.
This markdown file documents a download_result action that downloads output_url content to the local machine, which can affect user data or system state. Under the markdown variant of SQP-2, the description should disclose file-writing behavior so users understand that running the skill may create local files.
No suspicious patterns detected.