ENGINEERING

needrestart local root (CVE-2026-124757): check your Debian and Ubuntu machines and switch off the hook

Armaan Sandhu published CVE-2026-124757 on oss-security on November 17, the disclosure date agreed with the Linux distributions. It’s a local privilege escalation in needrestart, the tool that runs after every apt or dpkg run as root on Debian and Ubuntu and tells you which services need restarting. A user who can log in to the machine can get root. No exploitation has been reported.

How it works

needrestart decides which user session a process belongs to by matching the text of its cgroup path, and the match isn’t anchored. A user can create a matching folder inside their own user@UID.service cgroup, and their process then looks like part of root’s session.

needrestart’s notify-send hook (/etc/needrestart/notify.d/400-notify-send) then pops up “Relogin or restarts required!” for that session, using the process name. On Debian 12 and Ubuntu 24.04 the hook pastes that name into a command string that su runs through a shell as root, and the process sets its own name. The next apt upgrade runs the user’s commands as root.

Debian 13 is partly affected. Its hook passes the text to runuser as separate arguments, so the name can’t run as commands, but the spoof still makes notify-send run as root with a display and text the user picks.

Where the fixes are

DistributionneedrestartStatus on November 17
Ubuntu 24.043.6-7ubuntu4.6Fixed (noble-security, November 16)
Debian 12 (bookworm)3.6-4+deb12u3Vulnerable, no fixed package yet (Debian tracker)
Debian 13 (trixie)3.11-1Partly affected

Upstream has a three-patch fix: pass the notification text through environment variables, anchor the cgroup matches, and strip non-printable characters from process names.

Check one machine

dpkg-query -W needrestart
grep -n "su -p\|runuser" /etc/needrestart/notify.d/400-notify-send
ls -l /usr/bin/notify-send

On an unpatched Debian 12 the hook’s su line puts $MSGTITLE straight inside the quotes:

51:    su -p -s /bin/sh -c "$NSEND -a needrestart -u critical -i dialog-warning \"$MSGTITLE\" \"$MSGBODY\"" "$NR_USERNAME"

Ubuntu’s fixed package escapes it, so the shell reads the text from the environment instead of running it:

55:    su -p -s /bin/sh -c "$NSEND -a needrestart -u critical -i dialog-warning \"\$NR_NOTIFY_TITLE\" \"\$NR_NOTIFY_BODY\"" "$NR_USERNAME"

The hook exits at its first check when /usr/bin/notify-send is missing. It comes from libnotify-bin, which desktops have and most servers don’t, so a server without it can’t be attacked through this hook until someone installs a package that pulls libnotify-bin in.

Switch off the hook

needrestart has its own setting for this, so nothing needs deleting:

echo "NR_NOTIFYD_DISABLE_NOTIFY_SEND='1'" | sudo tee -a /etc/needrestart/notify.conf

The hook then prints disabled in global config and exits. needrestart still lists and restarts services after updates. Desktop users stop getting its restart pop-up. notify.conf is a config file, so a needrestart package update keeps your change. Take the line out once the fixed package is installed if you want the pop-up back.

What I found in the lab

I installed the real needrestart packages in throwaway Debian 12, Debian 13 and Ubuntu 24.04 containers and read the hooks. I didn’t try the exploit.

RFF’s Linux agent runs apt-get with NEEDRESTART_SUSPEND=1 so needrestart can’t restart services in the middle of a job. I checked needrestart’s apt hook: with that variable set it exits before running needrestart, so updates RFF runs don’t trigger the hook. Updates anyone runs by hand, and unattended-upgrades, still do.

What to do

  1. Check every Debian and Ubuntu machine for needrestart and its hook.
  2. On Ubuntu 24.04, install 3.6-7ubuntu4.6.
  3. On Debian 12, switch the hook off until Debian ships a fixed package, then install it.
  4. On Debian 13, switch the hook off or wait for Debian’s fix.
  5. Start with machines where people who aren’t admins can log in.

Doing it with RFF

The RFF Script Library has two new Linux entries. “needrestart local root (CVE-2026-124757) - Exposure Check” reads the installed hook rather than a version list, so it works on any distribution, and reports each machine as vulnerable, partly affected, fixed or switched off, with the needrestart version and whether notify-send is installed. “needrestart notify-send hook - Turn Off” sets the switch above and reads it back the way the hook does, with a dry run and an undo that puts notify.conf back byte for byte. I ran both against the three containers above: each verdict matched, and turn off, check, undo and check again came back as expected on Debian 12 and 13.

RFF is free for your first 100 endpoints: getrff.com.

Sources

One email per new post, nothing else. Unsubscribe in one click. Or use the RSS feed.

Comments

Comments use GitHub Discussions, so you'll need a GitHub account to post. Corrections are especially welcome.