應該不少人都有跟到三週前 VS Code 上的知名套件 Material Theme 被微軟主動下架的新聞,那下架的理由是什麼呢?根據你得知這件事的消息來源以及自身個性,可能會有兩種回答:
- 它「疑似」含有惡意程式碼
- 它就是個惡意軟體
為什麼跟自身個性有關呢?因為就算消息來源接收到的是第一種,在種種條件的互相加持影響之下,你也很有可能解釋成第二種。
以台灣的消息來源來說,最多人看到的應該是保哥的這篇臉書貼文,內文寫著:
微軟緊急下架擁有 900 萬次下載的知名 Material Theme Icons 與 Material Theme Free 擴充套件,這些看似無害的佈景主題擴充被發現暗藏高度混淆的惡意代碼,可能導致大規模開發者帳戶資料外洩!
🔥
事件關鍵點:
1️⃣ 網路安全研究員 Amit Assaraf 團隊在例行掃描中發現,這些主題擴展中的 release-notes.js 檔案存在大量混淆過的 JavaScript 程式,其中包含對使用者名稱、密碼等敏感資訊的存取。2️⃣ 專家推測這可能是透過 2023 年某次更新植入的供應鏈攻擊,或開發者帳號遭黑客劫持所致。
微軟不僅下架了所有相關擴充套件,還直接封鎖了開發者 Mattia Astorino (equinusocio) 的帳號,並強制卸載全球使用者端已安裝的擴充套件。這是 VS Marketplace 近三年來最大規模的安全清理行動!👍
附件連結是 GitHub Issues 討論,非常熱鬧,愛吃瓜的鄉民快去朝聖啊!👨💻
#還好我不愛Material #供應鏈攻擊 #記得VSCode連網升級一下
內文寫了「被發現暗藏高度混淆的惡意代碼」,直接認定是惡意軟體了。再加上文中附上的其他證據,混淆過的程式碼以及對敏感資訊的存取等等,還主動被微軟下架,不覺得是惡意軟體都難。
而底下留言附的資安人報導《資安風險!微軟禁下載量達900萬次的VSCode Material Theme擴充套件》 中,寫的就相對保守一點:
微軟近日從Visual Studio Marketplace中移除了兩個廣受歡迎的VSCode擴充套件:「Material Theme – Free」和「Material Theme Icons – Free」,原因是這些擴充套件被發現可能包含惡意程式碼。
用的字眼是「可能包含惡意程式碼」,就是我所說的第一種。但與上面的貼文類似,報導中還說明有資安團隊發現了可疑的程式碼,又混淆又跟帳號密碼有關。因此,儘管報導本身並沒有明確寫出它就是個惡意軟體,只有寫「可能包含惡意程式碼」,在其他證據的加持下,你或許也會認為它就是個惡意軟體。
除了這些,言之鑿鑿說 Material Theme 就是個惡意軟體的新聞或是推文也都還有很多,例如說 20 萬人追蹤的 @theo 就直接說了:
The Material Theme has just been removed from GitHub and VS Code due to shipping malware
那到底 VS Code 上的 Material Theme 擴充套件是不是惡意軟體呢?先講結論:「不是」。
那這整件事情的過程到底是如何?為什麼一開始說疑似是惡意軟體,後來又不是了?我們按照時間順序,先從開頭來聊聊吧。
事情的開端與下架的理由
(底下時間都是指台灣時間)
2025/02/26 凌晨 01:32,有人在 Material Theme 的 GitHub 上發了一個 issue:This extension was reported to be problematic,內文中提到在 VS Code 中會出現底下的提示:
We have uninstalled ‘equinusocio.vsc-material-theme’ which was reported to be problematic.
證明至少在這個時間點,微軟已經主動把 VS Code 中的 Material theme 移除。過了幾個小時,在 04:39 時,知名的討論區 reddit 中也有人發文討論相同的狀況:Lost Material Theme。
到了早上 7 點,Hacker News 上也開始有人討論:Material Theme has been pulled from VS Code’s marketplace 。
大約下午 3 點 40 分的時候,VS Code 的團隊成員 Isidor 出來回覆了:
Hi - Isidor here from the VS Code team.
A member of the community did a deep security analysis of the extension and found multiple red flags that indicate malicious intent and reported this to us. Our security researchers at Microsoft confirmed this claims and found additional suspicious code.We banned the publisher from the VS Marketplace and removed all of their extensions and uninstalled from all VS Code instances that have this extension running. For clarity - the removal had nothing to do about copyright/licenses, only about potential malicious intent.
Expect an announcement here with more details soon https://github.com/microsoft/vsmarketplace/
As a reminder, the VS Marketplace continuously invests in security. And more about extension runtime trust can be found in this article https://code.visualstudio.com/docs/editor/extension-runtime-security
Thank you!
大意就是社群中有人對這個套件做了深度的資安分析,找到了多個 red flags 指出這個套件具有惡意的意圖並向微軟回報,而微軟內部的資安研究員也確認了這個發現,並找出其他可疑的程式碼。微軟已經把這個開發者的套件都下架以及把他 ban 掉,並說明這次移除套件的行為與 license 無關(這我們等等談),只跟潛在的可疑意圖有關。
到了晚上 11 點,有人在 Visual Studio Marketplace 的 GitHub 中開了一個 issue 討論這件事:Material theme compromised?,想知道更多的細節。
而 VS Code Marketplace 的 PM seaniyer 也在 2/27 早上 9 點 57 的時候給出了回覆:
Sean here from VS Code Marketplace. We take the decision to remove seriously and thoroughly verify any reports. To protect developers, we also prioritize speedy removal of positives. We’ve posted the reason for removal in RemovedPackages, where we plan to add any future removals as well. Thanks for helping to keep the marketplace safe for everyone.
我們對移除決策持謹慎態度,並會徹底驗證所有舉報。為了保護開發者,我們也優先迅速移除確定存在問題的項目。我們已在 RemovedPackages 中發布了移除原因,並計劃未來將所有移除記錄統一發布在該處。
RemovedPackages.md 這個檔案是在當天早上 7 點才被建立的,或許代表這是微軟第一次主動把套件下架?
在文件中寫了被下架的套件是 Equinusocio.vsc-material-theme-icons(另一個相同作者的套件,他有兩個,一個是 Material Theme 另一個是 Material Theme Icons),理由是:
A theming extension with heavily obfuscated code and unreasonable dependencies including a utility for running child processes
一個主題擴充功能,其程式碼經過高度混淆,並包含不合理的依賴項,例如用於執行 child process 的 utility。
而有一間資安公司 Koi Security,在 2025/02/27 發布了文章 A Wolf in Dark Mode: The Malicious VS Code Theme That Fooled Millions,提到了他們在 Material Theme 中找到惡意程式碼,看起來是經由一個 dependency 所引入的:
Say hello to the wolf in dark mode, “Material Theme”, an extremely popular VSCode theme extension, found to be containing malware underneath it’s beautiful color scheme
Material Theme — Free, a theme extension for VSCode, which was installed 3,927,094 times by developers, was found to contain malicious code through a dependency
The malicious code seems to be inside a dependency of the theme, which was compromised.
這裡用的詞是「was found to contain malicious code」,也是直接說了包含惡意程式碼。
作者的反駁
2/28 將近下午 5 點,Material Theme 的作者 @equinusocio 在 Visual Studio Marketplace 的 GitHub 中開了個 issue:Asking for Equinusocio publisher restoration and relative extensions, censorship and shady discriminatory microsoft moves,大意就是說它的套件裡面沒有惡意程式碼,唯一有的問題是一個太舊的第三方套件:
This decision destroyed 10 years of reputation and trust, all based on unfounded SUSPICIONS regarding obfuscated code—something you dislike, even though there was no evidence of harm. The only issue was an outdated sanity.io dependency within the obfuscated code, which could have been fixed in 30 seconds.
這個決定毀掉了 10 年來的聲譽和信任,而這一切都基於對混淆程式碼毫無根據的懷疑——只是因為你不喜歡它,儘管並沒有任何危害的證據。唯一的問題是混淆程式碼中存在一個過時的 sanity.io 依賴,而這本可以在 30 秒內修復。
文末也提到如果確認他的套件沒有惡意程式碼,請恢復所有的 extensions 以及公開道歉:
If your review of MY SOURCE CODE confirms that there is nothing malicious, I formally request the full restoration of our publisher accounts (Equinusocio and vira-theme), all related extensions, and user access to the theme. Additionally, all installations and insights should be reinstated.
Material Theme 為什麼會被懷疑?
整理一下上面的論述,會發現 Material Theme 確實幹了這麼幾件事情:
- 明明是個 theme,但套件裡有 JavaScript
- 具有混淆過的程式碼
- 程式碼中有與 username 跟 password 有關的部分
- 含有拿來執行 child processes 的 utility
你問我可不可疑,可疑啊,當然可疑。但如果你問我它是不是惡意程式,我會說不是。
為什麼不是?因為沒有人給出證據啊。儘管把程式碼混淆確實可疑,但也就只是可疑而已。更何況這個「可疑」的力度在我看來並沒有這麼強。舉例來講,沒有找到跟惡意 server 通信的證據或是可疑的後門等等。
除此之外,關於混淆這點,如果有了解過情況的話,就會發現早在 2024 年 8 月,Reddit 上就有人發了一篇 Has the Material Theme extension been compromised?,說最新的版本含有大量混淆過的程式碼,GitHub 上的歷史紀錄也已經被刪除,問說是發生什麼事了。
有人說可能跟作者在 8/10 發起的這兩個討論有關:
因為作者想把這個套件從開源變成閉源,並且發展收費版,因此才用混淆的方式把一些邏輯藏起來。
而所謂的「程式碼中有與 username 跟 password 有關的部分」,也很可能是因為某個第三方套件使用了 url-parser,因此這些帳號密碼指的是在解析 URL 時網址上的帳號密碼,而不是什麼偷取你電腦中的敏感資訊。
至於「拿來執行 child processes 的 utility」,有人把程式碼反混淆之後來看,就只是個 build script,沒有執行任何惡意指令。
(話說上面這兩點我沒有親自驗證,擴充套件的原始碼一直都可以下載,有興趣的人可以親自看看:https://marketplace.visualstudio.com/_apis/public/gallery/publishers/Equinusocio/vsextensions/vsc-material-theme/34.7.9/vspackage )
而 Koi Security 的那篇文章也完全沒有任何明確證據,這邊我的立場跟 RE: VSCode Extension Drama 這篇文章的副標題一樣:You can’t run your threat response like a High School clique。
當然,先撇除 Material Theme 不談,這個作者本身原本就有不少不符合開源精神的行為,這也是為什麼前面提到的微軟聲明中,會說:「For clarity - the removal had nothing to do about copyright/licenses, only about potential malicious intent.」,但因為這些都跟擴充套件是否為惡意軟體這件事無關,所以這邊就不多談了。
而一開始應該是只有 Material Theme 跟 Material Theme Icons 被下架且移除,但之後作者開了新帳號改名又傳了一次,被發現多次後整個帳號被 ban 掉,這個從 reddit 的討論串中可以看出來。
總之呢,這個 @r8 的評論滿精準地說出我的想法:
Being an ass is not a crime. If you want to ban Mattia for being an ass (which, I’m sorry to say, he is), that’s what Codes of Conduct were invented for.
「疑似」與「確實」,重要的一線之隔
我想討論的問題是:「VS Code 團隊下架 Material Theme 套件是否合理?」
但因為這個問題背後其實藏著兩三個子問題,因此我決定先把問題切小,第一件可以來聊的事情是,當發現「疑似含有惡意程式碼」的套件時,把它下架是否合理?
預防勝於治療,在還沒出事之前先止損,我認為是合理的。
那第二個延伸問題就是:「既然只是疑似,那有多少把握的時候,下架才是合理的?」
這其實是個「畫線」的問題。
舉例來說,如果只是在 theme 的套件中發現沒混淆過的 JavaScript 檔案,下架可能就不太合理。但如果是在 theme 的套件中發現混淆過的 JavaScript 呢?(內容你還不知道是什麼,就只知道有混淆過),對有些人說可能就覺得應該下架了。
但也有些人會覺得,一定要找到確切的證據才能下架,只是在懷疑階段都不行。
所以我說這是一個畫線問題,取決於你要把線畫在哪邊,要滿足哪些條件,才會覺得足夠可疑,可疑到要把它下架。這個標準每個人、每個組織都會不一樣。
想好這兩個問題以後,再來討論:「VS Code 團隊下架 Material Theme 套件是否合理?」,以他們的角度來看,已知的訊息大概是:
- 明明是個 theme,但套件裡有 JavaScript,還是混淆過的
- 含有拿來執行 child processes 的 utility
- 這個套件有數百萬下載
當他們做決定前,必須知道這個決定的會帶來的影響。
舉例來說,這是 VS Code 團隊第一次做這件事,因此就算只是「懷疑有問題」,也可能會被解讀為具有足夠的信心,才會大動作遠端主動移除套件。此外,如果最後真的證明是惡意套件那倒是沒事,但如果不是呢?那是否在對外發表聲明時應該格外小心,強調只是疑似,在證據還沒這麼明確的狀況下,盡量不傷害開發者的名聲?
另一個問題是,既然「沒有證據」這件事會影響決定,那是否這條線應該畫得更嚴格一點,只有掌握切確證據以後才做決定?畢竟如果最後證實套件其實沒問題,外界對微軟的資安能力也會感到質疑(像是,我以為你有足夠的證據才做這些,結果居然說是誤報)。
總之呢,我也不知道 VS Code 團隊掌握了多少證據,但他們最後做的決定大家都知道了,就是強制移除套件以保護使用者。
大結局:VS Code 團隊的道歉
事件過了一個多禮拜之後,在 3/7 時微軟經由這個 PR:Update RemovedPackages.md,把 Material Theme 從清單中移除。
而 3/12 時在作者發的那個 Issue 底下發表了公開聲明進行道歉:
False positives suck, and it hurts when it happens.
誤判很糟糕,當它發生時確實令人痛心。The publisher account for Material Theme and Material Theme Icons (Equinusocio) was mistakenly flagged and has now been restored. In the interest of safety, we moved fast and we messed up. We removed these themes because they fired off multiple malware detection indicators inside Microsoft, and our investigation came to the wrong conclusion. We care deeply about the security of the VS Code ecosystem, and acted quickly to protect our users.
Material Theme 和 Material Theme Icons(Equinusocio)的發佈者帳戶被錯誤標記,現在已經恢復。出於安全考量,我們行動迅速,但也因此犯了錯。我們移除了這些佈景主題,因為它們在微軟內部觸發了多個惡意軟體偵測指標,而我們的調查最終得出了錯誤的結論。我們非常重視 VS Code 生態系統的安全性,因此迅速採取行動來保護使用者。I understand that the “Equinusocio” extensions author’s frustration and intense reaction, and we hear you. It’s bad but sometimes things like this happen. We do our best - we’re humans, and we hope to move on from this We will clarify our policy on obfuscated code and we will update our scanners and investigation process to reduce the likelihood of another event like this.
These extensions are safe and have been restored for the VS Code community to enjoy.
我們理解「Equinusocio」擴充套件作者的沮喪與強烈反應,我們聽到了。這件事很糟糕,但有時候這類情況難以避免。我們盡力而為,但我們也是人,希望能夠從這次事件中吸取教訓並向前邁進。我們將明確關於混淆程式碼的政策,並更新我們的掃描工具與調查流程,以降低類似事件再次發生的可能性。這些擴充套件是安全的,現在已經恢復,VS Code 社群可以繼續使用並享受它們。LINKS:
Material Theme
[Material Theme Icons]
(https://marketplace.visualstudio.com/items?itemName=Equinusocio.vsc-material-theme-icons)Again, we apologize that the author got caught up in the blast radius and we look forward to their future themes and extensions. We’ve corresponded with him and thanked him for his patience.
我們再次對這位作者受到牽連而深表歉意,也期待他未來的佈景主題與擴充套件。我們已與他聯繫,並感謝他的耐心等待。Scott Hanselman and the Visual Studio Code Marketplace Team - @shanselman
所以,儘管它有著一些確實可疑的行為,但是 Material Theme 自始至終都不是個惡意軟體。
不過從聲明中能看出來從他們的角度,在做決定時應該有滿高的信心,畢竟內部的惡意軟體偵測都這麼說了(雖然最後是 false positive)。
如果是我的話,可能也會決定下架吧,因此我是能理解這個決定的。
但我覺得下架時的說明應該要更清楚一點,多次強調「事件還在調查,還沒確定是惡意軟體」,要不斷強調「還在驗證,只是為了保護使用者所以先移除」這件事。
雖然 VS Code 團隊本來就沒有明確表示是惡意軟體,但表達更像是「雖然還沒完全確定,但我滿有自信它是」,而不是「還沒確認是惡意軟體,請大家不要先恐慌,等我們驗證」。
最後整理一下我的立場,我目前的立場是,高度可疑的套件下架是合理的,我也認同 VS Code 團隊這樣做。但為了避免 false positive,在對外聲明時必須格外小心,否則對開發者名聲的傷害是難以挽回的,而我認為這次 VS Code 團隊在這點上並沒有做好。
就舉這次事件為例,儘管 VS Code 的道歉聲明已經是 3 天前發的了,又有多少人知道呢?會不會大多數的人還是認為 Material Theme 是個惡意軟體呢?
話說 BleepingComputer 在 Microsoft apologizes for removing VSCode extensions used by millions 一文中有去問一開始回報問題的資安公司,他們還是覺得有惡意程式碼:
When asked by BleepingComputer about this development, cybersecurity researcher Amit Assaraf continued to claim that the extension did contain malicious code. However, there was no malicious intent from the publisher, commenting that “in this case, Microsoft moved too fast.”
當 BleepingComputer 詢問此事時,資安研究員 Amit Assaraf 仍堅稱該擴充套件包含惡意程式碼。然而,他表示發佈者並無惡意,並評論道:「在這種情況下,微軟行動得太快了。」
但目前看起來,還是沒有提供相關證據。
評論