Public bug reported:

    [ Impact ]

    gnome-remote-desktop's system daemon (the headless / "system mode" RDP path
    used to log in remotely to a GNOME session on servers and cloud instances)
    double-unrefs a floating GVariant in on_handle_start_handover()
    (src/grd-daemon-system.c).

    The redirect-parameters GVariant is passed to 
g_dbus_connection_emit_signal(),
    which sinks and consumes its floating reference.  The same variable was also
    declared g_autoptr(GVariant), so it is unref'd a second time when the 
function
    returns -- dropping a reference the daemon no longer owns.

    The handover-start signal is emitted on the normal connection path: every 
RDP
    connection that moves from the login screen (GDM greeter) to a user session
    triggers it.  This is not an exotic edge case.

    On a build with assertions enabled the second unref aborts at
    g_atomic_ref_count_dec().  On Ubuntu's production build (assertions 
disabled)
    it is instead a silent use-after-free: it corrupts memory rather than
    aborting, which can destabilise or crash the system daemon and, once it 
does,
    block subsequent RDP logins until the daemon is restarted.

    Affected release: Ubuntu 26.04 LTS (resolute), gnome-remote-desktop
    50.2-0ubuntu0.1.  Later releases ship GNOME 51, which already contains the
    fix; 26.04 is on the grd 50 series and needs the backport.

    [ Test Plan ]

    On an Ubuntu 26.04 machine with gnome-remote-desktop configured in system
    mode (headless RDP login, as used by cloud desktop images):

      1. Enable the system daemon and set credentials, e.g.
           sudo grdctl --system rdp enable
           sudo grdctl --system rdp set-credentials <user> <pass>
           sudo grdctl --system rdp disable-view-only
         and ensure the daemon is listening on :3389.
      2. From a client (mstsc, Windows App, or xfreerdp), connect repeatedly and
         complete the greeter -> user-session handover each time; include a few
         connections that are dropped a second or two into establishment (abort
         while still at / just past the greeter).  A loop of 20-30 connect/abort
         cycles is enough.

    This is a race, so reproduction is probabilistic.  To make it deterministic
    for verification, run the system daemon under valgrind (or an
    assertions-enabled / ASan build): the unfixed package shows an invalid
    read/free (or a g_atomic_ref_count_dec assertion) originating in
    on_handle_start_handover during a handover; the fixed package completes the
    same connect/abort loop with no invalid free and no daemon crash.

    [ Where problems could occur ]

    The change is minimal and self-contained: it removes the g_autoptr 
annotation
    from one local and moves two locals (connection, redirect_variant) into the
    single branch that uses them, in on_handle_start_handover() only.  There is 
no
    API/ABI change and nothing outside the system-daemon handover path is 
touched.

    If the change were wrong, the failure mode would be a GVariant *leak* on the
    handover path (the opposite of the current double-free) -- a slow, bounded
    memory growth under repeated connections, not a crash or a regression in
    functionality.  User-mode grd (per-session screen sharing) does not use this
    code path and is unaffected.

    [ Other Info ]

    Upstream issue:  
https://gitlab.gnome.org/GNOME/gnome-remote-desktop/-/issues/354
    Upstream fix:    
https://gitlab.gnome.org/GNOME/gnome-remote-desktop/-/merge_requests/435
                     commit c82b4ed4eebba35ac3966b02eced417046cc33ab
                     ("daemon-system: Don't unref the RedirectClient parameters 
twice")
    Merged upstream 2026-10-20, milestone GNOME 51.  The fix is a strict subset 
of
    the 50 -> 51 delta on this function and cherry-picks onto 50.2 (please 
confirm
    on upload).

** Affects: gnome-remote-desktop (Ubuntu)
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2174636

Title:
  gnome-remote-desktop system daemon double-unrefs a floating GVariant
  during handover (double-free / use-after-free on every greeter→session
  login)

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gnome-remote-desktop/+bug/2174636/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to