Windows: LUAFV Delayed Virtualization Cache Manager Poisoning EoP
The LUAFV driver can confuse the cache and memory manager to replace the contents of privileged file leading to EoP. When using delayed virtualization the driver allows mapping the original file read-only (as a data section or image section) without automatically creating the file in the virtual store. This trick is achieved by copying the real file’s SECTION_OBJECT_POINTERS (SOP) pointer from the file object opened in LuafvDelayOrVirtualizeFile to the top-level “virtual” file object. When creating a new section for a file object the kernel calls MiCreateImageOrDataSection. After checking some parameters it calls MiCallCreateSectionFilters. This is important for virtualization as this results in calling LuafvPreAcquireForSectionSynchronization in the LUAFV driver. If that function detects that the caller is trying to map the section writable then LuafvPreWrite is called which will complete the delayed virtualization process, and will update the SOP pointer of the “virtual” file to the newly created backing file. If the file is not being mapped writable then the LUAFV driver leaves the SOP pointing to the “real” file. MiCreateImageOrDataSection then checks whether the SOP::DataSectionObject CONTROLLING_SECTION_IS_WRITABLE flag is set. If it is then the function will call MiCreateDataFileMap. This function will call MiCreateDataFileMapObject to create a new data file map object. This object is then used to create a new section object. The problem is that the SOP pointer of the “virtual” file object is still pointing to the “real” file. This means that the CONTROLLING_SECTION_IS_WRITABLE flag is set, and MiCreateDataFileMapObject will create a new data file map object for the “real” file. This means that the new section object created will be backed by the “real” file, and not the “virtual” file. This means that an attacker can create a section object backed by a privileged file, and then write to it.