Native Messaging is a powerful capability for building extensions that need to interact with the rest of the system. However, over the years, users have reported a trail of bugs related to how the feature is implemented on Windows. While these bugs are typically only seen in uncommon configurations, they could break Native Messaging entirely for some users.
Some examples include:
I have landed a changelist in Chromium to improve this scenario for version 113.0.5656 and later. This change means that Chrome, Edge, and other Chromium-derived browsers will now directly invoke any Native Host that is a Windows Executable (.exe) rather than going through cmd.exe instead:
Native Hosts that are not implemented by executables (e.g. Python scripts or the like) will continue to use the old codepath.
Beyond fixing the somewhat obscure bugs, this change also fixes two other bugs that were caused by the old flow and those changes could cause problems if your Windows executable was not aware of the expected behavior for Native Hosts.
In particular:
1) Chrome will now start a Native Host implemented as a Windows app (subsystem:Windows) hidden, as it is designed to do. You must explicitly call ShowWindow() if your host is supposed to be visible.
2) Chrome will now successfully kill the Native Host 2 seconds after it closes its connection to the Native Host (if Chrome is still running). This is intentional.
Edge and other Chromium-derived browsers will pick up the new behavior when their merge pumps catch up to HEAD.
Thanks for reading!
-Eric
--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/43623aa5-7bc2-445c-ab38-a3d9eb1c86b7n%40chromium.org.
https://chromestatus.com/roadmap has Chrome’s release schedule.
This change landed in Chrome 113, which will reach the Stable channel in 4 weeks (Apr 26, 2023). It’s currently in the Dev Channel.
(Edge should have this change in the next Canary, and it will reach Stable the same week Chrome does).
Thanks,
-Eric
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/47ea4980-8256-4e26-b339-93424c60c193n%40chromium.org.
Ah. In addition to requiring the outdated (and unlisted) legacy extension, this repro also requires the old version 7 build of 1Password from https://app-updates.agilebits.com/download/OPW7 . That older installer registers the random-character version of the host.
And indeed, when you look at the log, you find that the v7 client deliberately refuses the connection from the new browser:
14144 2023-04-17 23:55:23 419.326s ERR opw_app::managers::browser_manager:52 > failed to validate browser. Error: opw-app\src\nmh.rs:133 untrusted chromium browser
Unfortunately for this scenario, there's no easy end-user workaround because 1Password deliberately does not allow connections from unknown callers, and their logic to identify the caller is now incorrect. Based on the logs, it appears what happens is that 1Password.exe walks up the process tree, from 1Password.exe to Chrome.exe to whatever launched Chrome.exe.
If you launched Chrome from Explorer, you'll see:
14144 2023-04-18 00:00:38 740.156s ERR opw_app::managers::browser_manager:52 > failed to validate browser. Error: opw-app\src\nmh.rs:133 untrusted chromium browser
name: explorer, publisher: Microsoft Windows, pid: 9104, session id: 1, path: C:\Windows\explorer.exe, version: 10.0.19041.2846
Whereas if you launched Chrome from the SlickRun launcher, you'll see:
14144 2023-04-18 00:04:39 970.081s ERR opw_app::managers::browser_manager:52 > failed to validate browser. Error: opw-app\src\nmh.rs:133 untrusted chromium browser
name: sr, publisher: Eric Lawrence, pid: 13424, session id: 1, path: C:\Program Files\SlickRun\sr.exe, version: 4.4.9.2
While other NativeHosts requiring the old behavior could be easily accommodated (e.g. by pointing the manifest.json at a simple batch file that launches the client), 1Password cannot be fixed like this because their anti-tampering logic forbids it.
Similarly, even debugging this issue with Chromium isn't possible (e.g. by reverting the change), because the debug builds aren't signed and thus are rejected by their anti-tamper logic.
--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/29ec7955-2f9c-4c64-bc7f-73823ea1ac02n%40chromium.org.
--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/881abca3-83ef-4ead-8f03-1f11bd39cbcbn%40chromium.org.
Eric,I tested (briefly) in Canary (Version 113.0.5657.0 (64-bit) under Win10) and I did not see any issues.My Native Host is a C# console application. I did not see any issues with reading stdin or writing to stdout.My Native Host launches a separate executable to interact with the user when necessary. For example, the user can save data to a file on their local disk, and my Native Host app uses the prompt app to let the user specify the path via a standard Windows Save File dialog. I forget the details, but when I used the Native Host exe to open a File Save dialog, the window did not always open as the foreground window. That may have been more a C# console application issue than something Chrome was/is doing. Anyway, my prompt application uses ShowWindow and that was not affected by any change in Chrome Canary.I did not see any issue when shutting down the browser. My log file shows an orderly shutdown where my Native Host receives a zero-length message via stdin. I write a status file and then write a "stopping" log message. That should occur in less than 2 seconds. I suppose there could be an I/O issue or some other delay that causes an issue. I will see what I can do about that.John
The "Directly Launch Native Hosts" feature has now relanded inside Chrome Canary version 115.0.5789.0.
It’s off-by-default, behind a flag on the chrome://flags#launch-windows-native-hosts-directly page.
The equivalent change will appear in Edge in a week or so. The next step is for me to land a Group Policy that would allow admins to turn this on for users in restricted environments (Cloud PCs that forbid cmd.exe, for example).
For improved compatibility, in the re-landed version of this change that is available in Chrome Canary 115+, Chrome will now look at headers inside of the target EXE. If the executable targets SUBSYSTEM:CONSOLE, the |start_hidden| flag will be set to true. If it targets SUBSYSTEM:WINDOWS (indicating a GUI application), the start_hidden flag will NOT be set.