[remoting][win] Harden remote WebAuthn NMH trust verification [chromium/src : main]

0 views
Skip to first unread message

Yuwei Huang (Gerrit)

unread,
May 15, 2026, 7:45:27 PM (6 days ago) May 15
to chromium...@chromium.org, chromotin...@chromium.org

Yuwei Huang added 3 comments

File remoting/host/webauthn/remote_webauthn_caller_security_utils.cc
Line 115, Patchset 7 (Latest): if (base::PathService::Get(base::DIR_SYSTEM, &system_dir)) {
Yuwei Huang . unresolved

If Chrome is 64-bit but this native messaging host is 32-bit, `base::PathService::Get(base::DIR_SYSTEM, &system_dir)` will return `C:\\Windows\\SysWOW64` due to WOW64 redirection. However, the 64-bit Chrome launches `C:\\Windows\\System32\\cmd.exe`. This will cause the path comparison below to fail and reject the legitimate caller.

To avoid this bitness mismatch issue, you can check if `parent_image_path.BaseName().value() == L"cmd.exe"`. This is still secure because we skip to the grandparent and check if the grandparent is an allowed caller program signed by Google.

File remoting/host/win/trust_util.cc
Line 61, Patchset 7 (Latest): std::wstring subject_name;
Yuwei Huang . unresolved

You can simplify this string allocation and avoid the manual null-terminator search by using `base::WriteInto` (from `"base/strings/string_util.h"`). `base::WriteInto` reserves `length` elements and correctly sets the size of the string to `length - 1`, expecting the Windows API to write the trailing null.

```cpp
std::wstring subject_name;
CertGetNameStringW(cert_context, CERT_NAME_SIMPLE_DISPLAY_TYPE, /*dwFlags=*/0,
/*pvTypePara=*/nullptr,
base::WriteInto(&subject_name, length), length);
```
Line 120, Patchset 7 (Latest): wintrust_data.dwStateAction = WTD_STATEACTION_CLOSE;
Yuwei Huang . unresolved

According to the [Microsoft documentation](https://learn.microsoft.com/en-us/windows/win32/api/wintrust/nf-wintrust-winverifytrust):
> If the WinVerifyTrust function returns a failure code, you should not call the WinVerifyTrust function again with the dwStateAction member set to WTD_STATEACTION_CLOSE.

Since you're calling it unconditionally, you should move this close operation inside the `if (trust_status == ERROR_SUCCESS)` block. (The original code had a memory leak by not calling this at all on success, so good catch on fixing that!).

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: I0e3c2b156381c3114133567b5c4822662d0ff6e1
Gerrit-Change-Number: 7853762
Gerrit-PatchSet: 7
Gerrit-Owner: Yuwei Huang <yuw...@chromium.org>
Gerrit-Comment-Date: Fri, 15 May 2026 23:45:16 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Yuwei Huang (Gerrit)

unread,
May 15, 2026, 9:12:06 PM (6 days ago) May 15
to chromium...@chromium.org, chromotin...@chromium.org

Yuwei Huang voted and added 3 comments

Votes added by Yuwei Huang

Commit-Queue+1

3 comments

File remoting/host/webauthn/remote_webauthn_caller_security_utils.cc
Line 115, Patchset 7: if (base::PathService::Get(base::DIR_SYSTEM, &system_dir)) {
Yuwei Huang . resolved

If Chrome is 64-bit but this native messaging host is 32-bit, `base::PathService::Get(base::DIR_SYSTEM, &system_dir)` will return `C:\\Windows\\SysWOW64` due to WOW64 redirection. However, the 64-bit Chrome launches `C:\\Windows\\System32\\cmd.exe`. This will cause the path comparison below to fail and reject the legitimate caller.

To avoid this bitness mismatch issue, you can check if `parent_image_path.BaseName().value() == L"cmd.exe"`. This is still secure because we skip to the grandparent and check if the grandparent is an allowed caller program signed by Google.

Yuwei Huang

Done

File remoting/host/win/trust_util.cc
Line 61, Patchset 7: std::wstring subject_name;
Yuwei Huang . resolved

You can simplify this string allocation and avoid the manual null-terminator search by using `base::WriteInto` (from `"base/strings/string_util.h"`). `base::WriteInto` reserves `length` elements and correctly sets the size of the string to `length - 1`, expecting the Windows API to write the trailing null.

```cpp
std::wstring subject_name;
CertGetNameStringW(cert_context, CERT_NAME_SIMPLE_DISPLAY_TYPE, /*dwFlags=*/0,
/*pvTypePara=*/nullptr,
base::WriteInto(&subject_name, length), length);
```
Yuwei Huang

Done

Line 120, Patchset 7: wintrust_data.dwStateAction = WTD_STATEACTION_CLOSE;
Yuwei Huang . resolved

According to the [Microsoft documentation](https://learn.microsoft.com/en-us/windows/win32/api/wintrust/nf-wintrust-winverifytrust):
> If the WinVerifyTrust function returns a failure code, you should not call the WinVerifyTrust function again with the dwStateAction member set to WTD_STATEACTION_CLOSE.

Since you're calling it unconditionally, you should move this close operation inside the `if (trust_status == ERROR_SUCCESS)` block. (The original code had a memory leak by not calling this at all on success, so good catch on fixing that!).

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: I0e3c2b156381c3114133567b5c4822662d0ff6e1
    Gerrit-Change-Number: 7853762
    Gerrit-PatchSet: 8
    Gerrit-Owner: Yuwei Huang <yuw...@chromium.org>
    Gerrit-Reviewer: Yuwei Huang <yuw...@chromium.org>
    Gerrit-Comment-Date: Sat, 16 May 2026 01:11:45 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    Comment-In-Reply-To: Yuwei Huang <yuw...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Yuwei Huang (Gerrit)

    unread,
    May 15, 2026, 9:31:22 PM (6 days ago) May 15
    to Chromium LUCI CQ, chromium...@chromium.org, chromotin...@chromium.org

    Yuwei Huang voted Commit-Queue+1

    Commit-Queue+1
    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: I0e3c2b156381c3114133567b5c4822662d0ff6e1
    Gerrit-Change-Number: 7853762
    Gerrit-PatchSet: 9
    Gerrit-Owner: Yuwei Huang <yuw...@chromium.org>
    Gerrit-Reviewer: Yuwei Huang <yuw...@chromium.org>
    Gerrit-Comment-Date: Sat, 16 May 2026 01:31:14 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Yuwei Huang (Gerrit)

    unread,
    May 15, 2026, 9:34:31 PM (6 days ago) May 15
    to Joe Downing, Chromium LUCI CQ, chromium...@chromium.org, chromotin...@chromium.org
    Attention needed from Joe Downing

    Yuwei Huang voted and added 1 comment

    Votes added by Yuwei Huang

    Auto-Submit+1

    1 comment

    Patchset-level comments
    File-level comment, Patchset 9 (Latest):
    Yuwei Huang . resolved

    PTAL thanks!

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Joe Downing
    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: I0e3c2b156381c3114133567b5c4822662d0ff6e1
    Gerrit-Change-Number: 7853762
    Gerrit-PatchSet: 9
    Gerrit-Owner: Yuwei Huang <yuw...@chromium.org>
    Gerrit-Reviewer: Joe Downing <joe...@chromium.org>
    Gerrit-Reviewer: Yuwei Huang <yuw...@chromium.org>
    Gerrit-Attention: Joe Downing <joe...@chromium.org>
    Gerrit-Comment-Date: Sat, 16 May 2026 01:34:22 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Joe Downing (Gerrit)

    unread,
    May 20, 2026, 12:15:40 PM (yesterday) May 20
    to Yuwei Huang, Code Review Nudger, Chromium LUCI CQ, chromium...@chromium.org, chromotin...@chromium.org
    Attention needed from Yuwei Huang

    Joe Downing voted

    Code-Review+1
    Commit-Queue+2
    Open in Gerrit

    Related details

    Attention is currently required from:
    • Yuwei Huang
    Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement 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: I0e3c2b156381c3114133567b5c4822662d0ff6e1
      Gerrit-Change-Number: 7853762
      Gerrit-PatchSet: 9
      Gerrit-Owner: Yuwei Huang <yuw...@chromium.org>
      Gerrit-Reviewer: Joe Downing <joe...@chromium.org>
      Gerrit-Reviewer: Yuwei Huang <yuw...@chromium.org>
      Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
      Gerrit-Attention: Yuwei Huang <yuw...@chromium.org>
      Gerrit-Comment-Date: Wed, 20 May 2026 16:15:24 +0000
      Gerrit-HasComments: No
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      open
      diffy

      Chromium LUCI CQ (Gerrit)

      unread,
      May 20, 2026, 1:33:57 PM (yesterday) May 20
      to Yuwei Huang, Joe Downing, Code Review Nudger, chromium...@chromium.org, chromotin...@chromium.org

      Chromium LUCI CQ submitted the change

      Change information

      Commit message:
      [remoting][win] Harden remote WebAuthn NMH trust verification

      * Use PathService instead of environment variables to query paths.
      * Update IsBinaryTrusted to verify that a binary is signed by Google.

      Verified: Tweaked code locally and verified that the logic works
      properly for verifying the NMH caller (Chrome). Saw the "Signature
      verified and publisher pinned for" log. Could not verify mojo caller
      trust because the caller (e.g. desktop process) is unsigned, but it
      should work as expected. I'll try ToT official build once CL is
      submitted.
      Bug: 502372527
      Change-Id: I0e3c2b156381c3114133567b5c4822662d0ff6e1
      Commit-Queue: Joe Downing <joe...@chromium.org>
      Auto-Submit: Yuwei Huang <yuw...@chromium.org>
      Reviewed-by: Joe Downing <joe...@chromium.org>
      Cr-Commit-Position: refs/heads/main@{#1633684}
      Files:
      • M remoting/host/webauthn/remote_webauthn_caller_security_utils.cc
      • M remoting/host/win/trust_util.cc
      Change size: M
      Delta: 2 files changed, 159 insertions(+), 60 deletions(-)
      Branch: refs/heads/main
      Submit Requirements:
      • requirement satisfiedCode-Review: +1 by Joe Downing
      Open in Gerrit
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: merged
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: I0e3c2b156381c3114133567b5c4822662d0ff6e1
      Gerrit-Change-Number: 7853762
      Gerrit-PatchSet: 10
      Gerrit-Owner: Yuwei Huang <yuw...@chromium.org>
      Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
      Gerrit-Reviewer: Joe Downing <joe...@chromium.org>
      Gerrit-Reviewer: Yuwei Huang <yuw...@chromium.org>
      open
      diffy
      satisfied_requirement
      Reply all
      Reply to author
      Forward
      0 new messages