-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## ProbeForWrite was honest. Its caller was not.\n\n`ProbeForWrite` is the kernel's user-mode pointer validator. Its body opens with a single gate: if `Length` is zero, return. The Windows Driver Kit headers have carried this behaviour for two decades, and every kernel programming guide written since explains it the same way. With `Length=0` there is no region to inspect, because the caller is performing a sizing query and the function should not have anything to write. The validator's response to \"no bytes to validate\" is to skip validation. The caller's response should be to skip writes.\n\n`ExpQuerySystemInformation` is the dispatcher that sits behind `NtQuerySystemInformation`. It calls `ProbeForWrite(buffer, Length, alignment)` once, near the top of its body, and then routes to a per-class handler based on the `SystemInformationClass` argument. For info classes 5 (`SystemProcessInformation`), 0x39, 0x94, 0xFC, and 0xFD (`SystemProcessInformationExtension`, decimal 253), that handler is `ExpGetProcessInformation`.\n\nThe probe returned because there was nothing to probe. The handler started.\n\n## The length check is in the code. So is the loop that follows it.\n\nOri Nimron's reverse-engineering of `ExpGetProcessInformation` in `ntoskrnl.exe` (Windows 11 build 26200.8328) names the shape of the bug in nine lines, simplified here for readability:\n\n```c\n__int64 ExpGetProcessInformation(unsigned int *buffer, unsigned int length,\n unsigned int *returnSize, void *unused,\n int infoClass)\n{\n v91 = buffer; // attacker-named pointer, from NtQuerySystemInformation\n\n if (infoClass == 252) {\n v86 = v91;\n } else {\n v86 = NULL;\n if (infoClass == 253) {\n v95 = v91; // class 253 binds v95 to the attacker pointer\n goto LABEL_11;\n }\n // class 5 path uses v81; does not touch v95\n }\n v95 = NULL; // class 252 falls through here, with v95 zeroed\n\nLABEL_11:\n status = STATUS_SUCCESS;\n if (length < 12) {\n status = STATUS_INFO_LENGTH_MISMATCH; // error is recorded\n // NO return.\n }\n\n while (NextProcess) {\n // ... per-process accounting ...\n if (infoClass == 253) {\n ++*v95; // *(uint32_t*)(addr+0) += 1\n v95[1] += threadCount; // *(uint32_t*)(addr+4) += per-process thread count\n v95[2] += handleCount; // *(uint32_t*)(addr+8) += per-process handle count\n }\n NextProcess = NextProcess->Flink;\n }\n\n return status;\n}\n```\n\nThe control flow that produces CVE-2026-40369 is the boundary between line 14 and line 17. The check on `length < 12` is reachable, it runs, it computes the error value, and it stores `STATUS_INFO_LENGTH_MISMATCH` into the slot that the function will eventually return. The function does not return. The loop below it executes with `v95` pointing wherever the caller said.\n\nFor a class 253 call from usermode, that pointer is the second argument of `NtQuerySystemInformation`. The caller supplies `0xffff800041424344` and `Length=0`. `ProbeForWrite` returns immediately because there are no bytes to write. `ExpGetProcessInformation` reaches its length check, marks the failure, and proceeds into the loop. For each process on the system, the loop writes three DWORDs at the kernel address the caller named.\n\nThe basic PoC in `basic_poc/basic_poc.cpp` is sixty-four lines and ends with the line that does it:\n\n```c\nNTSTATUS status = pNtQSI(\n SystemProcessInformationExtension,\n target, /* kernel address; ProbeForWrite skipped because Length=0 */\n 0, /* Length=0 bypasses ProbeForWrite entirely */\n &needed\n);\n```\n\nThe kernel writes. Then it returns `0xC0000004` (`STATUS_INFO_LENGTH_MISMATCH`) to the caller. The caller, in usermode, sees the failure code and learns nothing it did not already know. The increment is already on the address.\n\nThis is what fail-open-intercept looks like in C kernel dialect. The pattern is well-established in our exhibits in higher-level runtimes: Tomcat's `EncryptInterceptor` catches `GeneralSecurityException` and calls `super.messageReceived(msg)` outside the try; DataEase's `CommunityTokenFilter` writes a 401 inside a catch and then calls `filterChain.doFilter()` after it; Xerte's `connector.php` issues `header('Location: ...')` and falls through to the upload handler because PHP's `header()` does not terminate. The verdict was reached. The listener was wired to a channel the verdict never entered.\n\n`ExpGetProcessInformation` is the same shape one stack frame lower than the language. The error code goes into a local variable named `status`. The conditional that gates the writes is `infoClass == 253`, not `status == 0`. The error and the writes occupy different state. The function does not consult its own verdict before acting.\n\n## Class 253 reuses v95. Classes 5 and 252 do not.\n\nThe five info classes that route through `ExpGetProcessInformation` were not written together. Class 5 (`SystemProcessInformation`) has been in `ntoskrnl.exe` since Windows NT 3.1, and reads through a local variable named `v81` in the decompile. Class 252 (`SystemProcessInformationWithExtension`, the first variant) reads through `v86`. Class 253 (`SystemProcessInformationExtension`, the version that returns the per-process Pico-process and container extensions) reads through `v95`. The other two classes that share the function, 0x39 and 0x94, take different code paths and do not touch the user buffer the way classes 5, 252, and 253 do.\n\nClasses 5 and 252 perform an explicit NULL check on `v81` and `v86` before dereferencing inside the per-process loop. Class 253 does not. The handler for 253 binds `v95 = v91` at line 8 of the simplified function, jumps past the NULL-or-zero check that the other classes execute, and proceeds straight into `LABEL_11`. The check is in the function. It is on the path the other classes take. It is not on the path class 253 takes.\n\nThis is the across-info-classes variant of parallel-implementation-gap. The capability (\"read per-process accounting into a caller-named buffer\") is implemented five times in one function, dispatched by a switch on `infoClass`. Four of those implementations share a NULL/sentinel check before the dereference. The fifth, written separately to support a newer info class, reuses a different local and inherited none of the older paths' precautions. We have seen this shape across packages (Astro shipped two `/_image` endpoints, only one read the allowlist), across runtimes (MLflow's basic-auth gated Flask but not three FastAPI routers), across upload-versus-download directions (mcp-atlassian's path patch hardened both downloads and neither upload), and across branches of one function (Axios's `maxContentLength` lived inside the buffered branch's counter and the streaming branch had no counter to attach it to). CVE-2026-40369 is the same shape compressed into one function's switch arms.\n\nThe check the divergent path is missing is not exotic. It is the same NULL test the other arms run, three lines higher in the same body of code. The handler for class 253 has the local variable that holds the user pointer and the variable that stores the length-mismatch error. It does not have the line that would return.\n\n## Length zero was the contract. The kernel signed the contract and then broke it.\n\n`ProbeForWrite`'s body, as it ships in `ntoskrnl.exe`, reads roughly:\n\n```c\nvoid ProbeForWrite(volatile void *Address, SIZE_T Length, ULONG Alignment)\n{\n if (Length) {\n // ... alignment check ...\n // ... range check against MmUserProbeAddress ...\n // ... touch each page in the range to fault user-mapped memory ...\n }\n}\n```\n\nThe gate at the top is the kernel's way of saying: when `Length` is zero, there is nothing for me to check and nothing for my caller to write. The contract is reflexive. It binds both ends. The caller is supposed to read it and not write.\n\n`NtQuerySystemInformation` is a sizing-aware API. The documented usage pattern is two calls. First with `SystemInformationLength=0` to retrieve the required size via `ReturnLength`, then again with an allocated buffer of the named size. The contract that `ProbeForWrite` encodes is the API contract: `Length=0` is the sizing call. No writes happen in a sizing call.\n\n`ExpGetProcessInformation` for class 253 does not honour the contract. It records `STATUS_INFO_LENGTH_MISMATCH` because it can see the buffer is too small, and then it writes to the buffer because the writes are not gated on the buffer size. The error code is the caller's signal that no writes happened. The kernel sets it after the writes happen.\n\nClasses 5 and 252 honour the contract because their per-process loop checks `v81 != NULL` or `v86 != NULL` before each dereference. Class 253 does not, because the divergent module's author copied the loop body without copying the check.\n\n## NtQuerySystemInformation is reachable from the Chrome renderer.\n\nMicrosoft Edge, Google Chrome, and every other Chromium browser run their renderer processes inside the Windows sandbox implementation in `chromium/sandbox/win/`. The renderer's primary token is `USER_LOCKDOWN`: every group SID is deny-only, the only restricting SID is the NULL SID `S-1-0-0`, the user's own SID is deny-only, every privilege has been removed, and the integrity level is `UNTRUSTED`. The process runs inside a job object with `JOB_OBJECT_LIMIT_ACTIVE_PROCESS=1` and `JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE`. Win32k system calls are disabled via `ProcessSystemCallDisablePolicy`. Child-process creation is blocked. Image loads are restricted to Microsoft-signed binaries. By design, the renderer is the most-constrained process Microsoft ships.\n\n`NtQuerySystemInformation` is not in the blocked-syscall set. The Chromium codebase calls it directly, in `base/process/process_metrics_win.cc` and several other places, to introspect the renderer itself. Removing it would break the diagnostics the renderer depends on. The syscall is callable from inside the lockdown token.\n\nCVE-2026-40369's primitive is one syscall. `NtQuerySystemInformation(SystemProcessInformationExtension, attackerAddr, 0, &needed)`. The kernel does not inspect the token's privileges, integrity level, or restricting SIDs before executing the loop that writes to `v95`. It iterates the active-process list, which any unprivileged process can already enumerate, and increments three DWORDs at the address the caller named. The token's integrity could be `UNTRUSTED`. The token's privileges could be zero. The restricting SID could be `S-1-0-0`. The writes happen.\n\nThe third directory in Ori Nimron's repository, `full_poc_with_chrome_sandbox_emulator/`, is fourteen hundred lines of C that reverse-engineers `chromium/sandbox/win/src/restricted_token.cc`, `restricted_token_utils.cc`, `sandbox_policy_base.cc`, `broker_services.cc`, `target_services.cc`, and `sandbox/policy/win/sandbox_win.cc`, and constructs a renderer-equivalent sandbox in-process. The broker creates a lockdown primary token with the NULL SID as the only restricting SID, then an `USER_RESTRICTED_SAME_ACCESS` impersonation token, then a kLockdown job object, sets the impersonation token on the suspended child thread, resumes the child, and the child calls its own `LowerToken()` that sets `UNTRUSTED` integrity, `RevertToSelf`s into the lockdown primary, applies twelve process mitigations including `ProcessSystemCallDisablePolicy`, and runs eleven verification tests.\n\nThe eleven tests:\n\n```c\ntest_integrity(); // Token integrity = Untrusted\ntest_deny_only_sids(); // All non-logon SIDs deny-only\ntest_user_sid_deny_only(); // User SID deny-only\ntest_restricting_sids(); // Restricting SID = NULL SID (S-1-0-0)\ntest_privileges(); // All privileges stripped (count=0)\ntest_file_access(); // File read denied (kernel32.dll)\ntest_registry_access(); // Registry read denied (HKLM\\SOFTWARE)\ntest_process_creation(); // Process creation blocked\ntest_job_object(); // Process in job object\ntest_desktop_isolation();\ntest_write_access(); // Write access denied\n```\n\nEleven tests prove the sandbox is real. After the eleventh, the code calls `exp()`, which is the full kernel exploit chain. The author did not need to claim reachability. He shipped a process that builds the most-constrained Windows token there is and then escapes it.\n\n## One arbitrary increment, used three ways.\n\nThe basic PoC writes to one address and crashes. The full PoC in `full_poc/full_poc.cpp` does six things with the same primitive.\n\nThe first use is to corrupt `CmpLayerVersionCount`, a global in the registry component of `ntoskrnl.exe`, until the count is high enough that index 9 of `CmpLayerVersions[]` becomes reachable. That moves the increment from a one-time bug into a means of bumping a counter past a bounds check.\n\nThe second use is to corrupt `CmpLayerVersions[9]` itself, one DWORD at a time, until the pointer it holds matches a usermode allocation at `0x10000` that the exploit has filled with a fake `_FAKE_VERSION_STRUCT`. The fake struct contains a `UNICODE_STRING64` whose `Buffer` field is the kernel address the attacker wants to read.\n\nThe third use is no longer the bug itself. With `CmpLayerVersions[9]` redirected to attacker-controlled memory, `NtQuerySystemInformationEx(SystemBuildVersionInformation, &index=9, ...)` reads through the fake `UNICODE_STRING64`, dereferences the kernel address the attacker named, downcasts the wide-string at that address into a UTF-8 narrow-string, and returns the bytes. CVE-2026-40369's increment has been parlayed into a kernel arbitrary read.\n\nThe fourth use walks `PsInitialSystemProcess`, follows `ActiveProcessLinks`, finds the current process's `EPROCESS`, and reads the token `EX_FAST_REF` at offset `0x248`. Masking the bottom four bits gives the token pointer.\n\nThe fifth use returns to the original increment. The exploit names `token + 0x42` (the `Privileges.Enabled` bitmap) and increments the DWORD until the bit for `SeDebugPrivilege` is set. Then it names `token + 0x42 + 12` (the `Privileges.Present` bitmap) and does the same. The current process now has `SeDebugPrivilege` enabled.\n\nThe sixth step is what `SeDebugPrivilege` is for: `OpenProcess(PROCESS_ALL_ACCESS, FALSE, 796)`, where `796` is the PoC's hardcoded winlogon PID, then `VirtualAllocEx`, `WriteProcessMemory` with a `cmd.exe`-spawning Win32 shellcode, and `CreateRemoteThread`. The renderer process has just executed code as `NT AUTHORITY\\SYSTEM`.\n\nOne arbitrary kernel DWORD increment. Three roles in the same chain. One missing return statement in `ExpGetProcessInformation`.\n\n## The CVSS vector measures a different threat model.\n\nNVD scored CVE-2026-40369 as `CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H`. `PR:L` is \"low privileges required,\" which is the standard rating for an LPE that runs from any logged-in user account.\n\nThe PoC ran from a process whose token had been reduced to: every group SID deny-only, every privilege stripped, NULL SID as the only restricting SID, Untrusted integrity. The thirteen lines of `test_privileges()` verify that the privilege count is zero before `exp()` is called. There is no privilege below zero. CVSS 3.1 does not have a vector value for \"fewer privileges than a logged-in user.\" It assumes the lowest meaningful privilege level is \"low,\" because every other case is \"none required.\"\n\n`NtQuerySystemInformation` is callable from a token with zero privileges. The PoC measured the chain inside a Chrome-renderer-equivalent token and ran to completion. The vector did not foresee that operational case, because the vector predates the threat model in which a single Windows process is supposed to be more constrained than a logged-in user.\n\n## What is in Ori Nimron's repository.\n\nThree things. A 64-line basic reproducer that does the arbitrary increment. A full chain that turns the increment into SYSTEM by reusing the same primitive in three roles, with the help of a type-confusion in `SystemBuildVersionInformation`. And a 1400-line replica of Chrome's renderer sandbox whose only job is to demonstrate that none of the sandbox's restrictions affect the syscall the chain depends on.\n\nThe bug is one absence of a return statement after a length check fires in `ExpGetProcessInformation` for info class 253. The handlers for classes 5 and 252 have the equivalent guard. The handler for 253 does not, because it was written separately and reused a different local variable. The mismatch was recorded as the function's return value. The writes happened first.\n\nPoC: [orinimron123/CVE-2026-40369-EXPLOIT](https://github.com/orinimron123/CVE-2026-40369-EXPLOIT)","closing_line":"`ExpGetProcessInformation` set `STATUS_INFO_LENGTH_MISMATCH` as the return value. Then it did the writes.","hook_md":"The check fires. `ExpGetProcessInformation` reads `Length=0`, evaluates `length < 12`, computes `STATUS_INFO_LENGTH_MISMATCH`, and stores the status as the function's return value. The function does not return. It walks the active-process list, and for every process it increments three DWORDs at the unvalidated kernel pointer the caller named.\n\n`ProbeForWrite(buffer, 0, alignment)` returned to its caller without inspecting the address, because the documented contract is that `Length=0` means no writes happen downstream. The next function on the stack inherited that contract and walked straight through it.","post_id":368,"slug":"ntoskrnl-cve-2026-40369-mismatch-then-writes","title":"CVE-2026-40369: ntoskrnl Set STATUS_INFO_LENGTH_MISMATCH And Did The Writes Anyway","type":"initial","unreadable_sentence":"`ExpGetProcessInformation` set `STATUS_INFO_LENGTH_MISMATCH` as the return value. Then it did the writes."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCakqU8QAKCRDeZjl4jgkQ JmVIAQCSAiEl0PkzpbaAPgBJ3iOjLsBBzbl/8Gz/bPb4jJ6LXgD/cKuex32AY1bU wC3iMo1umfKyMKZOHplgwhTDhvFziwY= =ENoG -----END PGP SIGNATURE-----