Back to skill

Security audit

Claude Code Bridge

Security checks for vulnerabilities and agentic risk

Overview

This skill openly provides remote Claude Code terminal control from chat, but its broad passthrough, raw history exposure, weak session isolation, and persistent logs need careful review before installation.

Install only if you intend to give trusted chat participants remote control over a local Claude Code terminal. Avoid group chats and sensitive repositories unless access is tightly controlled, treat approvals as permission to run local commands or change files, and consider fixing session ID hashing, transcript permissions, CLAUDE_BIN launch handling, and generic key injection before use.

Vulnerability Patterns
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • 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
Findings (3)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/cc-bridge.sh:27
Finding
Environment-Controlled Command Injection Through CLAUDE_BIN<![CDATA[ ## Vulnerability Details **File Location**: `scripts/cc-bridge.sh`, lines 27 and 137-145 **Vulnerability Type**: Shell command injection **Risk Level**: High ### Vulnerable Code ```bash CLAUDE_BIN="${CLAUDE_BIN:-$HOME/.local/bin/claude}" ``` ```bash # 构建启动命令: # - unset CLAUDECODE/CLAUDE_CODE 防止 "nested session" 错误 # - export TERM 保证 CC 可以正常渲染 local launch_cmd launch_cmd="unset CLAUDECODE CLAUDE_CODE; export TERM=xterm-256color; exec '$CLAUDE_BIN'" # 在 tmux 中启动 claude # - set history-limit 为大滚动缓冲区,确保长会话不丢内容 tmux new-session -d -s "$TMUX_NAME" -x 220 -y 50 "bash --login -c '$launch_cmd'" ``` ### Technical Analysis The script permits the `CLAUDE_BIN` environment variable to override the expected Claude Code executable. It then interpolates that value into `launch_cmd`, which is embedded inside another command string passed to `bash --login -c`. The single quotes around `CLAUDE_BIN` do not provide a reliable security boundary because the resulting string is subsequently nested inside another single-quoted shell command. A malicious value containing quote characters and shell metacharacters can terminate the intended quoting context and append arbitrary commands. This is a command-construction vulnerability: untrusted or insufficiently validated data becomes shell syntax instead of remaining a single executable-path argument. ### Attack Path 1. An attacker gains influence over the environment used to launch OpenClaw or the bridge, such as through a service configuration, wrapper script, deployment variable, compromised shell initialization, or another environment-injection weakness. 2. The attacker sets `CLAUDE_BIN` to a value containing quote-breaking syntax and an additional shell command. 3. A user or agent invokes: ```bash cc-bridge.sh "<session_id>" start ``` 4. `do_start` interpolates the malicious value into `launch_cmd`. 5. The nested `bash --login -c` evaluates the injected syntax. 6. The attacker's comm ...[truncated 614 chars]
Remediation
<![CDATA[ ## Remediation Suggestions - Do not build a nested shell command by concatenating `CLAUDE_BIN`. - Validate that the configured executable is an absolute path to an expected, executable regular file. - Reject values containing control characters or shell syntax rather than attempting to escape them manually. - Prefer passing the executable as a positional parameter so it remains data: ```bash [[ "$CLAUDE_BIN" == /* ]] || { echo "[cc-bridge] CLAUDE_BIN must be an absolute path" >&2 return 1 } [[ -f "$CLAUDE_BIN" && -x "$CLAUDE_BIN" ]] || { echo "[cc-bridge] CLAUDE_BIN is not an executable file" >&2 return 1 } tmux new-session -d -s "$TMUX_NAME" -x 220 -y 50 \ env -u CLAUDECODE -u CLAUDE_CODE TERM=xterm-256color \ "$CLAUDE_BIN" ``` - If a login shell is strictly required, supply the executable through a positional parameter rather than interpolating it: ```bash tmux new-session -d -s "$TMUX_NAME" -x 220 -y 50 \ bash --login -c 'unset CLAUDECODE CLAUDE_CODE; export TERM=xterm-256color; exec "$1"' \ cc-bridge "$CLAUDE_BIN" ``` - Consider removing the environment override entirely when runtime configurability is unnecessary. - Run the bridge under a dedicated, least-privileged operating-system account. ]]>

T05 · Unauthorized Access and Privilege Escalation

Error
Location
scripts/cc-bridge.sh:42
Finding
Session Identifier Collisions Allow Cross-Chat Session Access<![CDATA[ ## Vulnerability Details **File Location**: `scripts/cc-bridge.sh`, lines 42-47 **Vulnerability Type**: Insecure session isolation and identifier collision **Risk Level**: High ### Vulnerable Code ```bash # 把任意 session_id 变成合法 tmux 名(字母数字下划线,<=20字符) SAFE_ID="$(echo "$SESSION_ID" | tr -cd '[:alnum:]_' | cut -c1-20)" TMUX_NAME="ccb_${SAFE_ID}" LOG_FILE="$STATE_DIR/${TMUX_NAME}.log" OFFSET_FILE="$STATE_DIR/${TMUX_NAME}.offset" ``` ### Technical Analysis The bridge derives the security-sensitive tmux session name and state-file names by deleting every character outside the accepted set and truncating the result to 20 characters. This transformation is not injective. Multiple distinct source identifiers can produce the same `SAFE_ID`. For example: - Identifiers that differ only through removed punctuation collapse to the same value. - Identifiers sharing the first 20 retained characters collide after truncation. - Punctuation-only identifiers collapse to an empty value and use `ccb_`. All bridge actions use the derived name to locate the tmux session. Consequently, colliding chat identifiers share the same Claude Code process, transcript, and output offset. No separate ownership mapping verifies that the caller's original channel and chat identifier created the target session. ### Attack Path 1. A victim chat starts a Claude Code session. 2. Another chat receives or supplies a distinct session identifier that sanitizes to the same first 20 retained characters. 3. The second chat invokes an action such as `status`, `send`, `approve`, `peek`, `history`, `restart`, or `stop`. 4. The script derives the same `TMUX_NAME`, `LOG_FILE`, and `OFFSET_FILE` used by the victim. 5. The action is executed against the victim's active Claude Code session. 6. The second chat can inject prompts, inspect terminal output, approve pending operations, disrupt the session, or terminate it. ### Impact Assessment A successful collision breaks the documented isolation betw ...[truncated 656 chars]
Remediation
<![CDATA[ ## Remediation Suggestions - Reject invalid identifiers instead of silently deleting characters: ```bash if [[ ! "$SESSION_ID" =~ ^[A-Za-z0-9_]+$ ]]; then echo "[cc-bridge] Invalid session identifier" >&2 exit 1 fi ``` - Do not use truncation alone to construct a security-sensitive identifier. - Derive the tmux name from a collision-resistant digest of the complete channel and chat identifier: ```bash SESSION_HASH="$(printf '%s' "$SESSION_ID" | sha256sum | awk '{print $1}')" TMUX_NAME="ccb_${SESSION_HASH:0:32}" ``` On systems without `sha256sum`, use an equivalent trusted hashing utility. - Include both the channel and full chat identifier in the hashed input, with unambiguous separators. - Store a protected ownership record mapping the generated tmux name to the exact original identifier. - Before every action, verify that the requesting conversation matches the ownership record. - Reject empty identifiers and fail closed if ownership metadata is missing or inconsistent. - Add tests covering punctuation variants, identifiers longer than 20 characters, Unicode input, empty input, and deliberately colliding prefixes. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/cc-bridge.sh:28
Finding
Terminal Transcripts May Be Created With Excessive Filesystem Permissions<![CDATA[ ## Vulnerability Details **File Location**: `scripts/cc-bridge.sh`, lines 28-47, 125-127, and 150-151 **Vulnerability Type**: Insecure storage of sensitive terminal output **Risk Level**: Medium ### Vulnerable Code ```bash STATE_DIR="$HOME/.openclaw/cc-bridge" SCROLLBACK_LINES=50000 # tmux 滚动缓冲区大小 STABLE_INTERVAL=0.8 # 轮询间隔(秒) STABLE_NEEDED=3 # 连续稳定次数 DEFAULT_TIMEOUT=90 # 默认最长等待(秒) LONG_TIMEOUT=300 # 长任务最长等待(秒) mkdir -p "$STATE_DIR" ``` ```bash # 把任意 session_id 变成合法 tmux 名(字母数字下划线,<=20字符) SAFE_ID="$(echo "$SESSION_ID" | tr -cd '[:alnum:]_' | cut -c1-20)" TMUX_NAME="ccb_${SAFE_ID}" LOG_FILE="$STATE_DIR/${TMUX_NAME}.log" OFFSET_FILE="$STATE_DIR/${TMUX_NAME}.offset" ``` ```bash # 清理旧日志 > "$LOG_FILE" echo "0" > "$OFFSET_FILE" ``` ```bash # 通过 pipe-pane 把所有输出追加到日志(用于 wait_for_stable_output 的 size 检测) tmux pipe-pane -t "$TMUX_NAME" -o "cat >> '$LOG_FILE'" ``` ### Technical Analysis The bridge stores Claude Code terminal output in persistent log files under `$HOME/.openclaw/cc-bridge`. Neither the directory nor the files are assigned explicit restrictive permissions, and the script does not set a secure `umask`. Their effective permissions therefore depend on the environment from which OpenClaw was launched. With a permissive or common `umask`, the directory and transcript files may be readable by other local users or service accounts. The logs can contain source code, command output, file contents, project paths, operational details, and secrets accidentally displayed by Claude Code or subprocesses. The offset files are less sensitive, but they share the same insecure creation pattern. In addition, storing a complete stream through `tmux pipe-pane` expands the amount of sensitive data retained on disk. ### Attack Path 1. OpenClaw starts the bridge under an account with a permissive `umask`. 2. The script creates the state directory, transcript, and offset files without explicit ...[truncated 913 chars]
Remediation
<![CDATA[ ## Remediation Suggestions - Set a restrictive `umask` before creating any state: ```bash umask 077 ``` - Create and verify the state directory with owner-only permissions: ```bash install -d -m 700 "$STATE_DIR" ``` - Create transcript and offset files with mode `0600`, using safe creation semantics: ```bash install -m 600 /dev/null "$LOG_FILE" printf '0\n' > "$OFFSET_FILE" chmod 600 "$OFFSET_FILE" ``` - Verify that `$STATE_DIR` is owned by the current user and is not a symbolic link before writing files. - Minimize transcript retention. If logs are needed only for output-stability detection, consider a mechanism that does not persist complete terminal contents. - Delete logs promptly when sessions end and implement bounded rotation for crashed or abandoned sessions. - Document that terminal output may contain secrets and avoid printing credentials in Claude Code sessions. - Run OpenClaw under a dedicated account whose home directory is not accessible to unrelated users. ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (13)

Ssd 3

High
Confidence
98% confidence
Finding
The skill instructs the agent to route every incoming message to a persistent CLI session whenever CC mode is active, effectively turning the chat channel into a remote terminal input path. Because the same session persists across turns and users can later inspect state via peek/history, accidental secrets, unrelated chat content, or prior session data can be exposed or acted upon out of context.

Ssd 3

High
Confidence
97% confidence
Finding
The skill exposes raw terminal screen and history contents back into chat through plain-language workflows, which can leak secrets, file contents, command output, environment data, or prior conversation context. In group chats or shared channels, this materially increases the chance of unauthorized disclosure beyond the original terminal environment.

Missing User Warnings

Medium
Confidence
95% confidence
Finding
The README explicitly markets arbitrary message forwarding into a real interactive Claude Code terminal session, but does not prominently warn that this gives remote chat participants a path to trigger command execution, file reads/writes, git operations, and other host-side actions through the bridged CLI. In the context of group chats or compromised messaging accounts, this can materially increase the chance of unsafe use because users may treat the bridge like a harmless chatbot rather than remote terminal control.

Missing User Warnings

Medium
Confidence
92% confidence
Finding
The README describes features like peek/history and relaying terminal output back to chat channels, but does not clearly warn that terminal contents, conversation history, file excerpts, command output, secrets, and other sensitive local data may be transmitted through third-party messaging services. This omission is risky because users may unknowingly expose private project data or credentials to external chat infrastructure, chat logs, or other chat participants.

Missing User Warnings

Medium
Confidence
94% confidence
Finding
The skill advertises remote approval handling for Claude Code actions but does not clearly warn that approvals may authorize system-modifying operations such as file edits, command execution, or other tool actions. A user approving from a chat app may not understand the scope of what they are authorizing, increasing the risk of unsafe remote actions.

Missing User Warnings

Medium
Confidence
96% confidence
Finding
The skill transparently forwards ordinary chat messages into a persistent Claude Code terminal session, but the description does not clearly warn users that their messages may be injected into a live CLI and retained in terminal/session history. This creates a consent and data-exposure risk because users may share sensitive content in chat without realizing it is being passed to tools and exposed in ongoing terminal context.

Ssd 3

Medium
Confidence
90% confidence
Finding
The long-task workflow explicitly tells the agent to inspect active terminal state and provide progress updates from CLI output back into chat. This increases the exposure window for sensitive intermediate output and may reveal partial results, internal paths, or tool output that was never intended for broad chat distribution.

Missing User Warnings

Medium
Confidence
91% confidence
Finding
The documentation explicitly says that all messages in CC mode are forwarded to Claude Code and that users can approve command execution and file read/write actions, but it does not clearly warn about privacy, data exfiltration, or system-impact risks. In this skill’s context, bridging a chat interface to a persistent CLI session increases danger because users may casually send sensitive data or approve destructive actions from a mobile or group chat without understanding the consequences.

Natural-Language Policy Violations

Medium
Confidence
93% confidence
Finding
This shell script includes natural-language usage text entirely in Chinese, including invocation guidance such as the expected phrases for starting or stopping the session. Under the policy, forcing a specific language without user opt-in is a natural-language policy violation unless the locale restriction is explicitly justified, which is not present here.

Description-Behavior Mismatch

Medium
Confidence
95% confidence
Finding
The script exposes `interrupt` and especially `key` operations that turn the chat bridge into a remote terminal/TUI controller, not just a Claude Code session manager. In this skill context, any chat-originated user who can invoke the bridge may manipulate the live CLI state machine and approve, cancel, navigate, or trigger actions that exceed the manifest’s narrower approval-and-message-routing purpose.

Natural-Language Policy Violations

Medium
Confidence
90% confidence
Finding
The messages instruct users to send Chinese phrases like "关闭cc" and "启动cc" to control the skill, which imposes a language-specific interaction pattern. Because no language choice or justification is provided, this conflicts with the language/locale policy for natural-language behavior.

Context-Inappropriate Capability

Medium
Confidence
98% confidence
Finding
The `do_key` handler permits broad special-key injection including navigation keys, control keys, and alt/meta combinations into a persistent tmux-hosted Claude Code session. This effectively grants remote interactive control over the terminal UI, enabling bypass of intended approval workflows, unintended command execution paths, or manipulation of prior prompts/history through a chat interface that may be weaker than a local shell trust boundary.

Natural-Language Policy Violations

Low
Confidence
82% confidence
Finding
SQP-3 covers natural-language policy violations across all file types, including forcing a specific language without user opt-in. This usage file presents all instructions and interaction guidance only in Chinese, with no indication of alternate language support or user choice.

Static analysis

No suspicious patterns detected.