Kernel Patch Protection
Kernel Patch Protection (KPP), informally known as PatchGuard, is a feature of 64-bit (x64) editions of Microsoft Windows that prevents patching the kernel. It was first introduced in 2005 with the x64 editions of Windows XP and Windows Server 2003 Service Pack 1.
"Patching the kernel" refers to unsupported modification of the central component or kernel of the Windows operating system. Such modification has never been supported by Microsoft because it can greatly reduce system security and reliability. However, though Microsoft does not recommend it, it is technically possible to patch the kernel on x86 editions of Windows. But with the x64 editions of Windows, Microsoft chose to implement technical barriers to kernel patching.
Since patching the kernel is technically permitted in 32-bit (x86) editions of Windows, several antivirus software developers use kernel patching to implement antivirus and other security services. This kind of antivirus software will not work on computers running x64 editions of Windows. Because of this, Kernel Patch Protection has been criticized for forcing antivirus makers to redesign their software without using kernel patching techniques.
Also, because of the design of the Windows kernel, Kernel Patch Protection cannot completely prevent kernel patching. This has led to additional criticism that since KPP is an imperfect defense, the problems caused to antivirus makers outweigh the benefits because authors of malicious software will simply find ways around its defenses. Nevertheless, Kernel Patching can still prevent system stability and reliability problems caused by legitimate software patching the kernel in unsupported ways.
The Windows kernel is designed so that device drivers have the same privilege level as the kernel itself. In turn, device drivers are expected to not modify or patch core system structures within the kernel. In x86 editions of Windows, Windows does not enforce this expectation that drivers not patch the kernel. But because the expectation is not enforced on x86 systems, some programs, notably certain security and antivirus programs, were designed to perform needed tasks through loading drivers that modified core kernel structures.
In x64 editions of Windows, Microsoft chose to begin to enforce the restrictions on what structures drivers can and cannot modify. Kernel Patch Protection is the technology that actually enforces these restrictions. It works by periodically checking to make sure that protected system structures in the kernel have not been modified. If a modification is detected, then Windows will initiate a bug check and shut down the system, with a blue screen and/or reboot. The corresponding bugcheck number is 0x109, the bugcheck code is CRITICAL_STRUCTURE_CORRUPTION. Prohibited modifications include:
- Modifying system service tables
- Modifying the interrupt descriptor table
- Modifying the global descriptor table
- Using kernel stacks not allocated by the kernel
- Modifying or patching code contained within the kernel itself, or the HAL or NDIS kernel libraries
It should be noted that Kernel Patch Protection only defends against device drivers modifying the kernel. It does not offer any protection against one device driver patching another.
Ultimately, since device drivers have the same privilege level as the kernel itself, it is impossible to completely prevent drivers from bypassing Kernel Patch Protection and then patching the kernel. KPP does however present a significant obstacle to successful kernel patching. With highly obfuscated code and misleading symbol names, KPP employs security through obscurity to hinder attempts to bypass it. Periodic updates to KPP also make it a "moving target", as bypass techniques that may work for a while are likely to break with the next update. Since its creation in 2005, Microsoft has so far released two major updates to KPP, each designed to break known bypass techniques in previous versions.
Patching the kernel has never been supported by Microsoft because it can cause a number of negative effects. Kernel Patch Protection protects against these negative effects, which include:
- The Blue Screen of Death, which results from serious errors in the kernel.
- Reliability issues resulting from multiple programs attempting to patch the same parts of the kernel.
- Compromised system security.
- Rootkits can use kernel access to embed themselves in an operating system, becoming nearly impossible to remove.
- Products that rely on kernel modifications are likely to break with newer versions of Windows or updates to Windows that change the way the kernel works.
Microsoft's Kernel Patch Protection FAQ further explains:
Because patching replaces kernel code with unknown, untested code, there is no way to assess the quality or impact of the third-party code...An examination of Online Crash Analysis (OCA) data at Microsoft shows that system crashes commonly result from both malicious and non-malicious software that patches the kernel.
— "Kernel Patch Protection: Frequently Asked Questions". 22 January 2007. Retrieved 22 February 2007.
Some computer security software, such as McAfee's McAfee VirusScan and Symantec's Norton AntiVirus, works by patching the kernel. Additionally, anti-virus software authored by Kaspersky Lab has been known to make extensive use of kernel code patching on x86 editions of Windows. This kind of antivirus software will not work on computers running x64 editions of Windows because of Kernel Patch Protection. Because of this, McAfee called for Microsoft to either remove KPP from Windows entirely or make exceptions for software made by trusted companies such as themselves.
Interestingly, Symantec's corporate antivirus software and Norton 2010 range and beyond  does work on x64 editions of Windows despite KPP's restrictions, although with less ability to provide protection against zero-day malware. Antivirus software made by competitors ESET, Trend Micro, Grisoft AVG, avast!, Avira Anti-Vir and Sophos do not patch the kernel in default configurations, but may patch the kernel when features such as "advanced process protection" or "prevent unauthorized termination of processes" are enabled. 
Contrary to some media reports,[by whom?] Microsoft will not weaken Kernel Patch Protection by making exceptions to it, though Microsoft has been known to relax its restrictions from time to time, such as for the benefit of hypervisor virtualization software. Instead, Microsoft worked with third-party companies to create new Application Programming Interfaces that help security software perform needed tasks without patching the kernel. These new interfaces were included in Windows Vista Service Pack 1.
Because of the design of the Windows kernel, Kernel Patch Protection cannot completely prevent kernel patching. This led the computer security providers McAfee and Symantec to say that since KPP is an imperfect defense, the problems caused to security providers outweigh the benefits, because malicious software will simply find ways around KPP's defenses and third-party security software will have less freedom of action to defend the system.
In January 2006, security researchers known by the pseudonyms "skape" and "Skywing" published a report that describes methods, some theoretical, through which Kernel Patch Protection might be bypassed. Skywing went on to publish a second report in January 2007 on bypassing KPP version 2, and a third report in September 2007 on KPP version 3. Also, in October 2006 security company Authentium developed a working method to bypass KPP.
Nevertheless, Microsoft has stated that they are committed to remove any flaws that allow KPP to be bypassed as part of its standard Security Response Center process. In keeping with this statement, Microsoft has so far released two major updates to KPP, each designed to break known bypass techniques in previous versions.
In 2006, the European Commission expressed concern over Kernel Patch Protection, saying it was anticompetitive. However, Microsoft's own antivirus product, Windows Live OneCare, had no special exception to KPP. Instead, Windows Live OneCare used (and had always used) methods other than patching the kernel to provide virus protection services. Still, for other reasons a x64 edition of Windows Live OneCare was not available until November 15, 2007.
- "Kernel Patch Protection: Frequently Asked Questions". Microsoft. 22 January 2007. Retrieved 30 July 2007.
- skape; Skywing (December 2005). "Introduction". Bypassing PatchGuard on Windows x64. Uninformed. Retrieved 20 September 2007.
- Gewirtz, David (2006). "The great Windows Vista antivirus war". OutlookPower. Retrieved 8 July 2013. "The system's already vulnerable. People have already hacked into PatchGuard. System is already vulnerable no matter what. PatchGuard has a chilling effect on innovation. The bad guys are always going to innovate. Microsoft should not tie the hands of the security industry so they can't innovate. We're concerned about out-innovating the bad guys out there." —Cris Paden, Manager on the Corporate Communication Team at Symantec
- Skywing (September 2007). "Introduction". PatchGuard Reloaded: A Brief Analysis of PatchGuard Version 3. Uninformed. Retrieved 20 September 2007.
- Schofield, Jack (28 September 2006). "Antivirus vendors raise threats over Vista in Europe". The Guardian. Retrieved 20 September 2007. "This has never been supported and has never been endorsed by us. It introduces insecurity, instability, and performance issues, and every time we change something in the kernel, their product breaks." —Ben Fathi, corporate vice president of Microsoft's security technology unit
- "Patching Policy for x64-Based Systems". Microsoft. 22 January 2007. Retrieved 20 September 2007.
- skape; Skywing (December 2005). "System Images". Bypassing PatchGuard on Windows x64. Uninformed. Retrieved 21 September 2007.
- Skywing (January 2007). "Conclusion". Subverting PatchGuard Version 2. Uninformed. Retrieved 21 September 2007.
- Skywing (December 2006). "Misleading Symbol Names". Subverting PatchGuard Version 2. Uninformed. Retrieved 20 September 2007.
- Microsoft (June 2006). "Update to Improve Kernel Patch Protection". Microsoft Security Advisory (914784). Microsoft. Retrieved 21 September 2007.
- Microsoft (August 2007). "Update to Improve Kernel Patch Protection". Microsoft Security Advisory (932596). Microsoft. Retrieved 21 September 2007.
- Field, Scott (11 August 2006). "An Introduction to Kernel Patch Protection". Windows Vista Security blog. Microsoft. Retrieved 30 November 2006.
- Allchin, Jim (20 October 2006). "Microsoft executive clarifies recent market confusion about Windows Vista Security". Microsoft. Retrieved 30 November 2006.
- Skywing (June 2006). "Patching non-exported, non-system-service kernel functions". What Were They Thinking? Anti-Virus Software Gone Wrong. Uninformed. Retrieved 21 September 2007.
- Montalbano, Elizabeth (6 October 2006). "McAfee Cries Foul over Vista Security Features". PC World. Retrieved 30 November 2006.
- "Symantec AntiVirus Corporate Edition: System Requirements". Symantec. 2006. Retrieved 30 November 2006.
- "Symantec Internet Security product page". Symantec. 2011. Retrieved 26 January 2011.
- "64-bit Protection". ESET. Retrieved 5 October 2007.
- "Minimum System Requirements". Trend Micro USA. Retrieved 5 October 2007.
- "AVG Anti-Virus and Internet Security - Supported Platforms". Grisoft. Archived from the original on 27 August 2007. Retrieved 5 October 2007.
- Jaques, Robert (23 October 2006). "Symantec and McAfee 'should have prepared better' for Vista". vnunet.com. Retrieved 30 November 2006.
- McMillan, Robert (19 January 2007). "Researcher: PatchGuard hotfix stitches up benefit to Microsoft". InfoWorld. Retrieved 21 September 2007.
- "Notable Changes in Windows Vista Service Pack 1". Microsoft. 2008. Retrieved 20 March 2008.
- skape; Skywing (1 December 2005). "Bypassing PatchGuard on Windows x64". Uninformed. Retrieved 2 June 2008.
- Skywing (December 2006). "Subverting PatchGuard Version 2". Uninformed. Retrieved 2 June 2008.
- Skywing (September 2007). "PatchGuard Reloaded: A Brief Analysis of PatchGuard Version 3". Uninformed. Retrieved 2 June 2008.
- Hines, Matt (25 October 2006). "Microsoft Decries Vista PatchGuard Hack". eWEEK. Retrieved 30 July 2007.
- Gewirtz, David (2006). "The great Windows Vista antivirus war". OutlookPower. Retrieved 30 November 2006.
- Espiner, Tom (25 October 2006). "EC Vista antitrust concerns fleshed out". silicon.com. Retrieved 30 November 2006.
- Jones, Jeff (12 August 2006). "Windows Vista x64 Security – Pt 2 – Patchguard". Jeff Jones Security Blog. Microsoft. Retrieved 11 March 2007.
- White, Nick (14 November 2007). "Upgrade to Next Version of Windows Live OneCare Announced for All Subscribers". Windows Vista Team Blog. Microsoft. Retrieved 14 November 2007.
- The Truth About PatchGuard: Why Symantec Keeps Complaining
- An Introduction to Kernel Patch Protection
- Microsoft executive clarifies recent market confusion about Windows Vista Security
- Kernel Patch Protection: Frequently Asked Questions
- Windows Vista x64 Security – Pt 2 – Patchguard
- Bypassing PatchGuard on Windows x64
- Subverting PatchGuard Version 2
- PatchGuard Reloaded: A Brief Analysis of PatchGuard Version 3
Working bypass approaches
- A working driver to bypass PatchGuard 3 (including source code)
- Bypassing PatchGuard with a hex editor
Microsoft security advisories: