Windows Kernel ReadLayoutFile Heap Overflow


1.1.1. Advisory Information

Windows Kernel ReadLayoutFile Heap Overflow
Advisory ID
Advisory URL
Date published
Date of last update
Vendors contacted
Release mode
Coordinated release
Nicolás Economou

1.1.2. Vulnerability Information

Remotely Exploitable
Locally Exploitable
CVE Name

1.1.3. Vulnerability Description

There is a bug in the ReadLayoutFile Windows Kernel function that can be leveraged
into a local privilege escalation exploit, potentially usable in a client-side attack scenario
or after a remote intrusion by other means.

This bug is similar to another bug used by a client-side exploit in Stuxnet.

1.1.4. Vulnerable packages

1.1.5. Vendor Information, Solutions and Workarounds

Apply security patch MS12-047 [4]

1.1.6. Credits

This vulnerability was discovered and researched by Nicolás Economou from Core Security Technologies.
The publication of this advisory was coordinated by Fernando Russ.

1.1.7. Technical Description / Proof of Concept Code

There is a bug in the ReadLayoutFile Windows Kernel (win32k.sys) function that can be leveraged
into a local privilege escalation exploit, potentially usable in a client-side attack scenario,
or after a remote intrusion by other means.

Custom keyboard layouts are implemented using a .dll file exporting the KbdLayerDescriptor function which,
in theory, returns a pointer to a structure of type KBDTABLES that is stored in the .DATA sections of the PE file.
The NtUserLoadKeyboardLayoutEx is a private function used by LoadKeyboardLayout[2] to load a custom keyboard layout, as arguments NtUserLoadKeyboardLayoutEx uses an open file handle pointing to a keyboard layout library.
When the function NtUserLoadKeyboardLayoutEx is correctly called the PE file referenced by its arguments is mapped in kernel space.

The bug is due to a memory corruption: a double word can be overwritten in a position relative to the base of the allocated
memory in kernel space. We have to distinguish the following constraints for exploiting this vulnerability:

We can confirm reliable exploitation for the following Microsoft Windows versions:

1.1.8. Report Timeline

1.1.9. References


1.1.10. About CoreLabs

CoreLabs, the research center of Core Security Technologies, is charged with anticipating
the future needs and requirements for information security technologies.
We conduct our research in several important areas of computer security
including system vulnerabilities, cyber attack planning and simulation,
source code auditing, and cryptography. Our results include problem
formalization, identification of vulnerabilities, novel solutions and
prototypes for new technologies. CoreLabs regularly publishes security
advisories, technical papers, project information and shared software
tools for public use at:

1.1.11. About Core Security Technologies

Core Security Technologies enables organizations to get ahead of threats
with security test and measurement solutions that continuously identify
and demonstrate real-world exposures to their most critical assets. Our
customers can gain real visibility into their security standing, real
validation of their security controls, and real metrics to more
effectively secure their organizations.

Core Security's software solutions build on over a decade of trusted
research and leading-edge threat expertise from the company's Security
Consulting Services, CoreLabs and Engineering groups. Core Security
Technologies can be reached at +1 (617) 399-6980 or on the Web at:

1.1.12. Disclaimer

The contents of this advisory are copyright
(c) 2012 Core Security Technologies and (c) 2012 CoreLabs,
and are licensed under a Creative Commons
Attribution Non-Commercial Share-Alike 3.0 (United States) License:

1.1.13. PGP/GPG Keys

This advisory has been signed with the GPG key of Core Security Technologies advisories
team, which is available for download at