CVE-2021-31985
📋 TL;DR
CVE-2021-31985 is a remote code execution vulnerability in Microsoft Defender's MpEngine that allows attackers to execute arbitrary code with SYSTEM privileges by exploiting memory corruption. This affects systems running Microsoft Defender Antivirus and Microsoft Defender for Endpoint. The vulnerability requires the attacker to trick a user into opening a specially crafted file.
💻 Affected Systems
- Microsoft Defender Antivirus
- Microsoft Defender for Endpoint
📦 What is this software?
⚠️ Risk & Real-World Impact
Worst Case
Full system compromise with SYSTEM privileges, enabling complete control over the affected system, data theft, lateral movement, and persistence.
Likely Case
Local privilege escalation leading to malware installation, data exfiltration, or ransomware deployment on individual endpoints.
If Mitigated
Limited impact with proper endpoint protection, network segmentation, and user awareness preventing malicious file execution.
🎯 Exploit Status
Exploit requires user interaction to open malicious file. Proof-of-concept code has been published, making exploitation more accessible.
🛠️ Fix & Mitigation
✅ Official Fix
Patch Version: Security updates released June 8, 2021 (KB5003637 for Windows 10 2004/20H2/21H1)
Vendor Advisory: https://portal.msrc.microsoft.com/en-US/security-guidance/advisory/CVE-2021-31985
Restart Required: Yes
Instructions:
1. Apply Microsoft security updates from June 2021. 2. For Windows 10/11: Use Windows Update or manually install KB5003637. 3. For Windows Server: Apply corresponding security updates. 4. Restart systems to complete installation.
🔧 Temporary Workarounds
Disable Microsoft Defender Real-time Protection
windowsTemporarily disable real-time scanning to prevent exploitation (not recommended long-term)
Set-MpPreference -DisableRealtimeMonitoring $true
Restrict File Execution
windowsUse AppLocker or similar to restrict execution of untrusted files
🧯 If You Can't Patch
- Implement strict application whitelisting to prevent execution of untrusted files
- Enhance email filtering and web protection to block delivery of malicious files
🔍 How to Verify
Check if Vulnerable:
Check Microsoft Defender version: Get-MpComputerStatus | Select AntivirusEngineVersion
Check Version:
Get-MpComputerStatus | Select AntivirusEngineVersion
Verify Fix Applied:
Verify installed updates: Get-HotFix | Where {$_.HotFixID -like "KB5003637*"}
📡 Detection & Monitoring
Log Indicators:
- Microsoft Defender crash logs (Event ID 1000)
- Unexpected process creation from MsMpEng.exe
- Suspicious file scanning activity
Network Indicators:
- Outbound connections from MsMpEng.exe to unusual destinations
- DNS requests for known exploit domains
SIEM Query:
EventID=1000 AND Source="Microsoft-Windows-Windows Defender" AND ProcessName="MsMpEng.exe"
🔗 References
- http://packetstormsecurity.com/files/163443/MpEngine-ASProtect-Embedded-Runtime-DLL-Memory-Corruption.html
- https://portal.msrc.microsoft.com/en-US/security-guidance/advisory/CVE-2021-31985
- http://packetstormsecurity.com/files/163443/MpEngine-ASProtect-Embedded-Runtime-DLL-Memory-Corruption.html
- https://portal.msrc.microsoft.com/en-US/security-guidance/advisory/CVE-2021-31985