alpine-chrome icon indicating copy to clipboard operation
alpine-chrome copied to clipboard

How move forward with chromium removing --remote-debugging-address=0.0.0.0 ?

Open evandrocoan opened this issue 1 year ago • 3 comments

Describe the bug Chromium removed the --remote-debugging-address=0.0.0.0 option, now it does nothing.

There is this issue open https://issues.chromium.org/issues/41487252, [bug] Flag --remote-debugging-address does not work as expected

But it looks like the do not care and are doing nothing about it, by stating:

--remote-debugging-address switch presents a security issue and should not be used. We are planning to remove it from the old headless and there are no plans to implement it in the new headless.

I looked around the chromium source code, and figured out this patch to force 0.0.0.0 instead of 172.0.0.1:

diff --git a/chrome/browser/devtools/remote_debugging_server.cc b/chrome/browser/devtools/remote_debugging_server.cc
index bc8a7d1402a99..bcfec1f560f7b 100644
--- a/chrome/browser/devtools/remote_debugging_server.cc
+++ b/chrome/browser/devtools/remote_debugging_server.cc
@@ -49,9 +49,10 @@ class TCPServerSocketFactory
   std::unique_ptr<net::ServerSocket> CreateLocalHostServerSocket(int port) {
     std::unique_ptr<net::ServerSocket> socket(
         new net::TCPServerSocket(nullptr, net::NetLogSource()));
-    if (socket->ListenWithAddressAndPort(
-            "127.0.0.1", port, kBackLog) == net::OK)
+    if (socket->ListenWithAddressAndPort("0.0.0.0", port, kBackLog) ==
+        net::OK) {
       return socket;
+    }
     if (socket->ListenWithAddressAndPort("::1", port, kBackLog) == net::OK)
       return socket;
     return nullptr;

diff --git a/content/browser/devtools/devtools_http_handler.cc b/content/browser/devtools/devtools_http_handler.cc
index a24477b920c5f..2e2451c533bce 100644
--- a/content/browser/devtools/devtools_http_handler.cc
+++ b/content/browser/devtools/devtools_http_handler.cc
@@ -284,7 +284,8 @@ void StartServerOnHandlerThread(
   std::unique_ptr<ServerWrapper> server_wrapper;
   std::unique_ptr<net::ServerSocket> server_socket =
       socket_factory->CreateForHttpServer();
-  std::unique_ptr<net::IPEndPoint> ip_address(new net::IPEndPoint);
+  std::unique_ptr<net::IPEndPoint> ip_address(
+      new net::IPEndPoint(net::IPAddress(0, 0, 0, 0), 9222));
   if (server_socket) {
     server_wrapper =
         std::make_unique<ServerWrapper>(handler, std::move(server_socket),

Can we manage to include our own patched chromium with this fix or can we use something like, this, which will forward port ip:9222 to localhost:9223:

socat TCP-LISTEN:9222,fork TCP:127.0.0.1:9223 &
chromium --headless --disable-gpu --no-sandbox --remote-debugging-port=9223

Related:

  1. #225
  2. #158

evandrocoan avatar Jul 01 '24 04:07 evandrocoan

Rather than patching chromium could a simple proxy be added that listens on 0.0.0.0 and redirects to 172.0.0.1?

boris-moduscreate avatar Jan 03 '25 23:01 boris-moduscreate

As @boris-moduscreate said, a simple proxy could be useful here. Competitors solved in that way:

https://github.com/chromedp/docker-headless-shell/blob/master/run.sh#L5

achetronic avatar Mar 20 '25 23:03 achetronic

In case you need a reference, I adopted the socat proxy approach (with s6-overlay to handle crashes) in my fork: patte/alpine-chromium. It works with chromium 135+.

patte avatar Apr 11 '25 15:04 patte