A sophisticated malware campaign on the npm repository has revealed a major blind spot in conventional software supply chain defenses. Researchers have identified that attackers are now embedding malicious code directly into a package’s normal runtime functions, allowing malware to bypass standard installation-time security scans.

The campaign, analyzed in a BleepingComputer report, centers on the indexed-btree package. This method marks a notable evolution from earlier supply chain attacks that typically relied on postinstall scripts—automated scripts executed upon package installation. Security tools and developer workflows have long focused on scrutinizing these install scripts, which can create a false sense of security: a package that appears clean during installation is often presumed safe at runtime.

This approach subverts that assumption. Instead of isolating malicious code in a dedicated install script, the actors have woven it into the package's core logic. The harmful payload executes as part of the package's legitimate, expected functionality. As a result, traditional defenses designed to flag suspicious install-time behavior will fail to detect it. The malicious code only activates when the application invokes the infected functions, placing it outside the scope of initial dependency reviews.

This technique fundamentally challenges current dependency vetting processes. A "clean installation" scan is no longer a reliable indicator of a safe package. The malicious code remains indistinguishable from legitimate logic until the moment of execution.

To counter this evasion tactic, development and security teams must adopt more dynamic and comprehensive auditing practices. The report from BleepingComputer outlines several actionable mitigation steps:

  1. Profile Dependencies During Test Execution: Integrate analysis tools into your CI/CD pipeline to monitor which code actually runs when your test suite executes. This runtime profiling can uncover unexpected network calls, file system access, or CPU-intensive operations triggered by dependencies.
  2. Map and Review Full Dependency Trees: Scrutinize not only direct dependencies but also the entire tree of sub-dependencies. Use tools like npm audit or dedicated software composition analysis (SCA) solutions to inspect transitive dependencies, where such malicious code is frequently hidden.
  3. Enforce Least-Privilege Sandboxing: Execute applications and their dependency installation scripts in sandboxed, non-privileged environments. This containment strategy limits the potential damage a malicious package can inflict if it runs.
  4. Monitor Runtime Network Activity: Vigilantly track outgoing network connections from your applications. Malware often requires a "call home" to a command-and-control server, and unusual network traffic is a key indicator of compromise.

This campaign underscores that modern supply chain security must move beyond install-time gatekeeping. Defending against advanced evasion requires continuous monitoring and scrutiny throughout the entire software lifecycle, from development through to production runtime.


npm 套件儲存庫中一場精密惡意軟件攻擊活動,揭示了傳統軟件供應鏈防禦的重大盲點。研究人員發現,攻擊者現在將惡意代碼直接嵌入套件的正常運行時功能中,使惡意軟件能繞過標準的安裝時安全掃描。

根據 BleepingComputer 報告分析,此次攻擊活動以 indexed-btree 套件為核心。此手法標誌著相較於早期供應鏈攻擊的顯著演進——過去攻擊通常依賴 postinstall 腳本,即套件安裝時自動執行的腳本。安全工具和開發者工作流程長期專注於審查這些安裝腳本,這可能造成虚假的安全感:安裝期間看似乾淨的套件,常被預設為運行時安全。

此手法顛覆了上述假設。攻擊者未將惡意代碼隔離在專用安裝腳本中,而是將其編織進套件的核心邏輯。有害載荷作為套件合法預期功能的一部分執行,導致傳統針對可疑安裝時行為設計的防禦機制無法偵測。惡意代碼僅在應用程式調用受感染函數時才啟動,使其超出初始依賴項審查的範圍。

此技術根本性挑戰了現行的依賴項審核流程。「乾淨安裝」掃描不再是安全套件的可靠指標。惡意代碼在執行前一刻仍與合法邏輯無異。

為應對此迴避策略,開發與安全團隊必須採取更動態且全面的審計實踐。BleepingComputer 報告概述了幾項可行緩解措施:

  1. 於測試執行期間分析依賴項: 將分析工具整合至 CI/CD 流程中,監控測試套件執行時實際運行的代碼。這種運行時分析可發現依賴項觸發的意外網絡調用、文件系統訪問或 CPU 密集型操作。
  2. 繪製並審核完整依賴樹: 嚴格審查直接依賴項及所有子依賴項的完整樹狀結構。使用 npm audit 或專用軟件成分分析(SCA)解決方案檢查傳遞性依賴項——惡意代碼常藏匿於此。
  3. 強制最小權限沙箱化: 在受隔離、非特權環境中執行應用程式及其依賴項安裝腳本。此遏制策略可限制惡意套件若運行可能造成的潛在損害。
  4. 監控運行時網絡活動: 警覺追蹤應用程式發出的網絡連接。惡意軟件通常需「回連」指揮控制服務器,異常網絡流量是遭入侵的關鍵指標。

此攻擊活動強調,現代供應鏈安全必須超越安裝時的閘道防護。防禦先進迴避手段需要在整個軟件生命週期中,從開發到生產運行時,持續監控與審查。

新聞來源 / Original News Source