T09 · Insecure Skill Coding Practices
- Location
clash-switch.sh:15- Finding
Hardcoded Clash Controller Credential
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
The skill has a coherent proxy auto-switching purpose, but it ships unsafe credential handling, injectable shell code, and elevated scheduled-task guidance that users should review before installing.
Install only after reviewing the scripts. Prefer the Python skill path with a unique local Clash secret, keep the controller bound to localhost, avoid passing secrets on command lines or committing them to config files, do not run scheduled tasks as administrator/root, and avoid the bundled shell scripts unless the hardcoded secret, injection bug, and `/tmp` state handling are fixed.
clash-switch.sh:15Hardcoded Clash Controller Credential
clash-switch.sh:42Arbitrary Python Code Execution Through Crafted Proxy Node Names
clash-switch-v2.sh:21Predictable Shared Temporary State Enables File Overwrite and Unintended File Reads
README.md:160Scheduled Task Documentation Requests Unnecessary Highest Privileges
skills/clash-auto-switch/requirements.txt:1Unpinned Runtime Dependencies Permit Unaudited Package Resolution
skills/clash-auto-switch/clash.py:21Clash Bearer Secret Can Be Sent to Arbitrary Plaintext HTTP Endpoints
The README promotes automatic proxy switching, health checks, and scheduled execution, but does not clearly warn that these operations can change active network routing and affect where user traffic is sent. In a skill context, that omission increases the chance of users enabling unattended behavior that silently alters connectivity, privacy exposure, or service access.
The README instructs users to run npx clawdhub install clash-auto-switch without pinning a specific package version. This can cause users to fetch whatever version is current at execution time, increasing supply-chain risk if a malicious or compromised release is published or if behavior changes unexpectedly.
The skill explicitly supports automated and scheduled execution of /clash auto, which can change active proxy/group selections without an explicit warning that network routing will be modified. In an agent or cron context, this can unexpectedly alter connectivity, traffic paths, and service behavior, making the action security-relevant rather than a harmless status check.
The script embeds a hard-coded Clash API bearer token directly in source and then uses it in HTTP requests. Hard-coded secrets are easily exposed through source sharing, backups, logs, shell history, or local file access, allowing unauthorized control of the local proxy manager and potentially traffic redirection or service disruption.
The switch_to function modifies the active ChatGPT proxy selection through the Clash API, which changes system/application routing behavior. While auto suggests automation, the script does not clearly warn in comments or help text that invoking it will actively change proxy configuration and persist state/log files.
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
# 切换节点
switch_to() {
local proxy="$1"
curl -s -X PUT -H "Authorization: Bearer ${CLASH_SECRET}" \
-H "Content-Type: application/json" \
-d "{\"name\":\"$proxy\"}" \
"${CLASH_API}/proxies/ChatGPT" >/dev/null 2>&1
This code presents its description, docstrings, and runtime/user-facing output in Chinese only, including installation guidance and operational messages. That creates a natural-language locale constraint without user opt-in or justification, which matches the language/locale policy violation criteria.
The top-level documentation says the script '优先选择美国/新加坡节点' (prefer U.S./Singapore nodes), but the actual PREFERRED_REGIONS array contains Singapore, Hong Kong, and Japan markers, with no U.S. entries. This is an active contradiction between documented intent and implemented selection logic, not just an omitted detail.
The script embeds a live Clash controller secret directly in source and uses it in Authorization headers for API calls. Hardcoded secrets are dangerous because anyone with access to the file, logs, backups, or repository can reuse the token to control the local proxy configuration, switch nodes, or inspect controller data; the risk is amplified because the usage output also prints the secret back to the terminal.
# Clash API 调用
clash_api_get() {
local endpoint="$1"
curl -s -H "Authorization: Bearer ${CLASH_SECRET}" "${CLASH_API}${endpoint}"
}
clash_api_put() {
The auto_switch flow changes the active proxy configuration automatically when health checks fail, which is a state-changing operation affecting system/network behavior. Although the script logs progress, it does not warn the user in usage/help text or request confirmation before changing the proxy, so the operational impact is not clearly disclosed as a potentially disruptive action.
The installation command uses npx clawdhub install clash-auto-switch without pinning a specific version, which means users may fetch whatever package version is current at install time. This creates a supply-chain risk: a compromised publisher account, malicious update, or unexpected breaking change could be pulled automatically and executed in the user's environment.
The guide instructs users to place CLASH_SECRET into a configuration file but does not warn that it is a sensitive credential or advise how to protect it. If that file is committed to source control, shared, logged, or exposed through local compromise, an attacker could use the secret to control the Clash API and alter proxy behavior.
The documentation encourages scheduled automatic execution of /clash auto, which changes proxy/network routing state without per-use confirmation or explicit safety notes. In practice this can silently redirect traffic, disrupt expected connectivity, or interfere with security/compliance assumptions about which network path is being used.
The skill documents automatic proxy switching but does not warn users that changing active proxy groups can disrupt ongoing connections, alter routing, or affect application behavior. In a networking skill, silent configuration changes are security-relevant because they can unexpectedly redirect traffic and interfere with user expectations about connectivity and session stability.
User-facing strings throughout the file, including installation guidance, error messages, help text, and operational status messages, are written only in Chinese. For a general-purpose skill, this creates a language/locale policy issue because the skill does not provide user opt-in, selection, or justification for restricting interactions to a single language.
This markdown file contains feature descriptions entirely in Chinese, which can constitute a language/locale policy issue when the skill documentation does not offer a user language choice or explain a required locale. The file does not indicate that the project is region-specific or that Chinese is an intentional, documented constraint.
The file is named README.md and includes an English language toggle link, but nearly all instructional content is written in Chinese. This can be a language/locale policy issue because users are not given an explicit language choice within the file content they open by default.
The documentation instructs users to supply a Clash API secret via command line or environment variables but provides no guidance on secure handling of that credential. This increases the risk of accidental exposure through shell history, logs, process inspection, screenshots, or insecure environment management, especially in shared or automated environments.
User-facing comments, status messages, and help output are all written in Chinese, with no option to select another language or locale. Under the stated policy, forcing a specific language without user opt-in is a natural-language policy concern.
The header comment explicitly lists '通知支持 - 切换成功/失败时发送通知' as a new feature. However, the script only logs to a file/stdout and updates a state file; there is no mail, webhook, desktop notification, or other notification mechanism anywhere in the code.
Comments and configuration define preferred regions as Singapore/Hong Kong/Japan, and later commands expose only US and Singapore regional switching. This imposes locale-specific behavior by default rather than presenting it as a user-selectable policy, which can conflict with language/locale choice expectations.
The region_switch function and usage help present U.S./Singapore as supported manual regions, but elsewhere the automatic-selection logic is documented as preferring U.S./Singapore while actually preferring Singapore/Hong Kong/Japan. This creates conflicting intent signals in the file about how regional preference works.
The natural-language instructions throughout the file are Chinese-only, and there is no indication that the user can choose another language or that the locale constraint is required for a region-specific purpose. Under the stated policy, forcing a specific language without user opt-in is a policy violation.
The documentation instructs users to configure an API secret via command line and environment variables but provides no warning that these values are sensitive and should not be logged, shared, or committed to files. This increases the chance of accidental credential exposure through shell history, screenshots, process listings, or configuration leakage.
The dependency is specified as requests>=2.28.0, which permits installation of many different future or older-compatible versions rather than a known-good release. This weakens reproducibility and can unintentionally pull in a vulnerable or breaking version during install, especially in automated environments.
requests>=2.28.0
No suspicious patterns detected.