T09 · Insecure Skill Coding Practices
- Location
scripts/_auth.py:13- Finding
Credentials, access tokens, and user content can be redirected to an arbitrary endpoint
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This TTS skill appears purpose-aligned, but it needs review because stored credentials can be sent to an environment-selected endpoint and an adjacent login helper can be executed automatically.
Review before installing. Use it only in an environment where CHANJING_API_BASE is unset or pinned to the official HTTPS Chanjing API, protect ~/.chanjing/credentials.json with owner-only permissions, and inspect any adjacent chanjing-credentials-guard installation before allowing this skill to run. Do not automatically download returned audio URLs unless the destination is validated as an expected Chanjing media host.
scripts/_auth.py:13Credentials, access tokens, and user content can be redirected to an arbitrary endpoint
scripts/_auth.py:61Plaintext credential storage does not enforce restrictive filesystem permissions
scripts/_auth.py:33Unverified Python code from an adjacent Skill is executed automatically
scripts/poll_task.py:24Task polling has no attempt limit or overall deadline
scripts/poll_task.py:50API-controlled audio URL is exposed for downstream fetching without validation
The destination for the token request is derived from CHANJING_API_BASE, and the request body contains app_id and secret_key. If an attacker can control the environment, they can redirect this authentication request to an arbitrary server and exfiltrate stored credentials.
method="POST",
)
try:
with urllib.request.urlopen(req, timeout=30) as resp:
body = json.loads(resp.read().decode("utf-8"))
except Exception as e:
return None, str(e)
The skill states it will execute open_login_page.py and open the default browser when credentials are missing. Triggering an auxiliary script and browser launch from a credential failure path expands the attack surface and can surprise users, especially in automated or high-trust agent environments where shell execution and external navigation should be explicit and tightly constrained.
## How to Use This Skill
**前置条件(权限验证)**:执行本 Skill 前,必须先通过 **chanjing-credentials-guard** 完成 AK/SK 与 Token 校验。本 Skill 与 guard 使用同一套凭证(`~/.chanjing/credentials.json`);脚本在无凭证时会**执行 `open_login_page.py` 脚本**,在默认浏览器打开 AK/SK 注册/登录页,并提示配置命令。
### Reviewer Q&A (four items)
This section explicitly says the skill reads and writes credentials.json, may open a browser, and downloads audio from URLs returned by the API, asking the operator to trust those links. Downloading and following response-supplied URLs without documented allowlisting or validation can enable SSRF-like outbound access, unintended data exfiltration targets, or delivery of malicious content if the API or its responses are compromised.
| # | Topic | Answer |
|---|-------|--------|
| **1** | **Purpose vs implementation; primary credential in registry text** | **Aligned**. This skill is a **Chanjing TTS** API client (list voices, create speech task, poll, fetch audio from **URLs in responses**). **`CHANJING_API_BASE` is not required** (default base URL). **Primary credential** is **`credentials.json`** (`app_id` / `secret_key`, refreshed **`access_token`**); stated in **`description`**, top English summary, and **Security & credentials** below. **`primaryEnv` omitted** (file-based dual keys). **No** `ffmpeg`/`ffprobe` in `metadata`. |
| **2** | **Runtime scope: secrets, arbitrary URLs** | **In scope**. Reads/writes **`CHANJING_CONFIG_DIR/credentials.json`**; may open **browser** / **`open_login_page.py`**; **HTTPS** to Open API; **downloads audio using URLs returned by the API**—**you must trust** the API host and those links. |
| **3** | **Env vars vs file-stored secrets** | **`CHANJING_CONFIG_DIR` / `CHANJING_API_BASE`** are optional. **AK/SK and token persist on disk**—sensitive; do not commit secrets; avoid echoing full keys in chat. |
| **4** | **Persistence & privilege** | Default **`always: false`**; **does not** modify other skills or global agent config. |
The documented runtime scope includes reading/writing persistent credentials and downloading from API-returned links, with no mention of output validation or network restrictions. In an agent setting, that combination is risky because secrets and network egress are both in scope, and a compromised or misconfigured API could direct the skill to retrieve attacker-controlled resources.
| # | Topic | Answer |
|---|-------|--------|
| **1** | **Purpose vs implementation; primary credential in registry text** | **Aligned**. This skill is a **Chanjing TTS** API client (list voices, create speech task, poll, fetch audio from **URLs in responses**). **`CHANJING_API_BASE` is not required** (default base URL). **Primary credential** is **`credentials.json`** (`app_id` / `secret_key`, refreshed **`access_token`**); stated in **`description`**, top English summary, and **Security & credentials** below. **`primaryEnv` omitted** (file-based dual keys). **No** `ffmpeg`/`ffprobe` in `metadata`. |
| **2** | **Runtime scope: secrets, arbitrary URLs** | **In scope**. Reads/writes **`CHANJING_CONFIG_DIR/credentials.json`**; may open **browser** / **`open_login_page.py`**; **HTTPS** to Open API; **downloads audio using URLs returned by the API**—**you must trust** the API host and those links. |
| **3** | **Env vars vs file-stored secrets** | **`CHANJING_CONFIG_DIR` / `CHANJING_API_BASE`** are optional. **AK/SK and token persist on disk**—sensitive; do not commit secrets; avoid echoing full keys in chat. |
| **4** | **Persistence & privilege** | Default **`always: false`**; **does not** modify other skills or global agent config. |
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
# 鉴权:与 chanjing-credentials-guard 使用同一配置文件(CONFIG_DIR/credentials.json)
# 实现:AK/SK 校验、Token 校验与刷新;无 AK/SK 时执行 open_login_page.py 打开注册/登录页
import json
import os
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
# 鉴权:与 chanjing-credentials-guard 使用同一配置文件(CONFIG_DIR/credentials.json)
# 实现:AK/SK 校验、Token 校验与刷新;无 AK/SK 时执行 open_login_page.py 打开注册/登录页
import json
import os
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
# 鉴权:与 chanjing-credentials-guard 使用同一配置文件(CONFIG_DIR/credentials.json)
# 实现:AK/SK 校验、Token 校验与刷新;无 AK/SK 时执行 open_login_page.py 打开注册/登录页
import json
import os
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
# 鉴权:与 chanjing-credentials-guard 使用同一配置文件(CONFIG_DIR/credentials.json)
# 实现:AK/SK 校验、Token 校验与刷新;无 AK/SK 时执行 open_login_page.py 打开注册/登录页
import json
import os
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
# 鉴权:与 chanjing-credentials-guard 使用同一配置文件(CONFIG_DIR/credentials.json)
# 实现:AK/SK 校验、Token 校验与刷新;无 AK/SK 时执行 open_login_page.py 打开注册/登录页
import json
import os
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
# 鉴权:与 chanjing-credentials-guard 使用同一配置文件(CONFIG_DIR/credentials.json)
# 实现:AK/SK 校验、Token 校验与刷新;无 AK/SK 时执行 open_login_page.py 打开注册/登录页
import json
import os
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
# 鉴权:与 chanjing-credentials-guard 使用同一配置文件(CONFIG_DIR/credentials.json)
# 实现:AK/SK 校验、Token 校验与刷新;无 AK/SK 时执行 open_login_page.py 打开注册/登录页
import json
import os
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
# 鉴权:与 chanjing-credentials-guard 使用同一配置文件(CONFIG_DIR/credentials.json)
# 实现:AK/SK 校验、Token 校验与刷新;无 AK/SK 时执行 open_login_page.py 打开注册/登录页
import json
import os
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
# 鉴权:与 chanjing-credentials-guard 使用同一配置文件(CONFIG_DIR/credentials.json)
# 实现:AK/SK 校验、Token 校验与刷新;无 AK/SK 时执行 open_login_page.py 打开注册/登录页
import json
import os
The skill declares significant capabilities—environment access, reading and writing credential files, network access, and shell/browser invocation—but does not define an explicit permission or allowed-tools scope. That omission increases the chance an agent runtime grants broader access than users or reviewers expect, especially given the documented credential handling and external downloads.
The skill explicitly states it will download audio from URLs contained in API responses and instructs reviewers to trust the returned URLs. Treating response-supplied URLs as trusted without documented validation is dangerous because it can turn the skill into an unrestricted fetcher, enabling attacker-controlled downloads, internal network probing, or retrieval of unexpected content if the upstream service is compromised.
**Required vs optional**: **`CHANJING_API_BASE`** **optional** (default `https://open-api.chanjing.cc`). **`CHANJING_CONFIG_DIR`** optional. **No** `ffmpeg`/`ffprobe` in skill `metadata`.
**Purpose alignment**: **TTS** client—list voices, create task, poll, **download audio from URLs in API responses**. **Trust** the API host and returned URLs.
See **How to Use** → **Reviewer Q&A (four items)** → **Security & credentials (registry summary)**.
The documented workflow requires polling until success and then downloading the generated audio from a URL in the response, again without any stated restriction on the destination. In this skill context, the combination of persistent credentials, network access, and response-driven downloads makes the behavior more dangerous because a single compromised API response can direct outbound traffic to unintended hosts.
1. Obtain an `access_token`, which is required for all subsequent API calls
2. List all voice IDs and select one to use
3. Call the Create Speech API, record `task_id`
4. Poll the Query Speech Status API until success, then download generated audio file using the url in response
### Obtain AccessToken
The manifest describes this skill as converting text to speech via the Chanjing TTS API, with credentials stored in credentials.json. This helper also launches a separate login/registration experience in the user's browser, which is a broader user-auth/onboarding behavior not reflected in the stated skill purpose.
A text-to-speech skill is expected to read credentials and call the TTS API, but invoking subprocesses to execute another skill's script introduces a separate execution capability. That behavior is not obviously required by the manifest's stated purpose, especially since the manifest only mentions credential files and optional configuration variables.
The code automatically executes another script via subprocess and may open the user's default browser when credentials are missing or invalid. This is a system-affecting action, but the file provides no prompt, log, or other user-visible disclosure before triggering it; the returned message is only produced after the action has already occurred.
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
skills_dir = Path(__file__).resolve().parent.parent.parent
script = skills_dir / "chanjing-credentials-guard" / "scripts" / "open_login_page.py"
if script.exists():
subprocess.run([sys.executable, str(script)], check=False, timeout=5)
else:
import webbrowser
webbrowser.open(LOGIN_URL)
The function writes access tokens and related credentials to CONFIG_DIR/credentials.json, which affects user data on disk. Although comments describe authentication behavior, there is no user-facing prompt, log, print, or other disclosure at the point of writing to inform the user that secrets and refreshed tokens are being persisted locally.
The credential file path is influenced by CHANJING_CONFIG_DIR from the environment and is written without validation or permission hardening. In a hostile execution environment, an attacker could redirect writes to an unintended filesystem location, causing credential leakage or overwriting sensitive files accessible to the running user.
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)
The token refresh flow transmits app_id and secret_key to a remote API endpoint over HTTP(S). While this is plausibly part of the authentication purpose, this file contains no user-facing warning, prompt, or runtime disclosure that locally stored credentials will be sent to the service to obtain a token.
Dynamic import() can load arbitrary modules at runtime, bypassing static analysis and potentially importing malicious code.
sys.path.insert(0, str(Path(__file__).resolve().parent))
from _auth import get_token
API_BASE = __import__("os").environ.get("CHANJING_API_BASE", "https://open-api.chanjing.cc")
def main():
Dynamic import() can load arbitrary modules at runtime, bypassing static analysis and potentially importing malicious code.
sys.path.insert(0, str(Path(__file__).resolve().parent))
from _auth import get_token
API_BASE = __import__("os").environ.get("CHANJING_API_BASE", "https://open-api.chanjing.cc")
def main():