Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid client serialwhen nesting proxies #67

Open
uninsane opened this issue Jan 26, 2025 · 1 comment
Open

Invalid client serialwhen nesting proxies #67

uninsane opened this issue Jan 26, 2025 · 1 comment

Comments

@uninsane
Copy link

xdg-dbus-proxy generally fails to proxy messages when its upstream dbus path is another instance of xdg-dbus-proxy instead of the root dbus session.

repro

configure a session bus at /tmp/bus1, a filtering proxy from /tmp/bus2 to that session bus, and then another proxy at /tmp/bus3 to /tmp/bus2:

# start a dbus session (or skip this step if already running a dbus session, and replace /tmp/bus1 with $DBUS_SESSION_BUS_ADDRESS in the later invocations)
$ dbus-daemon --session --address=unix:path=/tmp/bus1
$ xdg-dbus-proxy unix:path=/tmp/bus1 /tmp/bus2 --log --filter '--call=org.freedesktop.portal.Desktop=*' &
$ xdg-dbus-proxy unix:path=/tmp/bus2 /tmp/bus3 --log --filter '--call=org.freedesktop.portal.Desktop=*' &

applications can generally speak to the outer xdg-dbus-proxy at /tmp/bus2, but not the inner proxy at /tmp/bus3:

$ DBUS_SESSION_BUS_ADDRESS=unix:path=/tmp/bus2 busctl --user list
NAME                     PID PROCESS        USER  CONNECTION UNIT              SESSION DESCRIPTION
:1.1                 1277488 xdg-dbus-proxy colin :1.1       session-167.scope 167     -
org.freedesktop.DBus 1277488 xdg-dbus-proxy colin -          session-167.scope 167     -
$ DBUS_SESSION_BUS_ADDRESS=unix:path=/tmp/bus3 busctl --user list
Failed to list names: Transport endpoint is not connected

upon connecting to /tmp/bus3, the xdg-dbus-proxy proxying from /tmp/bus2 to /tmp/bus1 logs:

WARNING **: Invalid client serial: Exceeds maximum value of 4294901759
@uninsane
Copy link
Author

4f081c7 looks relevant to this. in this we initialize the proxy with

client->last_fake_serial = MAX_CLIENT_SERIAL; 

then we generate fake messages to the upstream bus like:

  client->last_fake_serial++;
  g_dbus_message_set_serial (message, client->last_fake_serial);
  buffer = message_to_buffer (message);
  queue_outgoing_buffer (&client->bus_side, buffer);

when receiving client messages in got_buffer_from_client (FlatpakProxyClient *client, ProxySide *side, Buffer *buffer), we decode the serial:

header = parse_header (buffer, &error);
if (header->serial > MAX_CLIENT_SERIAL) {
  g_warning ("Invalid client serial: Exceeds maximum value of %u", MAX_CLIENT_SERIAL);
  // and terminate the client 
}  

xdg-dbus-proxy intentionally generates messages above MAX_CLIENT_SERIAL and sends these bus-side. but since it expects to never receive such messages from the client side, xdg-dbus-proxy cannot operate as a client to another xdg-dbus-proxy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant