Back to skill

Security audit

Claude Code 接入第三方模型

Security checks for vulnerabilities and agentic risk

Overview

ClawScan marked this skill suspicious because scanners report an unauthenticated route to a tool-capable agent and several risks involving credentials, process control, and sensitive diagnostics.

Consider not installing this skill unless you need its gateway and profile-switching features and can accept the reported risks. In particular, review the unauthenticated agent bridge, how credentials and diagnostic logs are handled, and whether the gateway can affect other processes. The scan is incomplete: it covered 80% of components, the tool-misuse analyzer was degraded, and some content was excluded or only partially analyzed.

Vulnerability Patterns
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • 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)

T05 · Unauthorized Access and Privilege Escalation

Error
Location
scripts/zen_bridge.py
Finding

Unauthenticated bridge exposes the owner's tool-capable OpenCode agent

Content
View full analysis

Impact

An unauthorized caller can induce agent-mediated access to the owner's project files and receive resulting text through the completion response. File modification and command execution depend on the configured OpenCode agent permissions; unrestricted execution was not independently verified. Where paid providers are configured, the same unauthenticated route also permits unauthorized model usage.

Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Output HandlingUnvalidated Output Injection, Cross-Context Output, Unbounded Output
  • System Prompt LeakageDirect Leakage, Indirect Extraction, Tool-Based Exfiltration
  • Rogue AgentSelf-Modification, Session Persistence
Findings (43)

Agent Config Directory Access

High
Category
Agent Snooping
Confidence
91% confidence
Finding

The command retrieves the currently configured authentication token and the following loop sends it to a hard-coded DeepSeek endpoint without checking its associated base URL. Because this skill switches among multiple providers and local gateways, the token may belong to a different service and be disclosed to the wrong recipient.

Content

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

再拿候选名逐个打 Anthropic 兼容端点(这才是权威,/models 常漏别名):

bash
KEY=$(python -c "import json;print(json.load(open(r'C:/Users/<u>/.claude/settings.json'))['env']['ANTHROPIC_AUTH_TOKEN'])")
for M in "deepseek-flash" "deepseek-flash[1m]" "deepseek-v4-flash" "deepseek-chat" "deepseek-v4.1-flash"; do
  printf '%-24s => ' "$M"
  curl -s -m 45 https://api.deepseek.com/anthropic/v1/messages \

External Script Fetching

High
Category
Supply Chain
Confidence
90% confidence
Finding

Remote code is downloaded and executed. This bypasses code review and could introduce malicious code.

Content

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

md
KEY=$(python -c "import json;print(json.load(open(r'C:/Users/<u>/.claude/settings.json'))['env']['ANTHROPIC_AUTH_TOKEN'])")
for M in "deepseek-flash" "deepseek-flash[1m]" "deepseek-v4-flash" "deepseek-chat" "deepseek-v4.1-flash"; do
  printf '%-24s => ' "$M"
  curl -s -m 45 https://api.deepseek.com/anthropic/v1/messages \
    -H "x-api-key: $KEY" -H "anthropic-version: 2023-06-01" -H "content-type: application/json" \
    -d "{\"model\":\"$M\",\"max_tokens\":8,\"messages\":[{\"role\":\"user\",\"content\":\"hi\"}]}" \
    | python -c "import sys,json;d=json.load(sys.stdin);print('OK ->',d['model'] if 'model' in d else 'ERR '+str(d.get('error',{}).get('message'))[:160])"

Agent Config Directory Access

High
Category
Agent Snooping
Confidence
90% confidence
Finding

Skill reads from agent configuration directories (.claude/, .codex/, .gemini/). These directories may contain API keys, personal settings, and other credentials that the skill has no legitimate need to access.

Content

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

Step 3 · 配置模板

~/.claude/settings.json(用户级、跨项目,是唯一真相源):

json
{

Agent Config Directory Access

High
Category
Agent Snooping
Confidence
90% confidence
Finding

Skill reads from agent configuration directories (.claude/, .codex/, .gemini/). These directories may contain API keys, personal settings, and other credentials that the skill has no legitimate need to access.

Content

Scanner excerpt · scripts/ccswitch.py (reported line 21)May include surrounding context.

python
How it works:
    A profile is a JSON file in ~/.claude/profiles/<name>.json that fully
    describes Claude Code's settings.json for that upstream. Switching =
    copy profile -> ~/.claude/settings.json, then reconcile the gateway:

      * profile whose ANTHROPIC_BASE_URL points at 127.0.0.1:<gateway port>
        => local ccproxy gateway MUST be running -> start if down

Agent Config Directory Access

High
Category
Agent Snooping
Confidence
99% confidence
Finding

Reading agent configuration is necessary for this skill, but these commands display complete settings and explicitly print primaryApiKey and env values. Credentials can consequently enter tool output, conversation history, and upstream model requests even if the final response omits them.

Content

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

except FileNotFoundError: pass "

2) 项目级覆盖(优先级高于用户级)

cat .claude/settings.json .claude/settings.local.json 2>/dev/null

3) ~/.claude.json 里的 model / env 字段

python -c "import json;d=json.load(open(r'C:/Users//.claude.json'));print({k:d[k] for k in ('model','env','primaryApiKey') if k in d})"

text

Agent Config Directory Access

High
Category
Agent Snooping
Confidence
90% confidence
Finding

Skill reads from agent configuration directories (.claude/, .codex/, .gemini/). These directories may contain API keys, personal settings, and other credentials that the skill has no legitimate need to access.

Content

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

md
## 收尾清单

- [ ] 改前备份:`cp ~/.claude/settings.json ~/.claude/backups/settings.json.bak-$(date +%Y%m%d-%H%M%S)`;
      若要动 HKCU,先把变量导出一份 json 到同目录。
- [ ] 改后**必须**跑 Step 5 验证主模型 + 子代理模型,不能只看配置文件。
- [ ] 报告里**不要回显 API Key**,只说前缀 + 长度。

Agent Config Directory Access

High
Category
Agent Snooping
Confidence
90% confidence
Finding

Skill reads from agent configuration directories (.claude/, .codex/, .gemini/). These directories may contain API keys, personal settings, and other credentials that the skill has no legitimate need to access.

Content

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

text
claude --model / --effort 等命令行参数
      >  ~/.claude/settings.json 的 env 块
      >  shell / 系统 继承来的环境变量

Agent Config Directory Access

High
Category
Agent Snooping
Confidence
90% confidence
Finding

Skill reads from agent configuration directories (.claude/, .codex/, .gemini/). These directories may contain API keys, personal settings, and other credentials that the skill has no legitimate need to access.

Content

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

md
## Step 14 · 单一配置源(Single Source of Truth)

**结论:配置只写在 `~/.claude/settings.json`,不要同时在 Windows 环境变量里放一份。**

理由(实测):
1. **环境变量那份根本不起作用**。`settings.json` 的 `env` 块优先级更高(Step 5),

Env Variable Harvesting

High
Category
Data Exfiltration
Confidence
70% confidence
Finding

Code enumerates, copies, or searches environment variables for secrets. Bulk environment access can collect credentials unrelated to the skill's stated purpose.

Content

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

python
import os, subprocess, re
env = {k:v for k,v in os.environ.items()
       if not (k.upper().startswith("ANTHROPIC") or k.upper().startswith("CLAUDE_CODE"))}
p = subprocess.run([r"C:/Users/<u>/AppData/Roaming/npm/claude.cmd",
                    "-p", "hi", "--output-format", "json"],

Agent Config Directory Access

High
Category
Agent Snooping
Confidence
90% confidence
Finding

The prescribed switch operation replaces the entire user-level settings file with a model profile rather than updating only model-related fields. Minimal or stale profiles can consequently remove unrelated security permissions or hooks across projects; backing up the old file enables recovery but does not prevent the changed security behavior.

Content

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

md
## 设计(可直接照搬到别的工具)

1. **profile 即模板**:`~/.claude/profiles/<name>.json` 存一份完整的 Claude Code
   `settings.json`;切换 = 复制覆盖 `~/.claude/settings.json`。
2. **切前必备份**:旧文件存 `~/.claude/backups/settings.json.bak-<时间戳>`;
   与目标内容相同则跳过(不刷屏)。
3. **是否需要网关由配置自身推出**,不靠额外元数据:

Direct Prompt Extraction

High
Category
System Prompt Leakage
Confidence
85% confidence
Finding

Skill contains instructions that could directly expose system prompts, internal rules, or hidden instructions to users or external parties.

Content

Scanner excerpt · scripts/ccproxy.py (reported line 1282)May include surrounding context.

python
oa_req = anthropic_to_openai(req)
except Exception as e:
self._send_error_anthropic(400, "invalid_request_error", "translate: %s" % e)
return
prompt_chars = sum(len(str(m.get("content", ""))) for m in oa_req["messages"])
model_for_reply = req.get("model") or CONFIG["upstream"].get("model")
# Guide tip 6: a turn this large means the next cache miss is expensive

Env Variable Harvesting

High
Category
Data Exfiltration
Confidence
60% confidence
Finding

Code enumerates, copies, or searches environment variables for secrets. Bulk environment access can collect credentials unrelated to the skill's stated purpose.

Content

Scanner excerpt · scripts/ccswitch.py (reported line 320)May include surrounding context.

python
ensure_shared_token()
    port = GW_PORT if port is None else int(port)
    GATEWAY_LOG.parent.mkdir(parents=True, exist_ok=True)
    env = os.environ.copy()
    for k in ("HTTP_PROXY", "HTTPS_PROXY", "http_proxy", "https_proxy",
              "ALL_PROXY", "all_proxy"):
        env.pop(k, None)

Env Variable Harvesting

High
Category
Data Exfiltration
Confidence
60% confidence
Finding

Code enumerates, copies, or searches environment variables for secrets. Bulk environment access can collect credentials unrelated to the skill's stated purpose.

Content

Scanner excerpt · scripts/ccswitch.py (reported line 429)May include surrounding context.

python
if not ZEN_BRIDGE.exists():
        die("zen_bridge.py not found: %s - install it next to ccproxy.py"
            % ZEN_BRIDGE)
    env = os.environ.copy()
    for k in ("HTTP_PROXY", "HTTPS_PROXY", "http_proxy", "https_proxy",
              "ALL_PROXY", "all_proxy"):
        env.pop(k, None)

External Transmission

Medium
Category
Data Exfiltration
Confidence
60% 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 · SKILL.md (reported line 36)May include surrounding context.

先看账号可用清单:

bash
curl -s https://api.deepseek.com/models -H "Authorization: Bearer $KEY"

再拿候选名逐个打 Anthropic 兼容端点(这才是权威,/models 常漏别名):

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 · SKILL.md (reported line 36)May include surrounding context.

先看账号可用清单:

bash
curl -s https://api.deepseek.com/models -H "Authorization: Bearer $KEY"

再拿候选名逐个打 Anthropic 兼容端点(这才是权威,/models 常漏别名):

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 · SKILL.md (reported line 82)May include surrounding context.

md
{
  "$schema": "https://json.schemastore.org/claude-code-settings.json",
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.deepseek.com/anthropic",
    "ANTHROPIC_AUTH_TOKEN": "<KEY>",
    "ANTHROPIC_MODEL": "deepseek-flash[1m]",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "deepseek-flash[1m]",

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 · examples/profiles/deepseek.json (reported line 5)May include surrounding context.

json
"$schema": "https://json.schemastore.org/claude-code-settings.json",
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "sk-YOUR-DEEPSEEK-KEY-HERE",
    "ANTHROPIC_BASE_URL": "https://api.deepseek.com/anthropic",
    "ANTHROPIC_DEFAULT_FABLE_MODEL": "deepseek-flash[1m]",
    "ANTHROPIC_DEFAULT_FABLE_MODEL_NAME": "deepseek-flash",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "deepseek-flash",

External Transmission

Medium
Category
Data Exfiltration
Confidence
91% confidence
Finding

This is the transmission side of the credential-binding issue at line 42: the probe sends the active configuration's token to DeepSeek regardless of which provider issued it. In a multi-provider switching skill, that assumption can expose another provider's credential or a local gateway token to an unintended recipient.

Content

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

md
KEY=$(python -c "import json;print(json.load(open(r'C:/Users/<u>/.claude/settings.json'))['env']['ANTHROPIC_AUTH_TOKEN'])")
for M in "deepseek-flash" "deepseek-flash[1m]" "deepseek-v4-flash" "deepseek-chat" "deepseek-v4.1-flash"; do
  printf '%-24s => ' "$M"
  curl -s -m 45 https://api.deepseek.com/anthropic/v1/messages \
    -H "x-api-key: $KEY" -H "anthropic-version: 2023-06-01" -H "content-type: application/json" \
    -d "{\"model\":\"$M\",\"max_tokens\":8,\"messages\":[{\"role\":\"user\",\"content\":\"hi\"}]}" \
    | python -c "import sys,json;d=json.load(sys.stdin);print('OK ->',d['model'] if 'model' in d else 'ERR '+str(d.get('error',{}).get('message'))[:160])"

Session Persistence

Medium
Category
Rogue Agent
Confidence
65% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

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

md
- 用同目录 `tag.txt` 给每一轮实验打标签,避免多次运行串味。
- `ANTHROPIC_BASE_URL` 支持 `http://`,指向 127.0.0.1 时记得把 `NO_PROXY` 加上 `127.0.0.1`。

**⚠️ 最大坑**:在 Bash 工具里用 `nohup ... &` 起的中继会**随该次命令的进程组一起被杀**,
表现为「Claude Code 连不上 → 一直重试 → 看起来像卡死」,
而且因为 SIGTERM 打断管道,**连报错都看不到**。
必须用工具自带的后台运行能力(`run_in_background`)启动长驻进程。

Session Persistence

Medium
Category
Rogue Agent
Confidence
65% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

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

md
**排查这条坑时踩到的两个环境陷阱(都不是代码问题,别误判成 bug)**:

- **`nohup ... &` 启动的进程会随工具 shell 退出被回收**。日志停在最后一行、
  端口无监听、`/health` 返回 502 —— 看起来像"网关又挂了"。
  工具里必须用后台任务方式启动(`run_in_background`)才活得久。
- ~~上游 `User-Agent` 不是断流原因~~。实测无 UA / 浏览器 UA / 诚实 UA

Session Persistence

Medium
Category
Rogue Agent
Confidence
65% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

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

启动

网关必须常驻,且不能用 nohup ... &(会随命令进程组被杀,见 Step 8)。 用工具自带的后台运行能力起,或给用户建启动器(本机已固化,见第六 / 七部分):

bash

The launcher workflow force-terminates the process occupying a port without warning about unrelated processes or interrupted work.

Medium
Category
Output Handling
Confidence
99% confidence
Finding

The launcher force-kills whichever listening process occupies the configured port without verifying that it is a gateway owned by this workflow. An unrelated service can therefore be terminated, interrupting work or losing unsaved state; a port number is not a reliable process identity.

Content

No source excerpt is available for this finding.

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 · SKILL.md (reported line 882)May include surrounding context.

md
- Anthropic 协议 Base URL(Claude Code 用这个):`https://open.bigmodel.cn/api/anthropic`
  - ⚠️ 末尾**不要加 `/v1`**——Claude Code 会自动拼 `/v1/messages`,拼成
    `https://open.bigmodel.cn/api/anthropic/v1/messages`(这正是智谱的正确路径)。
  - 国际站 z.ai 同协议:`https://api.z.ai/api/anthropic`(Key 用 z.ai 平台发的)。
- API Key:`https://open.bigmodel.cn/usercenter/apikeys` 创建。
  填进 `ANTHROPIC_AUTH_TOKEN`(即 Key 本身,CC 会带 `x-api-key` 头,别加 `Bearer `)。
- 模型 ID(小写,OpenAI/Anthropic 端点通用):

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 · SKILL.md (reported line 1010)May include surrounding context.

md
| **OpenCode Zen** | `https://opencode.ai/zen/v1/chat/completions` | `deepseek-v4.1-flash-free` | **免 key(匿名)** | ✅ 现役,但**必须走 opencode SDK**(见第八部分) |
| OpenCode Zen | 同上 | `space-bunny-free` | 免 key | ✅ **实测仍可用**(2026-10-16,profile `zen-space-bunny`,端口 3463);早前「已下线」的记录有误 |
| OpenRouter | `https://openrouter.ai/api/v1/chat/completions` | `stealth/space-bunny-alpha` | 需 key(注意:整段 `:free` 后缀会 404) | ❌ 随模型下线 |
| AI/ML API | `https://api.aimlapi.com/v1/chat/completions` | `stealth/space-bunny-alpha` | 需 key | ❌ 随模型下线 |

- **Zen 免 key 的代价(2026-10-16 实测)**:Zen 免费层**只接受从 opencode 客户端/SDK 发出的
  请求**。匿名直连 endpoint 会 `FreeTierError: only used from within OpenCode`,

Request-capture diagnostics lack a warning about persisting sensitive conversation content and authentication headers.

Medium
Category
Output Handling
Confidence
99% confidence
Finding

The diagnostics enable request capture and explicitly print axios request headers, which can contain Authorization or API-key credentials. Complete request bodies can also expose proprietary code and conversation content through persistent logs and agent transcripts; the separate instruction not to repeat keys in the final report does not prevent these earlier disclosures.

Content

No source excerpt is available for this finding.