Microsoft .NET Framework 4 PEImageLayout::Map Security Feature Bypass
🗓️ 12 Nov 2026 00:00:00Reported by Google Security Research, James ForshawType
packetstorm🔗 packetstorm.news👁 22 Views
Security feature bypass in .NET Framework 4 allows code injection into a PPL process.
Windows: .NET PEImageLayout::Map Security Feature Bypass
https://project-zero.issues.chromium.org/issues/569822336
Windows: .NET PEImageLayout::Map Security Feature Bypass
Platform: Windows 11 / .NET v4
Class: Security Feature Bypass
Security Boundary: User
## Summary
The implementation of the assembly loader in .NET Framework v4 can be abused to load a file from a flat memory buffer resulting in bypass of WDAC policy and code injection into a Protected Process Light process as long as "Dynamic Code Security" code integrity policy option is not enabled leading to a security feature bypass.
**Note:** This issue has been publicly disclosed at the 44con conference in September 2026 as part of my presentation. I based the decision to not disclose on the Security Servicing Criteria which for WDAC which seems to indicate that if there's mitigating controls present in the policy engine then it's not a bypass and so would not be serviced. As you can configure the "Dynamic Code Security" policy to block the attack that would seem to be the case. However after discussing it with contacts in the .NET team they feel that the issue is not by design and should still be fixed so I'm disclosing it.
I'm applying the standard deadline, however that's somewhat meaningless in this case as it's already in the public domain. Also I used the underlying behavior to exploit Oracle VirtualBox's protected process implementation, that issue will also become public on 2026/10/16. I'd suggest making an assessment of the severity and if it's Moderate then publishing wouldn't matter.
## Description
Mapping an assembly file into memory uses roughly the following code in `PEImageLayout::Map`.
```
PEImageLayout *PEImageLayout::Map(HANDLE file) {
PEImageLayout* image = new MappedImageLayout(file);
if (!mapped->Image) {
image = new FlatImageLayout(file);
}
if (image->Image) {
if (!PEDecoder::CheckFormat(image->Image))
ThrowWin32(ERROR_BAD_EXE_FORMAT);
}
return image;
}
```
It'll try to use `MappedImageLayout` first which tries to map the file as an image section, if that fails it'll fall back to using FlatImageLayout which just maps the file as a data section. This is interesting if the assembly is being loaded into a process where code integrity is enforced, such as under WDAC or in a protected process. If we can get MappedImageLayout to fail and instead get FlatImageLayout to load the code we might be able to get arbitrary code to run which is untrusted relative to the policy.
The `MappedImageLayout` constructor looks something like the following:
```c
void MappedImageLayout::MappedImageLayout(HANDLE file) {
HANDLE mapping = CreateFileMapping(file, nullptr, SEC_IMAGE | PAGE_READONLY);
if (mapping) {
this->Image = CLRMapViewOfFileEx(mapping);
} else {
if (GetLastError() != ERROR_BAD_EXE_FORMAT)
ThrowLastError();
}
if (EEConfig::EnforceCodeIntegrity()) {
ThrowWin32(ERROR_BAD_EXE_FORMAT);
}
// ...
}
```
We can get it to fail, and cause the fallback to occur if `CreateFileMapping` fails with error `ERROR_BAD_EXE_FORMAT` and the `EEConfig::EnforceCodeIntegrity` call returns false. For code integrity enforcement this means the "Dynamic Code Security" policy is disabled, this is the default setting. It's not enabled in Windows 11 S Mode for example and if a code integrity policy isn't deployed it'll also not be enabled in a protected process.
The `ERROR_BAD_EXE_FORMAT` error corresponds to the underlying `NtCreateSection` call failing with the status code `STATUS_INVALID_IMAGE_FORMAT`. It's trivial to get this status code by passing a file which isn't a valid image, but the file still needs to be considered valid by the .NET runtime to allow it to be loaded as a flat buffer.
No doubt there's plenty of ways to achieve the desired result, the simplest one I found was removing the PE Header's Characteristics `IMAGE_FILE_EXECUTABLE_IMAGE` flag from the DLL. This causes NtCreateSection to fail with `STATUS_INVALID_IMAGE_FORMAT` but .NET doesn't care if the flag is set.
It's worth noting that the behavior in .NET v2 seems to be different, in that it'll always call LoadLibrary on the DLL even after mapping the buffer as a flat image. I didn't spend much time checking if this was bypassable or not as v2 isn't installed by default or even exists as an optional component. I also didn't check any modern .NET runtime. Presumably there was a reason this fallback exists, perhaps it'll load .NET Modules which don't have to be in a PE file? I didn't spend much time checking.
Bypassing WDAC/PPL shouldn't be this trivial IMO. Previous work has focussed on finding a way to call Assembly::Load(byte\[\]) but that requires some other code to run, such as full trust PowerShell to reach the API. This attack can run from a file on disk in many more scenarios. That said, enabling the "Dynamic Code Security" policy does block this attack which is why I didn't believe it can meet the bar for a security bulletin with MSRC.
## Proof of Concept
A simple proof of concept for bypassing WDAC where "Dynamic Code Security" is not enabled, such as Windows 11 S Mode is as follows.
```c
using System;
using System.Runtime.InteropServices;
public class ComClass
{
[ComUnregisterFunction]
public static void UnregisterFunction(Type t)
{
Console.WriteLine("Hello");
}
}
```
Compile the above C\# as a library for AnyCPU. Then use a hex editor, modify byte 0x96 from 0x22 to 0x20 which clears the `IMAGE_FILE_EXECUTABLE_IMAGE` flag. Now, assuming it's allowed by policy we can use the Assembly Registration Tool to run it with the following command line as a normal user (no admin rights required):
```
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\regasm.exe c:\path\to\assembly.dll /unregister
```
If successful it should print "Hello" to the console. To exploit a protected process you can register the DLL as a COM object in HKCU and find a binary (such as WerFaultSecure.exe) that'll run protected and also load a COM object. Note, you can only exploit Protected Process Light, not classic Protected Process as .NET is only signed sufficiently to load into a PPL.
### Expected Result
The untrusted assembly should be blocked from loading.
### Observed Result
The untrusted assembly loads and prints "Hello" to the console.
## Disclosure
This bug is subject to a 90-day disclosure deadline. If a fix for this issue is made available to users before the end of the 90-day deadline, this bug report will become public 30 days after the fix was made available. Otherwise, this bug report will become public at the deadline. The scheduled deadline is 2027-01-04.Data
Build on a solid foundation with Vulners data
We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data
Api
Power your application with Vulners API
The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access
App
Assess and manage vulnerabilities with Vulners tools
Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation
12 Nov 2026 00:00Current
6.1Medium risk
Vulners AI Score6.1