CVE-2021-31166 Overview
CVE-2021-31166 is a critical remote code execution vulnerability in the Windows HTTP Protocol Stack (HTTP.sys), the kernel-mode driver responsible for processing HTTP requests on Windows systems. This vulnerability allows an unauthenticated attacker to execute arbitrary code at the kernel level by sending specially crafted HTTP packets to a vulnerable system. The vulnerability is classified as a Use After Free (CWE-416) memory corruption flaw that can be exploited remotely without any user interaction.
Critical Impact
This vulnerability enables unauthenticated remote code execution with kernel-level privileges. It is wormable, meaning it can spread automatically across networks without user interaction. CISA has added this vulnerability to its Known Exploited Vulnerabilities catalog due to active exploitation in the wild.
Affected Products
- Microsoft Windows 10 version 2004
- Microsoft Windows 10 version 20H2
- Microsoft Windows Server version 2004
- Microsoft Windows Server version 20H2
Discovery Timeline
- 2021-05-11 - CVE-2021-31166 published to NVD
- 2025-10-30 - Last updated in NVD database
Technical Details for CVE-2021-31166
Vulnerability Analysis
The vulnerability resides in HTTP.sys, the kernel-mode driver that handles HTTP traffic for Windows services including Internet Information Services (IIS), Windows Remote Management (WinRM), and WSDAPI. The flaw is a Use After Free condition that occurs when the HTTP Protocol Stack improperly handles certain HTTP request headers.
When processing HTTP requests containing malicious trailer headers or specific request sequences, the driver can reference memory that has already been freed. This memory corruption can be leveraged to achieve arbitrary code execution within the kernel context, giving attackers complete control over the affected system.
The attack surface is particularly significant because HTTP.sys operates at the kernel level, meaning successful exploitation bypasses user-mode security controls entirely. Any Windows service that utilizes HTTP.sys for HTTP processing becomes a potential attack vector.
Root Cause
The root cause is a Use After Free (CWE-416) vulnerability in the HTTP Protocol Stack's handling of HTTP request headers. The kernel driver fails to properly track memory allocations during HTTP request processing, leading to a condition where freed memory is subsequently accessed. This type of memory safety issue in kernel-mode code is particularly dangerous as it can lead to complete system compromise.
Attack Vector
The attack vector is network-based and requires no authentication or user interaction. An attacker can exploit this vulnerability by:
- Identifying a target system running a vulnerable Windows version with HTTP.sys exposed
- Sending specially crafted HTTP packets containing malicious header structures
- Triggering the Use After Free condition in kernel memory
- Achieving arbitrary code execution with SYSTEM privileges
The vulnerability is considered wormable, meaning successful exploitation could be automated to spread across networks without any human intervention. Any service binding to HTTP.sys including IIS web servers, WinRM endpoints, and WSDAPI services can serve as an attack surface.
Detection Methods for CVE-2021-31166
Indicators of Compromise
- Unexpected system crashes or Blue Screen of Death (BSOD) events with HTTP.sys references in crash dumps
- Anomalous HTTP traffic patterns with malformed or unusual header structures
- Windows Event Log entries indicating kernel-mode driver failures in the HTTP subsystem
- Unexpected process creation or network connections originating from SYSTEM context
Detection Strategies
- Deploy network intrusion detection signatures to identify malformed HTTP packets targeting the vulnerability
- Monitor Windows Event Logs for Event ID 4625 (failed authentication) and kernel crash events
- Implement endpoint detection and response (EDR) solutions to identify anomalous kernel-mode behavior
- Analyze network traffic for unusual HTTP header patterns, particularly trailer headers
Monitoring Recommendations
- Enable enhanced Windows kernel auditing to capture driver load and memory events
- Configure network monitoring to alert on HTTP traffic anomalies to Windows servers
- Establish baseline metrics for HTTP.sys performance and alert on deviations
- Monitor CISA KEV catalog updates and threat intelligence feeds for active exploitation campaigns
How to Mitigate CVE-2021-31166
Immediate Actions Required
- Apply the Microsoft security update for CVE-2021-31166 immediately on all affected systems
- Prioritize patching internet-facing systems running IIS, WinRM, or other HTTP.sys-dependent services
- Implement network segmentation to limit exposure of vulnerable systems
- Review and restrict unnecessary HTTP-based services on Windows systems
Patch Information
Microsoft has released security updates to address this vulnerability. The official security advisory and patch information is available through the Microsoft Security Response Center advisory for CVE-2021-31166. Organizations should apply the appropriate update for their Windows version immediately due to the critical severity and active exploitation status. Additional technical analysis is available via the Packet Storm RCE Exploit documentation.
Workarounds
- Disable unnecessary HTTP-based services that utilize HTTP.sys until patching is complete
- Implement network-level controls (firewalls, WAF) to filter potentially malicious HTTP traffic
- Use network segmentation to isolate vulnerable Windows servers from untrusted networks
- Consider disabling HTTP trailer support if not required for business operations
# Verify HTTP.sys service status and consider disabling if not required
sc query http
# Stop HTTP service if not needed (will affect IIS, WinRM, etc.)
sc stop http
# Disable HTTP service to prevent automatic restart
sc config http start= disabled
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.


