← all writeups

.NET: The CVE-2026-70197 Patch That Did Not Contain the Fix

High 2026-11-19 dotnet/runtime (System.Net.Sockets) CVE-2026-70197

Summary

CVE-2026-70197 is an out of bounds write in System.Net.Sockets on Windows. Reusing one SocketAsyncEventArgs across an IPv4 and then an IPv6 datagram socket leaves an undersized native address buffer in place, and the next receive writes a 28 byte sockaddr_in6 into a 16 byte block. Microsoft rated it CVSS 8.1, CWE-787, with a remote code execution impact and no authentication.

The advisory published on 2026-10-13 said the fix shipped in .NET 8.0.32, 9.0.21, 10.0.13 and 11.0.0-rc.2. It did not. The code that implements the vulnerable behavior was unchanged in every one of those builds, and the shipped 10.0.13 runtime still died with heap corruption on exactly the reuse the advisory described. Microsoft then confirmed the fix had been missed and re-released it in 8.0.33, 9.0.22, 10.0.14 and 11.0.0-rc.3.

Background

SocketAsyncEventArgs is the reusable, allocation free object behind the high throughput socket APIs (ReceiveFromAsync, ReceiveMessageFromAsync). Reuse is the entire point: a server allocates a pool of these objects once and hands the same instance to operation after operation to avoid per call garbage.

On Windows the receive path needs a native memory block to hold the source address that WSARecvFrom and WSARecvMsg fill in. That block is laid out as an 8 byte length field followed by the sockaddr. An IPv4 sockaddr_in needs 16 bytes; an IPv6 sockaddr_in6 needs 28. The block is managed by a single helper, AllocateSocketAddressBuffer.

The vulnerability

Here is the helper as it shipped, including in all four builds the October advisory named as fixed:

private unsafe void AllocateSocketAddressBuffer()
{
    //_socketAddress!.Size = SocketAddress.GetMaximumAddressSize(_socketAddress!.Family);
    int size = SocketAddress.GetMaximumAddressSize(_socketAddress!.Family);

    if (_socketAddressPtr == IntPtr.Zero)
    {
        _socketAddressPtr = (IntPtr)NativeMemory.Alloc((uint)(_socketAddress!.Size + sizeof(IntPtr)));
    }

    *((int*)_socketAddressPtr) = size;
}

Three facts combine into the write:

  1. The native block is allocated exactly once, the first time the instance is used. Its size is fixed by the address family in use at that first call: Size + 8. For an IPv4 first use that is 16 + 8 = 24 bytes, with 16 usable bytes after the length field.
  2. On every later use the method only rewrites the length field. The if guards the allocation on _socketAddressPtr == IntPtr.Zero, so once the block exists it is never grown. The commented out first line shows the size was also removed from the SocketAddress object itself.
  3. _socketAddress is replaced per operation when the family changes. Socket.cs sets e._socketAddress = Serialize(ref endPointSnapshot), so the IPv6 operation produces a 28 byte SocketAddress while the native block is still the 24 byte IPv4 sized one.

So on the second use with IPv6, size is 28 and that 28 is written into the length field of a block that has only 16 usable bytes behind it. DoOperationReceiveFrom then hands that pointer, with the length saying 28, to WSARecvFrom. Windows writes a full sockaddr_in6 and runs 12 bytes past the end of the allocation. DoOperationReceiveMessageFrom reaches the same place through WSARecvMsg. The write is into the native heap, with attacker chosen adjacency if the application pools and reuses these objects, which is the normal way to use them.

Why the October patch did not fix it

The interesting part is not the bug, which is a clean undersized buffer. It is that the advisory shipped with the wrong builds marked as fixed.

A comparison of the four named builds against their immediate predecessors shows no change in the relevant code:

  • Source, all 44 files under System.Net.Sockets/src/System/Net/Sockets: v8.0.31 against v8.0.32 is identical. v9.0.20 against v9.0.21 is identical. 10.0.12 against 10.0.13 differs only in an unrelated macOS empty sockaddr accept fix, nothing in SocketAsyncEventArgs.Windows.cs.
  • Decompiled IL, win-x64, metadata stripped: System.Net.Sockets.dll 8.0.31 against 8.0.32 is zero hunks. 10.0.12 against 10.0.13 and 11.0.0-rc.1 against 11.0.0-rc.2 are the same two macOS hunks. System.Net.Primitives.dll, which owns SocketAddress, is zero hunks in all of them.
  • AllocateSocketAddressBuffer is byte for byte identical in every build, commented out line and all.

The code the advisory described as fixed was the vulnerable code, unchanged.

Proof of concept

A single self contained console program demonstrates the consequence. It takes one SocketAsyncEventArgs, uses it for an IPv4 ReceiveMessageFromAsync, then uses the same instance for an IPv6 one. A control mode runs the same traffic but hands the IPv6 operation a fresh instance, which gets a correctly sized block.

var e = new SocketAsyncEventArgs();
e.SetBuffer(new byte[64]);

// First use: IPv4. Allocates Size(16) + 8 = 24 native bytes.
p4.SendTo(new byte[] { 1 }, s4.LocalEndPoint!);
e.RemoteEndPoint = new IPEndPoint(IPAddress.Any, 0);
if (s4.ReceiveMessageFromAsync(e)) done.Wait(5000);
done.Reset();

// Second use: IPv6. Length field becomes 28, allocation stays 24.
// In control mode a new instance gets a correctly sized allocation.
var e6 = reuse ? e : new SocketAsyncEventArgs();
p6.SendTo(new byte[] { 2 }, s6.LocalEndPoint!);
e6.RemoteEndPoint = new IPEndPoint(IPAddress.IPv6Any, 0);
if (s6.ReceiveMessageFromAsync(e6)) done.Wait(5000);

Run against a self contained .NET 10.0.13 runtime on Windows 11 (coreclr.dll 10.0.1326.50504):

control (fresh instance for the IPv6 op): 3 of 3 runs exit 0
reuse   (one instance across families):   crashes with 0xC0000374 (heap corruption)
loop    (reuse in a tight loop):           crashes within 6 to 7 rounds

The Windows Application event log records the fault inside the runtime itself, not in managed code:

Faulting application name: SocketsOob.exe
Faulting module name: coreclr.dll, version: 10.0.1326.50504
Exception code: 0xc0000005
Fault offset: 0x00000000001f79f1

0xC0000374 is STATUS_HEAP_CORRUPTION and 0xc0000005 is an access violation. The control, which never reuses the instance across families, never crashes.

Impact

The write is unauthenticated and reachable over the network. Any process that keeps a SocketAsyncEventArgs in a pool and uses it for UDP sockets of both address families fits the shape: a dual stack DNS resolver, a game server backend, anything that services IPv4 and IPv6 datagrams through shared pooled state. An attacker sends a datagram to the IPv6 socket that reuses an instance previously used on an IPv4 socket, and the receive overruns the native block.

Microsoft’s own rating is the ceiling here: CVSS 8.1, AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H, remote code execution, no authentication and no user interaction. The proof shown above is the reliable denial of service floor, a native heap corruption crash in the runtime. The corruption is the same primitive either way.

The fix

The real fix, which shipped in 10.0.14 and the matching 8.0.33, 9.0.22 and 11.0.0-rc.3 builds, rewrites the helper to size off the socket and to grow the block when it is too small:

private unsafe void AllocateSocketAddressBuffer()
{
    // Size off the socket's own family, not _socketAddress!.Family: callers of the SocketAddress-accepting
    // ReceiveFromAsync overload supply their own SocketAddress, whose Family isn't validated against the socket.
    int size = SocketAddress.GetMaximumAddressSize(_currentSocket!.AddressFamily);

    // The buffer may be reused across operations for sockets of different address families (e.g. a
    // SocketAsyncEventArgs reused across sockets), so grow it if the previously allocated size is too small.
    if (_socketAddressPtr == IntPtr.Zero || size > _socketAddressBufferSize)
    {
        if (_socketAddressPtr != IntPtr.Zero)
        {
            NativeMemory.Free((void*)_socketAddressPtr);
        }

        _socketAddressPtr = (IntPtr)NativeMemory.Alloc((uint)(size + sizeof(IntPtr)));
        _socketAddressBufferSize = size;
    }

    *((int*)_socketAddressPtr) = size;
}

Two changes close the bug. The size now comes from _currentSocket.AddressFamily rather than the per operation _socketAddress, and the allocation grows whenever size > _socketAddressBufferSize, with the current capacity tracked in a new field. A reused instance that moves from IPv4 to IPv6 now reallocates to 28 before the native call, so the write stays in bounds.

Timeline

  • 2026-10-13: CVE-2026-70197 published, naming 8.0.32, 9.0.21, 10.0.13 and 11.0.0-rc.2 as fixed.
  • 2026-10-19: Microsoft’s update guide notes the vulnerability has not been addressed and a complete mitigation is being prepared.
  • 2026-10-20: reported to Microsoft that the named builds carry no change in the described code, with the static comparison and a live 10.0.13 heap corruption crash.
  • 2026-11-03: advisory revised with the corrected fixed builds: 8.0.33, 9.0.22, 10.0.14 and 11.0.0-rc.3.
  • 2026-11-19: acknowledgement updated to credit the report.

Disclosure

Microsoft Security Update Guide: CVE-2026-70197. GitHub advisory: GHSA-4mpw-cpwj-hxxj. The first set of builds the advisory named as fixed did not contain the fix; it shipped in 8.0.33, 9.0.22, 10.0.14 and 11.0.0-rc.3.