Debugging the undebuggable and finding a CVE in Microsoft Defender for Endpoint
Microsoft Defender for Endpoint (MDE) sent telemetry to the M365 cloud without proper authorization checks, so anyone who knew a tenant's OrgId could send spoofed events on behalf of any device or organisation. This allowed an attacker to create fake devices and alerts in another tenant, potentially confusing a SOC.
Published on medium.com
At FalconForce, we like to understand the tools that we work with. One of the tools we use a lot on the blue side is MDE: Microsoft Defender for Endpoint, formerly Microsoft Defender ATP.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
At FalconForce we spend a lot of time understanding the tools we work with, and one of the tools we use most on the blue side is MDE: Microsoft Defender for Endpoint, formerly Microsoft Defender ATP. While working out how MDE sends its logs to the M365 cloud, we found a useful trick for debugging protected processes and, along the way, a vulnerability in MDE that we reported to Microsoft in August 2021 and that received CVE-2022-23278.
This write-up has three parts. First, some tips and tricks for debugging protected processes. Then the vulnerability itself, which became visible once the MDE process could be debugged properly. Finally, a look at the fix Microsoft made.
TL;DR: you can debug MDE running on an endpoint by running dbgsrv.exe and raising its PPL protection to WinTcb. That can be used to snoop on the data MDE transmits to the cloud. We identified a vulnerability related to missing authorization checks on data sent from the MDE endpoint to the M365 cloud, allowing anyone to send spoofed data to any M365 tenant.
Context
Microsoft Defender for Endpoint runs on the endpoint and ships telemetry to the M365 cloud, where it ends up in the M365 Defender portal. The process that matters for this work is MsSense.exe. All communication between MsSense.exe and the M365 cloud takes place over TLS with certificate pinning, which is there to stop an Adversary-in-the-Middle attack using tools such as Burp, even if a rogue CA certificate can be installed on the device.
The telemetry is delivered with a POST request to /OneCollector/1.0. The metadata that decides where the events land, and which device they appear to come from, sits in the id portion of the JSON body: the OrgId (a GUID identifying the organisation the logs are delivered to), plus MachineId and ComputerDnsName, which show up in the M365 portal as the originators of the event.
Setup
To observe what MDE sends, we need to debug MsSense.exe. The tooling involved:
- ProcessHacker, to inspect the protections of a program.
- PPLKiller by Acebond, which removes PPL protection flags from a running process by using a vulnerable driver to manipulate kernel memory.
- WinDbg, plus its debug server dbgsrv.exe.
- A Python interpreter with
zlib, to decompress the captured request body.
We also had past experience with Windows Kernel-Mode debugging. That allows debugging these protected processes, but it is very inconvenient because the entire machine freezes whenever a break-point triggers in the debugger.
Finding it
Process Hacker shows the protections on the MsSense.exe process.

Attaching a debugger to the process fails, even when the debugger is run from the SYSTEM account with TrustedInstaller privileges.

Lowering the protection level with PPLKiller was the first thing we tried, but it still produced the same permission denied error in WinDbg. The better idea was the reverse: instead of lowering the protection level of MsSense.exe, raise the protection level of our debugger.
Exploitation
Step 1: raise the protection level of the debug server
By default PPLKiller only allows removing PPL privileges, but the same mechanism can add them to an existing process. We contributed a patch that adds an /enablePPL option to increase the protection level of an existing process. The trick to making this work reliably is to apply it not to the WinDbg process itself but to the debug server dbgsrv.exe.
First, start dbgsrv.exe listening on localhost port 1234 (any port will do), running under the SYSTEM account:
"C:\Program Files\WindowsApps\Microsoft.WinDbg_1.2111.9001.0_neutral__8wekyb3d8bbwe\amd64\dbgsrv.exe" -t tcp:server=[redacted],port=1234
Then use the patched PPLKiller to raise the protection level of that debug server:
> tasklist | findstr dbgsrvdbgsrv.exe 4024 >.\PPLKiller.exe /enablePPL 4024PPLKiller version 0.3 by @aceb0nd[+] Windows Version 2009 Found[*] Device object handle has been obtained[*] Ntoskrnl base address: FFFFF80720800000[*] PsInitialSystemProcess address: FFFF90032906D080[*] Current process address: FFFF900330580080[*] Enabling PPL protection for process.
Process Hacker then shows dbgsrv.exe running as user SYSTEM with Full (WinTcb) protections enabled.

Step 2: attach WinDbg through the protected debug server
With dbgsrv.exe running, WinDbg can connect to it.

Via the dbgsrv.exe process, running as SYSTEM with the increased PPL protection level, we can attach to MsSense.exe.

Step 3: break on the TLS encryption function
With the debugger attached, we can intercept TLS-encrypted traffic before it gets encrypted. Place a break-point on SspiCli!EncryptMessage, the function that handles encryption as part of the TLS protocol:
> bu SspiCli!EncryptMessage
Resume the process with the g command. Once the process hits EncryptMessage, the debugger breaks:
Breakpoint 0 hitSspiCli!EncryptMessage:00007ff8`53a91be0 4053 push rbx
The arguments to EncryptMessage are documented by Microsoft:
SECURITY_STATUS SEC_ENTRY EncryptMessage( [in] PCtxtHandle phContext, [in] unsigned long fQOP, [in, out] PSecBufferDesc pMessage, [in] unsigned long MessageSeqNo);
We are interested in pMessage, the third argument, which is passed in the r8 register under the Windows calling convention. r8 contains a pointer to a SecBufferDesc structure:
typedef struct _SecBufferDesc { unsigned long ulVersion; unsigned long cBuffers; PSecBuffer pBuffers;} SecBufferDesc, *PSecBufferDesc;
The pBuffers element is at offset 8, since the two unsigned long elements before it take 4 bytes each. The following WinDbg command views pBuffers, which contains multiple SecBuffers; the poi function de-references a pointer in WinDbg:
0:039> dq(poi(@r8+8))00000054`c4bff070 00000007`0000000d 00000235`ea69c04000000054`c4bff080 00000001`000003f9 00000235`ea69c04d00000054`c4bff090 00000006`00000010 00000235`ea69c44600000054`c4bff0a0 00000000`00000000 00000000`0000000000000054`c4bff0b0 0000a2a8`14726248 00000000`0000000000000054`c4bff0c0 00000000`00000000 00000235`e584ee6000000054`c4bff0d0 00000235`e584e600 00000000`0000000000000054`c4bff0e0 00000235`eb164500 00000235`eb164500
The SecBuffer type is defined as follows:
typedef struct _SecBuffer { unsigned long cbBuffer; unsigned long BufferType; char *pvBuffer;}
The pvBuffer element contains the data to be encrypted, again at offset 8 because two unsigned long elements of 4 bytes precede it.
After some poking around, it turns out the second SecBuffer (with type 00000001) is what actually contains the clear-text data. Extract it as follows; the 0n161* can be modified to dump the other buffers as well:
> db poi(poi(@r8+8)+8+0n16*1) L0n19250 4f 53 54 20 2f 4f 6e-65 43 6f 6c 6c 65 63 74 POST /OneCollect6f 72 2f 31 2e 30 20 48-54 54 50 2f 31 2e 31 0d or/1.0 HTTP/1.1.0a 43 61 63 68 65 2d 43-6f 6e 74 72 6f 6c 3a 20 .Cache-Control: 6e 6f 2d 63 61 63 68 65-0d 0a 43 6f 6e 6e 65 63 no-cache..Connec74 69 6f 6e 3a 20 4b 65-65 70 2d 41 6c 69 76 65 tion: Keep-Alive0d 0a 43 6f 6e 74 65 6e-74 2d 54 79 70 65 3a 20 ..Content-Type: 61 70 70 6c 69 63 61 74-69 6f 6e 2f 78 2d 6a 73 application/x-js6f 6e 2d 73 74 72 65 61-6d 3b 20 63 68 61 72 73 on-stream; chars65 74 3d 75 74 66 2d 38-0d 0a 43 6f 6e 74 65 6e et=utf-8..Conten74 2d 45 6e 63 6f 64 69-6e 67 3a 20 64 65 66 6c t-Encoding: defl61 74 65 0d 0a 41 63 63-65 70 74 3a 20 61 70 70 ate..Accept: app6c 69 63 61 74 69 6f 6e-2f 6a 73 6f 6e 0d 0a 41 lication/json..A
The POST headers and the POST body are encrypted using separate calls to EncryptMessage, so only the POST headers are shown here. To observe the POST body, continue execution until the next break-point is hit. Note that if the program was paused for a long time on the first break-point, the underlying TLS connection will have timed out and a new request will be made before the POST body can be observed.
The POST body looks strange when viewed:
> db poi(poi(@r8+8)+8+0n16*1)b5 5b 59 6f ea 4a 97 7d-6f a9 ff c3 55 9e ba 95 .[Yo.J.}o...U...9b 73 3c 60 02 47 ea 07-1b 0f 31 49 99 18 3c 60 .s<`.G....1I..<`f7 6d b5 c0 26 18 0f 40-02 c4 e0 4f f7 bf f7 da .m..&[email protected] 19 70 4e e7 93 5a ea-48 88 60 97 ab 6a 4f 6b 6.pN..Z.H.`..jOkaf 5d 55 fe c7 d5 eb e2-e5 ea d7 55 e7 07 77 f5 .]U........U..w.
That did not look like a proper POST body until we noticed the Content-Encoding: deflate in the POST headers: the body is compressed. The size of the compressed data is in the cbBuffer field, 8 bytes before the pointer to the compressed data:
> dd poi(@r8+8)+0n16*1 L100000054`c41fe7e0 00001c42
Write it to a file:
> .writemem c:\temp\request.raw poi(poi(@r8+8)+8+0n16*1) l1c42Writing 1c42 bytes....
Step 4: decompress and decode the payload
The file can be decompressed in various ways, for example with a simple Python script:
import zlibimport sysf = open(sys.argv[1],'rb')o = open(sys.argv[1]+'.out','wb')o.write(zlib.decompress(f.read(), -15))
Running this on request.raw produces request.raw.out, which finally contains the decrypted payload. It turns out to be JSON:

The actual events are base64-encoded inside the JSON data:
"data": { "events": "rQkLAQ9HZ...snip"
Decoding this base64 yields the events in a binary format. They appear to be serialised using the Microsoft Bond serialisation framework, which is similar to the more commonly used Protobuf framework.

These are the actual events that are ingested into the M365 cloud.
Step 5: the vulnerability in the id portion
Now that we know how data is sent from MDE on our device to the M365 cloud, we can look at the vulnerability. It lives in the id portion of the JSON that is sent:

The metadata about the events is in the id portion. It contains the OrgId, a GUID representing the identifier of the organisation where these logs will be delivered, as well as the MachineId and ComputerDnsName that will end up in the M365 portal as the originators of the event.
The headers of the POST request also matter:
POST /OneCollector/1.0 HTTP/1.1Cache-Control: no-cacheConnection: Keep-AliveContent-Type: application/x-json-stream; charset=utf-8Content-Encoding: deflateAccept: application/jsonAccept-Encoding: gzip, deflateUser-Agent: MSDWUpload-Time: 2022-02-11T20:12:22.443ZReliability-Mode: mediumClient-Version: UTC-Windows-C++-no-10.0.19042.1466.amd64fre.vb_release.191206-1406-noApiKey: <removed>AuthMsaDeviceTicket: <removed>Content-Length: 7234Host: eu-v20.events.data.microsoft.com
Authentication is based on an ApiKey, which turns out to be static and shared for all MDE clients, and an AuthMsaDeviceTicket. That ticket turns out to be optional and can be replaced with a header specifying Client-Id: NO_AUTH, bypassing authentication altogether.
There is no proper authorization in place proving that the sender is authorised to send on behalf of a specific device and organisation. Anyone can send data on behalf of any organisation and machine simply by manipulating the MachineId, OrgId and ComputerDnsName fields. This also works cross-tenant, allowing logs to be sent to another tenant if the GUID of that tenant is known. That GUID can be obtained by any user in the organisation or from any machine enrolled in MDE.
Step 6: proof of concept
As a proof of concept we captured some events from our tenant and replayed those events 20 times to a different tenant (that we also own), spoofing the MachineId and ComputerDnsName fields. It turns out that when a MachineId does not yet exist, a new Device is added to MDE with the details provided.

Root cause
There is no proper authorization in place proving that the sender is authorised to send on behalf of that device and organisation. The ApiKey is static and shared across all MDE clients, so it identifies the client software rather than the tenant, and the AuthMsaDeviceTicket is optional: replacing it with Client-Id: NO_AUTH bypasses authentication altogether.
Impact
Using this vulnerability, an attacker could send any number of spoofed events to any M365 environment when the OrgId is known. Those events could include spoofed alerts that would trigger fake incidents for a SOC to investigate, causing great confusion about which incidents are real and which have been manipulated. This works when the target tenant's OrgId GUID is known, which any user in the organisation or any machine enrolled in MDE can obtain.
Fix
On 8 March 2022 Microsoft released a patch for the vulnerability as part of the March Patch Tuesday, together with additional guidance on the MSRC blog.
The patch requires an update to the MDE client and adds anti-spoofing measures. The Microsoft Defender for Endpoint client analyzer tool can be used to check whether a specific machine has been updated and whether the anti-spoofing measures are enabled. Below is the output on a fully patched machine:

Besides the patch, Microsoft added the vulnerability to the Microsoft 365 Defender portal as a threat, with a dashboard showing the number of vulnerable devices in an environment.

A new alert was also added, triggered when exploitation attempts occur against a target environment. It is titled "Suspicious client communication". We triggered it in our test environment by running our original PoC code, which transmits spoofed events, but it only triggered when we targeted the DeviceId of a fully patched machine.

Technical details on the fix
The fix adds a mechanism to authenticate a device sending logs, using a signed JWT-like token passed in a newly added HTTP header named Custom-Request-Field. The screenshot below shows an example of a decoded JWT token taken from the Custom-Request-Field header of a device with a fully patched version of Microsoft Defender for Endpoint.

The token contains the machineId and the orgId. These values can be used to identify spoofing when they do not match the orgId and machineId in the actual request.
Microsoft also appears to have implemented additional measures limiting the ability to send data on behalf of a non-existing MachineId. These events appear to be dropped and no longer end up in the logging contained in the MDE portal.
Timeline
-
17 Aug 2021: vulnerability reported via the Microsoft MSRC portal.
-
20 Aug 2021: additional information provided to Microsoft, including Python PoC code to exploit.
-
15 Sep 2021: vulnerability acknowledged by Microsoft.
-
4 Nov 2021: the Microsoft team requests additional time before the issue can be fixed, asking to postpone any publications.
-
20 Nov 2021: the Microsoft team informs us that fixing is complex and will require more time.
-
7 Feb 2022: information received that CVE-2022-23278 will be assigned and the vulnerability will be patched as part of the March Patch Tuesday.
-
8 Mar 2022: patch released by Microsoft.
-
1 April 2022: FalconForce blog post with full details released, intentionally delayed to give organisations sufficient time to patch.
-
Other telemetry collectors with client-supplied tenant and device identifiers. Look for request bodies where the organisation GUID and device identifiers come from the client. A positive result is a request accepted with a Client-Id: NO_AUTH style header, or with an optional device ticket omitted, and the event appearing under the spoofed identity.
-
Static, shared API keys. Check whether the same ApiKey value is present across unrelated installations. If it is, the key authenticates the software, not the tenant, and is worth testing against other endpoints of the same service.
-
Optional authentication headers. Try replacing a device ticket or token header with a no-auth marker. A positive result is a successful ingestion response rather than an authentication error.
-
Cross-tenant delivery. With a known OrgId GUID from a tenant you control, replay captured events with a modified OrgId. A positive result is the events landing in the other tenant's portal.
-
Ghost device creation. Replay events with a MachineId that does not exist in the tenant. A positive result is a new device appearing in the device inventory with the supplied ComputerDnsName.
-
Post-fix verification. On a patched client, inspect the Custom-Request-Field header and decode the token. A positive result for the fix being present is a token whose machineId and orgId match the request; a mismatch is what the new alert is meant to catch.
What happened, in plain words
Microsoft Defender for Endpoint (MDE) is a security program that runs on Windows computers. Its job is to watch what happens on the machine and send a record of it up to Microsoft's cloud service, where an administrator can see it in a web portal. Those records are called telemetry: things like which programs ran, which files were touched, which connections were made.
While trying to understand exactly how MDE sends those records, the researchers at FalconForce found two things. The first was a neat trick for looking inside a program that Windows deliberately protects from prying eyes. The second, found once they could look inside, was a real flaw: the cloud service that receives the records did not properly check who was sending them. Anyone who knew the target organisation's OrgId GUID could send fake records into that organisation's portal, as if they came from a computer it owned.
They reported it to Microsoft in August 2021. It was given the identifier CVE-2022-23278, patched in March 2022, and described publicly in April 2022.
This article walks through the whole story in the same order the researchers told it: the debugging trick first, then the flaw, then the fix. The commands and output below are taken from their write-up.
A quick note on vocabulary before we start, because a few words will come back constantly:
- A process is a running program. When you open a browser, the browser becomes one or more processes. Windows keeps a list of them, and each one has a number called a process ID (PID).
- A debugger is a tool that lets a person pause a running program, look at what it is holding in memory, and step through it one instruction at a time. Programmers use it to find bugs; security researchers use it to understand what a program is really doing.
- Memory here means the working area a program uses while it runs. Values the program is currently handling sit there, in raw form, before or after they are written to disk or sent over the network.
- TLS is the encryption that puts the padlock in your browser's address bar. It turns readable data into scrambled data on its way across the internet, so that anyone watching the wire sees gibberish.
- A tenant is one organisation's own private slice of a cloud service. Your company's Microsoft 365 is a tenant; another company's is a different tenant, with its own identifier.
Part 1: looking inside a protected program
Why MDE is hard to inspect
The part of MDE that does the sending is a process called MsSense.exe. If you want to see what a program sends before it is encrypted, the natural move is to attach a debugger to it. Windows, however, has a feature designed to stop exactly that.
Windows lets a program declare itself a Protected Process Light, or PPL. Think of it as a sealed glass box: the program keeps running normally, but other programs, even ones run by an administrator, are not allowed to reach inside. Microsoft uses this for its own security software precisely so that malware (or a curious researcher) cannot tamper with it. The protection level is a label attached to the process, and there are several grades of it.
To see the label, the researchers used a free tool called ProcessHacker, which is a kind of task manager on steroids: it lists every process and shows details Windows normally hides.

The screenshot shows Process Hacker's properties window for MsSense.exe, where the protection level is visible.
Trying to attach a debugger anyway fails. It fails even when the debugger is started from the SYSTEM account, which is the most powerful built-in account on a Windows machine, and even with TrustedInstaller privileges, a special level normally reserved for the component that installs and repairs Windows itself. In everyday terms: even the building's master key does not open this door.

The screenshot shows the error WinDbg (Microsoft's debugger) displays when it tries to attach to MsSense.exe.
The first idea, and why it did not work
There are tools that can change a process's protection label after the fact. One is PPLKiller by Acebond. It works by loading a vulnerable driver and using it to edit a part of Windows memory that ordinary programs are never allowed to touch. A driver is a small piece of software that runs with deep privileges inside the operating system; a vulnerable one can be abused to do things the operating system would otherwise forbid.
The obvious plan was to use PPLKiller to remove the protection from MsSense.exe, then attach the debugger. It did not work: WinDbg still gave the same permission denied error.
There is another route, called Windows Kernel-Mode debugging. The kernel is the core of the operating system, the layer beneath all programs. A kernel debugger can see everything, including protected processes. The catch is practical: the entire machine freezes every time the debugger pauses at a break-point (a spot in the program where you have asked execution to stop). A computer that locks up every few seconds is not a pleasant place to work.
So the researchers turned the idea around. Instead of lowering the protection on the program they wanted to inspect, why not raise the protection on their own tool?
Raising the protection of the debugger instead
PPLKiller, as originally written, could only remove protection. The same underlying mechanism can also add it, so the researchers contributed a patch that adds an /enablePPL option, which raises the protection level of an existing process.
There is a subtlety. Raising the protection on the WinDbg window itself does not work reliably. Instead, they raised it on a separate helper program, the debug server called dbgsrv.exe. A debug server is a small program that sits and waits for a debugger to connect to it over the network; the debugger talks to the server, and the server does the actual poking inside the target process. Protecting the server, rather than the debugger, is what made the trick dependable.
Step one: start the debug server, listening only on the local machine (localhost, address [redacted]) on port 1234. Any free port would do. It runs under the SYSTEM account.
"C:\Program Files\WindowsApps\Microsoft.WinDbg_1.2111.9001.0_neutral__8wekyb3d8bbwe\amd64\dbgsrv.exe" -t tcp:server=[redacted],port=1234
Line by line:
- The quoted path is the full location of dbgsrv.exe inside the installed WinDbg package. Windows paths with spaces must be quoted, which is why the quotes are there.
-t tcp:server=[redacted],port=1234tells the server to accept connections over TCP (the ordinary network protocol) on address [redacted], which always means "this same computer", and on port 1234. Because the address is localhost, nothing outside the machine can connect.
Step two: find the process ID of the server, then raise its protection.
> tasklist | findstr dbgsrvdbgsrv.exe 4024 >.\PPLKiller.exe /enablePPL 4024PPLKiller version 0.3 by @aceb0nd[+] Windows Version 2009 Found[*] Device object handle has been obtained[*] Ntoskrnl base address: FFFFF80720800000[*] PsInitialSystemProcess address: FFFF90032906D080[*] Current process address: FFFF900330580080[*] Enabling PPL protection for process.
Line by line:
tasklist | findstr dbgsrvruns Windows' built-in list of running processes and pipes the output throughfindstr, which filters it down to lines containing "dbgsrv". The|symbol means "take the output of the left command and feed it to the right one".- The result is the line
dbgsrv.exe 4024, so the process ID is 4024. .\PPLKiller.exe /enablePPL 4024runs the patched PPLKiller from the current folder (the.\means "in this folder") and asks it to enable PPL protection on process 4024.- The remaining lines are PPLKiller's own progress messages: its version, the Windows version it detected, and the memory addresses it located along the way. Those long hexadecimal numbers are addresses inside the computer's memory, not anything you need to memorise.
After this, Process Hacker shows dbgsrv.exe running as SYSTEM with the protection level called Full (WinTcb).

The screenshot shows Process Hacker's view of dbgsrv.exe, now running as SYSTEM with Full (WinTcb) protection enabled.
Attaching to MDE through the protected server
With the server running and protected, WinDbg can connect to it.

The screenshot shows WinDbg being pointed at the running debug server.
Through that server, which now runs as SYSTEM with the raised protection level, the debugger can attach to MsSense.exe.

The screenshot shows WinDbg successfully attached to MsSense.exe.
Reading the traffic before it is encrypted
Now comes the interesting part. All communication between MsSense.exe and the Microsoft cloud uses TLS, and on top of that it uses certificate pinning. To understand pinning, first recall what a certificate is: a digital document that proves a server is who it claims to be, issued by an authority that browsers and operating systems trust. Normally, if someone could install a fake trusted authority on your machine, they could impersonate any server. Pinning means the program does not accept just any trusted certificate: it remembers the exact certificate it expects and refuses everything else. That is what stops an Adversary-in-the-Middle attack, where an attacker secretly sits between your computer and the server, using tools such as Burp (a popular tool for inspecting web traffic), even if a rogue authority certificate has been installed on the device.
So intercepting the traffic on the wire is out. But a debugger does not need the wire. It can stand inside the program at the exact moment before encryption happens, when the data is still readable.
The function that performs the encryption is SspiCli!EncryptMessage. The part before the exclamation mark is the module (a library loaded into the process) and the part after is the function inside it. A function is a named block of code that does one job; here, the job is "take this data and encrypt it".
A break-point is set with:
> bu SspiCli!EncryptMessage
Line by line:
buis the WinDbg command that sets a break-point at a named location, resolved when the module loads.SspiCli!EncryptMessageis the location: the EncryptMessage function inside the SspiCli module.
Then the process is resumed with the g command (short for "go"). When the program reaches the function, the debugger stops it:
Breakpoint 0 hitSspiCli!EncryptMessage:00007ff8`53a91be0 4053 push rbx
Line by line:
Breakpoint 0 hitmeans the first break-point you set has been reached.SspiCli!EncryptMessage:00007ff853a91be0` is the memory address of the function.4053 push rbxis the first machine instruction at that address.pushsaves a value onto the stack, a scratch area programs use to keep track of where they are. You do not need to understand the instruction; it is simply where execution paused.
Finding the data inside the function
The arguments to EncryptMessage are documented by Microsoft:
SECURITY_STATUS SEC_ENTRY EncryptMessage( [in] PCtxtHandle phContext, [in] unsigned long fQOP, [in, out] PSecBufferDesc pMessage, [in] unsigned long MessageSeqNo);
Line by line:
SECURITY_STATUS SEC_ENTRY EncryptMessage(declares the function's name and the type of value it returns (a status code saying whether it worked).[in] PCtxtHandle phContextis the first argument: a handle to the encryption session, meaning "which conversation is this".[in] unsigned long fQOPis the second: quality-of-protection flags, options about how the encryption should be done.[in, out] PSecBufferDesc pMessageis the third and the interesting one: a pointer to a description of the message buffers.[in, out]means the function both reads it and may modify it.[in] unsigned long MessageSeqNois the fourth: a sequence number.
A pointer is a value that says where in memory something lives, like a street address rather than the house itself. On 64-bit Windows, function arguments are passed in registers, which are tiny fixed slots inside the processor. The third argument travels in the register named r8. So r8 holds the address of a SecBufferDesc structure. A structure is a bundle of related values stored together in memory, one after another.
typedef struct _SecBufferDesc { unsigned long ulVersion; unsigned long cBuffers; PSecBuffer pBuffers;} SecBufferDesc, *PSecBufferDesc;
Line by line:
typedef struct _SecBufferDesc {starts the definition of a structure and gives it the name SecBufferDesc.unsigned long ulVersion;is the first field: a version number, 4 bytes long.unsigned long cBuffers;is the second: how many buffers there are, also 4 bytes.PSecBuffer pBuffers;is the third: a pointer to the actual array of buffers.} SecBufferDesc, *PSecBufferDesc;closes the definition and adds a shorthand name for a pointer to this structure.
Because the two 4-byte numbers come first, the pointer pBuffers sits at offset 8 from the start of the structure. Offset means "how many bytes from the beginning". The following WinDbg command views it. The poi function de-references a pointer, meaning "go to the address and fetch what is stored there".
0:039> dq(poi(@r8+8))00000054`c4bff070 00000007`0000000d 00000235`ea69c04000000054`c4bff080 00000001`000003f9 00000235`ea69c04d00000054`c4bff090 00000006`00000010 00000235`ea69c44600000054`c4bff0a0 00000000`00000000 00000000`0000000000000054`c4bff0b0 0000a2a8`14726248 00000000`0000000000000054`c4bff0c0 00000000`00000000 00000235`e584ee6000000054`c4bff0d0 00000235`e584e600 00000000`0000000000000054`c4bff0e0 00000235`eb164500 00000235`eb164500
Line by line:
0:039>is the debugger prompt; the numbers are the current thread and process context.dqmeans "display quadwords", that is, show memory in 8-byte chunks.(poi(@r8+8))takes the value in r8, adds 8 to skip the two 4-byte fields, fetches the pointer stored there, and uses that as the address to display. The@prefix tells WinDbg thatr8is a register name.- Each output line shows an address on the left and the values stored there on the right. These are the individual SecBuffer entries.
Each entry has this shape:
Line by line:
unsigned long cbBuffer;is the size of the buffer in bytes.unsigned long BufferType;says what kind of data the buffer holds.char *pvBuffer;is a pointer to the data itself.- Again, the pointer sits at offset 8, because two 4-byte numbers come before it.
After some experimenting, the researchers found that the second SecBuffer, the one whose type is 00000001, holds the readable data. The command below extracts it. The 0n16*1 means "16 bytes times 1", that is, skip the first buffer; changing the multiplier dumps the other buffers instead.
> db poi(poi(@r8+8)+8+0n16*1) L0n19250 4f 53 54 20 2f 4f 6e-65 43 6f 6c 6c 65 63 74 POST /OneCollect6f 72 2f 31 2e 30 20 48-54 54 50 2f 31 2e 31 0d or/1.0 HTTP/1.1.0a 43 61 63 68 65 2d 43-6f 6e 74 72 6f 6c 3a 20 .Cache-Control: 6e 6f 2d 63 61 63 68 65-0d 0a 43 6f 6e 6e 65 63 no-cache..Connec74 69 6f 6e 3a 20 4b 65-65 70 2d 41 6c 69 76 65 tion: Keep-Alive0d 0a 43 6f 6e 74 65 6e-74 2d 54 79 70 65 3a 20 ..Content-Type: 61 70 70 6c 69 63 61 74-69 6f 6e 2f 78 2d 6a 73 application/x-js6f 6e 2d 73 74 72 65 61-6d 3b 20 63 68 61 72 73 on-stream; chars65 74 3d 75 74 66 2d 38-0d 0a 43 6f 6e 74 65 6e et=utf-8..Conten74 2d 45 6e 63 6f 64 69-6e 67 3a 20 64 65 66 6c t-Encoding: defl61 74 65 0d 0a 41 63 63-65 70 74 3a 20 61 70 70 ate..Accept: app6c 69 63 61 74 69 6f 6e 2f 6a 73 6f 6e 0d 0a 41 lication/json..A
Line by line:
dbmeans "display bytes".poi(poi(@r8+8)+8+0n16*1)walks the same chain: fetch the buffer list, skip 8 bytes to reach the first buffer's data pointer, then skip 16 more bytes to reach the second buffer's data pointer, and fetch that.L0n1925says how many bytes to show: 1925 in decimal.- The output is two columns: hexadecimal byte values on the left, and the same bytes rendered as text on the right. You can read
POST /OneCollector/1.0 HTTP/1.1and the header names in the right-hand column. This is the beginning of an HTTP request, the same kind of message your browser sends when it loads a page.
The POST headers and the POST body are encrypted by separate calls to EncryptMessage, so only the headers appear here. To see the body, execution must continue to the next break-point. One practical warning from the researchers: if the program is left paused too long at the first break-point, the underlying TLS connection times out and a fresh request is made before the body can be captured.
The body, when viewed, looks like nonsense:
> db poi(poi(@r8+8)+8+0n16*1)b5 5b 59 6f ea 4a 97 7d-6f a9 ff c3 55 9e ba 95 .[Yo.J.}o...U...9b 73 3c 60 02 47 ea 07-1b 0f 31 49 99 18 3c 60 .s<`.G....1I..<`f7 6d b5 c0 26 18 0f 40-02 c4 e0 4f f7 bf f7 da .m..&[email protected] 19 70 4e e7 93 5a ea-48 88 60 97 ab 6a 4f 6b 6.pN..Z.H.`..jOkaf 5d 55 fe c7 d5 eb e2-e5 ea d7 55 e7 07 77 f5 .]U........U..w.
Line by line:
- The command is the same as before: display bytes at the second buffer's data pointer.
- The output is random-looking bytes. This is not a bug in the extraction: the headers said
Content-Encoding: deflate, which means the body has been compressed. Compression is a way of shrinking data by describing repeated patterns more compactly; it is not encryption, and it can be undone by anyone who knows the method.
The size of the compressed data is stored in the cbBuffer field, 8 bytes before the pointer to the data:
> dd poi(@r8+8)+0n16*1 L100000054`c41fe7e0 00001c42
Line by line:
ddmeans "display doublewords", that is, show memory in 4-byte chunks.poi(@r8+8)+0n16*1points at the second buffer entry itself, not at its data.L1asks for one value.- The output shows the address and the value
00001c42, which is the size in hexadecimal: 0x1c42 bytes.
That data is then written to a file:
> .writemem c:\temp\request.raw poi(poi(@r8+8)+8+0n16*1) l1c42Writing 1c42 bytes....
Line by line:
.writememis the WinDbg command that copies a region of memory into a file.c:\temp\request.rawis the destination file.poi(poi(@r8+8)+8+0n16*1)is the starting address, the same chain as before.l1c42is the length, 0x1c42 bytes, matching the size just read.Writing 1c42 bytes....is WinDbg confirming what it did.
Turning the captured bytes back into readable data
The file can be decompressed in several ways. The researchers used a short Python script. Python is a programming language often used for small utility scripts like this one.
import zlibimport sysf = open(sys.argv[1],'rb')o = open(sys.argv[1]+'.out','wb')o.write(zlib.decompress(f.read(), -15))
Line by line:
import zlibloads Python's built-in compression library, which knows how to undo deflate compression.import sysloads the library that gives access to things like command-line arguments.f = open(sys.argv[1],'rb')opens the file whose name was given on the command line (sys.argv[1]is the first argument after the script name) in binary read mode ('rb').o = open(sys.argv[1]+'.out','wb')opens an output file with.outappended to the name, in binary write mode ('wb').o.write(zlib.decompress(f.read(), -15))reads the whole input file, decompresses it, and writes the result to the output file. The-15tells the library to expect raw deflate data with no wrapper around it.
Running this on request.raw produces request.raw.out, which contains the decrypted payload. It turns out to be JSON, a text format for structured data that looks like labelled boxes inside braces.

The screenshot shows part of the decoded JSON data.
The actual events are base64-encoded inside the JSON. Base64 is a way of writing arbitrary binary data using only ordinary letters, digits and a couple of symbols, so it can travel safely inside text.
"data": { "events": "rQkLAQ9HZ...snip"
Line by line:
"data": {opens a JSON object nameddata."events": "rQkLAQ9HZ...snip"is a field namedeventswhose value is a long base64 string. The...snipis the researchers' shorthand for "the rest is omitted here".
Decoding that base64 yields the events in a binary format. They appear to be serialised using the Microsoft Bond framework, which is similar to the more commonly used Protobuf. Serialisation is the process of turning structured data into a stream of bytes so it can be stored or sent, with the expectation that the receiver can turn it back into structure.

The screenshot shows the beginning of the base64-decoded events payload.
These are the actual events that get ingested into the Microsoft cloud.
Part 2: the flaw
Where the identity of the sender is written
Now that the researchers could see exactly what MDE sends, they could look for the flaw. It lives in the id portion of the JSON.

The screenshot shows the id portion of the JSON sent to Microsoft 365.
That id portion carries the metadata about the events: the OrgId, a GUID identifying the organisation the logs will be delivered to, plus the MachineId and ComputerDnsName, which will appear in the portal as the originators of the event. A GUID is a long random-looking identifier used to name something uniquely.
The headers of the POST request matter too:
POST /OneCollector/1.0 HTTP/1.1Cache-Control: no-cacheConnection: Keep-AliveContent-Type: application/x-json-stream; charset=utf-8Content-Encoding: deflateAccept: application/jsonAccept-Encoding: gzip, deflateUser-Agent: MSDWUpload-Time: 2022-02-11T20:12:22.443ZReliability-Mode: mediumClient-Version: UTC-Windows-C++-no-10.0.19042.1466.amd64fre.vb_release.191206-1406-noApiKey: <removed>AuthMsaDeviceTicket: <removed>Content-Length: 7234Host: eu-v20.events.data.microsoft.com
Line by line:
POST /OneCollector/1.0 HTTP/1.1is the request line: the method (POST, meaning "here is data for you"), the path on the server, and the HTTP version.Cache-Control: no-cacheasks that no copy be stored along the way.Connection: Keep-Aliveasks to keep the connection open for further requests.Content-Type: application/x-json-stream; charset=utf-8says the body is a stream of JSON text in UTF-8 encoding.Content-Encoding: deflatesays the body is compressed with deflate, which is why it looked like nonsense in the debugger.Accept: application/jsonsays the client expects JSON back.Accept-Encoding: gzip, deflatesays the client can handle compressed responses.User-Agent: MSDWidentifies the client software.Upload-Time: 2022-02-11T20:12:22.443Zis a timestamp.Reliability-Mode: mediumis a delivery setting.Client-Version: UTC-Windows-C++-no-10.0.19042.1466.amd64fre.vb_release.191206-1406-nodescribes the build of the client.ApiKey: <removed>is a key used for authentication. The researchers removed the actual value from the published write-up.AuthMsaDeviceTicket: <removed>is a ticket meant to prove the identity of the device. Its value was also removed.Content-Length: 7234is the size of the body in bytes.Host: eu-v20.events.data.microsoft.comis the server being contacted.
The flaw itself
Authentication here rests on two things: the ApiKey and the AuthMsaDeviceTicket. The researchers found that the ApiKey is static and shared across all MDE clients, so it proves "this is MDE software" rather than "this is your organisation". And the ticket turns out to be optional: it can be replaced with a header specifying Client-Id: NO_AUTH, which bypasses authentication altogether.
That leaves the real problem: there is no proper authorization check proving that the sender is allowed to send on behalf of a specific device and organisation. Authentication and authorization are often confused. Authentication asks "who are you?"; authorization asks "are you allowed to do this?". Here the service relied on a static key shared by all MDE clients, and then trusted whatever identity the client claimed in the id fields.
In everyday terms: imagine a courier company that accepts any parcel as long as the sender writes the recipient's address on it, and never checks whether the sender actually works for the company named on the label. Anyone can post anything to anyone.
So anyone can send data on behalf of any organisation and machine, simply by editing the MachineId, OrgId and ComputerDnsName fields. It also works across tenants: logs can be sent to another organisation's tenant if that tenant's GUID is known. That GUID can be obtained by any user in the organisation or from any machine enrolled in MDE.
Proving it
As a proof of concept, the researchers captured some events from their own tenant and replayed them 20 times to a different tenant that they also owned, with the MachineId and ComputerDnsName fields changed. The result: when a MachineId does not yet exist, a new Device is added to MDE with whatever details were supplied.

The screenshot shows the device inventory with 20 "ghost" devices that do not really exist in the tenant.
What an attacker could do with it
With this flaw, an attacker could send any number of fake events to any Microsoft 365 environment, provided the OrgId is known. Those events could include fake alerts, which would cause fake incidents to be created for a security operations centre (SOC, the team that monitors alerts) to investigate. The practical damage is confusion: the defenders can no longer tell which incidents are real and which were planted.
Part 3: the fix
On 8 March 2022, Microsoft released a patch as part of the March Patch Tuesday (the monthly day on which Microsoft ships security updates), along with additional guidance on the MSRC blog.
The patch requires an update to the MDE client and adds anti-spoofing measures. Spoofing means pretending to be something you are not, in this case pretending to be another device or organisation. The Microsoft Defender for Endpoint client analyzer tool can be used to check whether a particular machine has been updated and whether the anti-spoofing measures are now enabled. Below is the output on a fully patched machine:

The screenshot shows the client analyzer reporting that the anti-spoofing capability has been deployed.
Besides the patch, Microsoft added the vulnerability to the Microsoft 365 Defender portal as a threat, with a dashboard showing how many devices in an environment are still vulnerable.

The screenshot shows an example graph of the number of vulnerable devices in an environment.
A new alert was also added, raised when someone attempts to exploit the flaw against a target environment. It is titled "Suspicious client communication". The researchers triggered it in their test environment by running their original proof-of-concept code, which sends spoofed events, but it only fired when they targeted the DeviceId of a fully patched machine.

The screenshot shows the alert raised when spoofed events are sent to the timeline of a patched machine.
How the fix works
The fix adds a way to authenticate the device that is sending logs, using a signed token similar to a JWT, passed in a newly added HTTP header named Custom-Request-Field. A JWT (JSON Web Token) is a compact string that carries a few claims about who you are, together with a cryptographic signature proving the claims were issued by someone trusted and have not been altered. Think of it as a tamper-evident ID card rather than a handwritten name tag.
The screenshot below shows an example of a decoded JWT token taken from the Custom-Request-Field header of a device with a fully patched version of Microsoft Defender for Endpoint.

The screenshot shows the new JWT token added as part of the patch.
The token contains the machineId and the orgId. Those values can be used to spot spoofing: if they do not match the orgId and machineId in the actual request, something is wrong.
Microsoft also appears to have added further measures limiting the ability to send data on behalf of a MachineId that does not exist. Such events appear to be dropped and no longer show up in the logging in the MDE portal.
Timeline
- 17 Aug 2021: vulnerability reported via the Microsoft MSRC portal.
- 20 Aug 2021: additional information provided to Microsoft, including Python proof-of-concept code.
- 15 Sep 2021: vulnerability acknowledged by Microsoft.
- 4 Nov 2021: the Microsoft team asks for more time before the issue can be fixed and requests that publication be postponed.
- 20 Nov 2021: the Microsoft team says the fix is complex and will take longer.
- 7 Feb 2022: word arrives that CVE-2022-23278 will be assigned and the vulnerability patched as part of the March Patch Tuesday.
- 8 Mar 2022: patch released by Microsoft.
- 1 April 2022: FalconForce publishes the full write-up, deliberately delayed to give organisations time to patch.
Glossary
- Adversary-in-the-Middle: an attack where someone secretly sits between your computer and a server, reading or altering the traffic.
- ApiKey: a fixed string used by software to identify itself to a service; here it was shared by all MDE clients.
- Authentication: proving who you are.
- Authorization: deciding whether an identified party is allowed to perform a particular action.
- Base64: a way of writing binary data using only ordinary text characters.
- Break-point: a place in a program where a debugger pauses execution so you can inspect what is happening.
- Certificate: a digital document, issued by a trusted authority, that proves a server's identity.
- Certificate pinning: a program accepting only one specific expected certificate rather than any trusted one, which blocks interception even with a rogue authority.
- Compression (deflate): shrinking data by encoding repeated patterns; reversible, unlike encryption.
- CVE: a public identifier for a known security vulnerability.
- Debugger: a tool that pauses a running program and lets you inspect and step through it.
- Debug server (dbgsrv.exe): a helper program that a debugger connects to over the network and that does the actual inspection of the target process.
- Driver: software that runs with deep privileges inside the operating system.
- Function: a named block of code that performs one job.
- GUID: a long, effectively unique identifier.
- HTTP header: a labelled line in a web request or response carrying metadata, such as the content type or an authentication value.
- JSON: a text format for structured data made of named fields and values.
- JWT (JSON Web Token): a compact, signed string carrying claims about identity, tamper-evident thanks to its signature.
- Kernel: the core layer of an operating system, beneath all ordinary programs.
- Kernel-mode debugging: debugging the operating system itself, which can see protected processes but freezes the whole machine at each break-point.
- Memory: the working area a running program uses to hold values.
- Microsoft Bond: a framework for turning structured data into bytes and back, similar to Protobuf.
- Offset: the number of bytes from the start of a structure to a particular field.
- OrgId: the GUID identifying the organisation whose tenant will receive the logs.
- PPL (Protected Process Light): a Windows feature that seals a process so other programs, even administrative ones, cannot inspect or modify it.
- Pointer: a value that gives the memory address of something, like a street address rather than the house.
- POST: the HTTP method used to send data to a server.
- Process: a running program, identified by a process ID (PID).
- Register: a small fixed slot inside the processor used to pass values, such as function arguments.
- Serialisation: turning structured data into a stream of bytes so it can be stored or transmitted.
- SOC: security operations centre, the team that monitors and investigates security alerts.
- Spoofing: pretending to be a device, person or organisation you are not.
- Structure: a bundle of related values stored together in memory.
- SYSTEM account: the most powerful built-in account on Windows.
- Tenant: one organisation's private slice of a cloud service.
- TLS: the encryption that protects data travelling over the internet, shown by the padlock in a browser.
- TrustedInstaller: a special Windows privilege level normally reserved for the component that installs and repairs Windows.
- WinDbg: Microsoft's debugger for Windows programs.