freenode
Security & Cryptography

needrestart bug lets local users become root on Debian and Ubuntu

CVE-2026-124757 is triggered when package tools run the utility as root; Debian trixie is only partly affected.

A local user can gain root on Debian bookworm and Ubuntu 24.04 through needrestart, the utility those distributions run after package operations to report which services should be restarted. Armaan Sandhu reported the flaw, tracked as CVE-2026-124757 and assigned by Red Hat, after a coordinated disclosure agreed on linux-distros that closed on 17 November 2026.

needrestart decides which login session a process belongs to by searching the text of that process's cgroup path. The search is not anchored, so a local user can plant a directory name that makes their own process look like it belongs to root's session. The packaged notification hook then treats the process's self-chosen name as text to display. On the confirmed vulnerable packages, Debian's needrestart 3.6-4+deb12u3 and Ubuntu 24.04's 3.6-7ubuntu4.5, that name is placed in a shell command run through su. A root shell parses the string and runs the attacker's commands as root.

Sandhu reproduced the issue in a lab, with root as the only target. The stock apt hook is enough: any apt or dpkg invocation as root runs needrestart afterward. The tests used apt-get. unattended-upgrades was not tested. Upstream also notes that the notify hook runs whenever needrestart runs, so hosts that invoke it from monitoring or other automation, not only from apt, can be exposed. Other distributions' packages were not checked.

Debian trixie, shipping needrestart 3.11-1, is only partly affected. A local user can still make the tool treat their process as root's session, and the packaged hook then runs notify-send as root with a display and message the attacker chooses. Command execution was not reproduced there.

The fix passes notification text through environment variables, anchors the systemd cgroup matches, and strips non-printable characters from that text. It applies, with offsets, to needrestart 3.11. On the 3.6 line one of the changes does not apply cleanly and needs a backport. Upstream said the patches would be added to its git repository at disclosure. Updated packages should be taken from each distribution's security advisories.