[remoting] Fix PID-reuse TOCTOU in IsTrustedMojoEndpoint [chromium/src : main]

0 views
Skip to first unread message

Yuwei Huang (Gerrit)

unread,
Apr 21, 2026, 10:10:42 PM (2 days ago) Apr 21
to android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, chromium...@chromium.org, chromotin...@chromium.org

Yuwei Huang added 4 comments

File components/named_mojo_ipc_server/connection_info.h
Line 39, Patchset 4 (Latest): base::Process process;
Yuwei Huang . unresolved

Like `audit_token` and `credentials`, consider wrapping `process` in `#if BUILDFLAG(IS_WIN)` since it's only populated and used on Windows.

File components/named_mojo_ipc_server/endpoint_options.h
Line 77, Patchset 4 (Latest): bool should_open_caller_process = false;
Yuwei Huang . unresolved

Since `should_open_caller_process` is only implemented and relevant on Windows, consider wrapping it in `#if BUILDFLAG(IS_WIN)` (similar to `require_same_peer_user` for Linux). This prevents confusion and misuse on other platforms.

File components/named_mojo_ipc_server/named_mojo_server_endpoint_connector_win.cc
Line 188, Patchset 4 (Latest): OnError();
Yuwei Huang . unresolved

If the client process terminates immediately after connecting, `OpenWithAccess` will fail. Calling `OnError()` here introduces a 3-second delay (`kRetryConnectionTimeout`) before the server accepts new connections. A malicious local user could exploit this to perform a DoS attack on the IPC server by continuously connecting and terminating.

Instead of `OnError()`, you should just drop the invalid connection and listen for the next one:
```cpp
ResetConnectionObjects();
Connect();
```
(Note: You might want to consider doing the same for the `GetNamedPipeClientProcessId` failure above.)
File remoting/host/mojo_caller_security_checker.cc
Line 74, Patchset 4 (Latest): CHECK(caller.process.IsValid());
Yuwei Huang . unresolved

If another IPC server uses this security checker but doesn't set `should_open_caller_process = true` in its `EndpointOptions`, this `CHECK` will crash the entire host process upon any connection. To prevent a misconfiguration from becoming a Denial-of-Service vector, consider logging an error and returning `false` instead:

```cpp
if (!caller.process.IsValid()) {
LOG(ERROR) << "caller.process is invalid. Was should_open_caller_process set to true?";
return false;
}
```
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ie9624c8e279baf1aed8ff2ba53ef98f717332ff5
Gerrit-Change-Number: 7782841
Gerrit-PatchSet: 4
Gerrit-Owner: Yuwei Huang <yuw...@chromium.org>
Gerrit-Reviewer: Yuwei Huang <yuw...@chromium.org>
Gerrit-Comment-Date: Wed, 22 Apr 2026 02:10:37 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Yuwei Huang (Gerrit)

unread,
Apr 21, 2026, 11:01:54 PM (2 days ago) Apr 21
to android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, chromium...@chromium.org, chromotin...@chromium.org

Yuwei Huang added 6 comments

File components/named_mojo_ipc_server/connection_info.h
Line 39, Patchset 4: base::Process process;
Yuwei Huang . resolved

Like `audit_token` and `credentials`, consider wrapping `process` in `#if BUILDFLAG(IS_WIN)` since it's only populated and used on Windows.

Yuwei Huang

Done

File components/named_mojo_ipc_server/endpoint_options.h
Line 77, Patchset 4: bool should_open_caller_process = false;
Yuwei Huang . resolved

Since `should_open_caller_process` is only implemented and relevant on Windows, consider wrapping it in `#if BUILDFLAG(IS_WIN)` (similar to `require_same_peer_user` for Linux). This prevents confusion and misuse on other platforms.

Yuwei Huang

Done

File components/named_mojo_ipc_server/named_mojo_server_endpoint_connector_win.cc
Line 184, Patchset 5 (Latest):#if BUILDFLAG(IS_WIN)
Yuwei Huang . unresolved

This file is specific to Windows (`_win.cc`), so `BUILDFLAG(IS_WIN)` is guaranteed to be true here. You can safely remove the `#if` guards.

Line 188, Patchset 4: OnError();
Yuwei Huang . resolved

If the client process terminates immediately after connecting, `OpenWithAccess` will fail. Calling `OnError()` here introduces a 3-second delay (`kRetryConnectionTimeout`) before the server accepts new connections. A malicious local user could exploit this to perform a DoS attack on the IPC server by continuously connecting and terminating.

Instead of `OnError()`, you should just drop the invalid connection and listen for the next one:
```cpp
ResetConnectionObjects();
Connect();
```
(Note: You might want to consider doing the same for the `GetNamedPipeClientProcessId` failure above.)
Yuwei Huang

Done

File remoting/host/mojo_caller_security_checker.cc
Line 67, Patchset 5 (Parent): // TODO: yuweih - see if it's possible to move away from PID-based security
Yuwei Huang . unresolved

Since this CL resolves the PID-reuse issue for Windows by using the pinned process handle, consider updating this TODO to reflect that this is now only a concern for non-Windows platforms (or remove it if Windows was the primary concern).

Line 74, Patchset 4: CHECK(caller.process.IsValid());
Yuwei Huang . resolved

If another IPC server uses this security checker but doesn't set `should_open_caller_process = true` in its `EndpointOptions`, this `CHECK` will crash the entire host process upon any connection. To prevent a misconfiguration from becoming a Denial-of-Service vector, consider logging an error and returning `false` instead:

```cpp
if (!caller.process.IsValid()) {
LOG(ERROR) << "caller.process is invalid. Was should_open_caller_process set to true?";
return false;
}
```
Yuwei Huang

Done

Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ie9624c8e279baf1aed8ff2ba53ef98f717332ff5
Gerrit-Change-Number: 7782841
Gerrit-PatchSet: 5
Gerrit-Comment-Date: Wed, 22 Apr 2026 03:01:46 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Yuwei Huang <yuw...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Yuwei Huang (Gerrit)

unread,
Apr 22, 2026, 3:36:10 AM (2 days ago) Apr 22
to android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, chromium...@chromium.org, chromotin...@chromium.org, droger+w...@chromium.org

Yuwei Huang voted and added 2 comments

Votes added by Yuwei Huang

Commit-Queue+1

2 comments

File components/named_mojo_ipc_server/named_mojo_server_endpoint_connector_win.cc
Line 184, Patchset 5:#if BUILDFLAG(IS_WIN)
Yuwei Huang . resolved

This file is specific to Windows (`_win.cc`), so `BUILDFLAG(IS_WIN)` is guaranteed to be true here. You can safely remove the `#if` guards.

Yuwei Huang

Done

File remoting/host/mojo_caller_security_checker.cc
Line 67, Patchset 5 (Parent): // TODO: yuweih - see if it's possible to move away from PID-based security
Yuwei Huang . resolved

Since this CL resolves the PID-reuse issue for Windows by using the pinned process handle, consider updating this TODO to reflect that this is now only a concern for non-Windows platforms (or remove it if Windows was the primary concern).

Yuwei Huang

Done

Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ie9624c8e279baf1aed8ff2ba53ef98f717332ff5
    Gerrit-Change-Number: 7782841
    Gerrit-PatchSet: 9
    Gerrit-Comment-Date: Wed, 22 Apr 2026 07:36:05 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    Comment-In-Reply-To: Yuwei Huang <yuw...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy
    Reply all
    Reply to author
    Forward
    0 new messages