
PowerShell script that applies a temporary registry-based mitigation for CVE-2026-21509, a Microsoft Office security feature bypass, with backup and rollback support.
English version: README.md
此腳本會套用以登錄檔為基礎的緩解措施,用於防護 CVE-2026-21509(Microsoft Office 安全功能略過漏洞),此漏洞已遭到主動攻擊利用。
CVE 編號: CVE-2026-21509
嚴重性: 重要
影響: 安全功能略過
受影響產品: Microsoft Office 2016 和 2019
執行前請先前往: https://msrc.microsoft.com/update-guide/vulnerability/CVE-2026-21509 在 Security Updates 區塊檢查是否有適合版本 Office 的下載連結。
此登錄檔修改可提供即時保護,但無法取代官方安全性更新。您仍然必須儘快安裝安全性更新(KB5002713)。
CVE-2026-21509_Mitigation.ps1 - 套用登錄檔機碼的 PowerShell 腳本Apply_CVE-2026-21509_Mitigation.bat - 批次檔啟動器(較容易執行)README_zh-TW.md - 本檔案Apply_CVE-2026-21509_Mitigation.bat 上按右鍵y 或 Y 然後按 Enter 繼續執行Set-ExecutionPolicy Bypass -Scope Process -Force.\CVE-2026-21509_Mitigation.ps1The script shows status and warnings first, then asks for confirmation before changing the registry. Messages shown during execution are listed below (Chinese in parentheses):
Phase 1: Information and confirmation(第一階段:說明與確認)
[Vulnerability Information] (漏洞資訊)
CVE ID: CVE-2026-21509(CVE 編號)Severity: Important (CVSS 7.8)(嚴重性與 CVSS)[Checking Current Status...] (檢查目前狀態)
Global Status: This vulnerability is being actively exploited worldwide(全域狀態:已在實際環境中被利用)Your Status: ...(您的狀態)
No Office 2016/2019 installation detected(未偵測到 Office 2016/2019)PROTECTED - Mitigation already applied(已保護:緩解措施已套用)VULNERABLE - Mitigation not yet applied(仍有風險:尚未套用緩解措施)Protected prompt (已保護時的提示,若適用)
Good news! Your system is already protected.(好消息,已受保護)Do you want to re-apply the mitigation anyway? (y/N):(是否仍要重新套用?)No Office detected prompt (未偵測到 Office 時的提示,若適用)
Phase 2: Apply changes(第二階段:執行變更,僅在使用者確認後執行)
[Step 1/4] Creating registry backup...(建立登錄檔備份)[Step 2/4] Detecting Office installation...(偵測 Office 安裝)[Step 3/4] Applying registry keys...(套用登錄檔機碼)[Step 4/4] Complete!(完成)Result summary(完成結果)
[SUCCESS] Mitigation successfully applied!(成功套用緩解措施)[Warning] No changes were applied(警告:未套用任何變更)根據您的系統和 Office 組態,腳本會將變更套用至下列一或多個路徑:
64 位元 MSI Office(或 32 位元 Windows 上的 32 位元):
HKLM\SOFTWARE\Microsoft\Office\16.0\Common\COM Compatibility\{EAB22AC3-30C1-11CF-A7EB-0000C05BAE0B}
64 位元 Windows 上的 32 位元 MSI Office:
HKLM\SOFTWARE\WOW6432Node\Microsoft\Office\16.0\Common\COM Compatibility\{EAB22AC3-30C1-11CF-A7EB-0000C05BAE0B}
64 位元隨選即用(或 32 位元 Windows 上的 32 位元):
HKLM\SOFTWARE\Microsoft\Office\ClickToRun\REGISTRY\MACHINE\Software\Microsoft\Office\16.0\Common\COM Compatibility\{EAB22AC3-30C1-11CF-A7EB-0000C05BAE0B}
64 位元 Windows 上的 32 位元隨選即用:
HKLM\SOFTWARE\Microsoft\Office\ClickToRun\REGISTRY\MACHINE\Software\WOW6432Node\Microsoft\Office\16.0\Common\COM Compatibility\{EAB22AC3-30C1-11CF-A7EB-0000C05BAE0B}
若要驗證登錄檔機碼是否已套用:
Win + R,輸入 regedit,然後按 EnterCompatibility Flags = 0x00000400如果您需要移除緩解措施:
登錄檔備份_CVE-2026-21509_*.reg或者,手動刪除腳本建立的登錄檔機碼。
此腳本依「現況」提供,不提供任何形式的保證。請務必先在非正式環境中測試。登錄檔備份功能可協助確保您能夠在需要時復原。
程式碼產生說明: 本程式碼由 Claude AI 產生。
如有關於此漏洞的問題或疑問,請聯絡 Microsoft 支援服務或參考 Microsoft 安全性回應中心的官方指引。
A: 是的。自 2026 年 1 月 26 日起,Microsoft Office 2016 和 2019 的安全性更新已經推出。執行 Microsoft Office 2016 和 2019 的客戶應確保已安裝更新,以防範此漏洞。
A:
A:
A: 是的!此登錄檔緩解措施僅為暫時性保護。您必須安裝官方安全性更新以獲得完整保護。
A: 否,但已遭到主動攻擊利用(Exploitation Detected)。
A: Microsoft 365 Apps 企業版的使用者應確保已套用最新更新。系統已設定為自動接收更新的使用者無需採取進一步動作。
解決方法: 在批次檔上按右鍵並選擇「以系統管理員身分執行」
解決方法: 以系統管理員身分開啟 PowerShell 並執行:
Set-ExecutionPolicy Bypass -Scope Process -Force
可能原因:
解決方法:
此緩解措施會封鎖以下 CLSID:
{EAB22AC3-30C1-11CF-A7EB-0000C05BAE0B}此 CLSID 與有弱點的 OLE 控制項相關聯,攻擊者可利用此控制項略過 Office 的安全功能。
數值 0x00000400 (DWORD) 會指示 Office 封鎖此特定 COM 物件的載入,進而防止攻擊者利用該漏洞。
套用此緩解措施不應影響一般的 Office 功能。如果您遇到任何異常行為,可以使用桌面上的備份檔案復原登錄檔變更。
如果您在使用此腳本時遇到問題,或有改善建議,請:
No Action Required(不需要採取任何動作)No Office 2016 or 2019 installation detected on this system.(未偵測到 Office 2016/2019)[This script will perform the following actions] (本腳本將執行下列動作)
1. Create registry backup(建立登錄檔備份)2. Detect Office installation type(偵測 Office 安裝類型)3. Add registry keys to block vulnerable COM component(新增登錄檔機碼以封鎖脆弱的 COM 元件)4. Provide detailed execution report(提供詳細執行報告)[Important Reminders] (重要提醒)
This is a temporary mitigation, official update KB5002713 is still required(此為暫時性緩解措施,仍需安裝 KB5002713)After applying, restart all Office applications(套用後請重新啟動 Office)If problems occur, use the backup file on Desktop to restore(若有問題可用桌面備份檔還原)Confirmation prompt (詢問使用者確認)
Do you want to continue with the mitigation? (y/N):(是否要繼續套用緩解措施?)