CVE
CVE-2026-124757
CWE
CWE-78, CWE-863, CWE-150
Affected Surface
- Debian 12 bookworm, needrestart 3.6-4+deb12u3 (local root confirmed by the reporter)
- Ubuntu 24.04 LTS, needrestart 3.6-7ubuntu4.5 (local root confirmed by the reporter). Ubuntu lists 16.04, 18.04, 20.04, 22.04, 24.04, 26.04 and 26.10 as vulnerable
- Debian 13 trixie, forky and sid, needrestart 3.11-1 (session spoof and root notify-send with attacker-chosen DISPLAY and text; command execution not reproduced)
- Upstream needrestart before 3.11.1
- Exploitation of the notify hook needs /usr/bin/notify-send (libnotify-bin) on the host and a root run of needrestart, which the stock apt hook triggers after every apt or dpkg transaction
TL;DR
needrestart checks which running processes still use outdated libraries after a package upgrade. On Debian and Ubuntu its apt hook runs it as root after every apt or dpkg transaction, and it can notify logged-in users through hooks in /etc/needrestart/notify.d/.
Armaan Sandhu found that two of its assumptions combine into local root (CVE-2026-124757, assigned by Red Hat, disclosed 17 November 2026):
- needrestart decides which user and session a process belongs to by matching unanchored regexes against
/proc/PID/cgroup. On a systemd host a user can create subdirectories inside their own delegateduser@UID.servicecgroup. A directory nameduser-0.slice/session-1.scopemakes their process look like part of root’s login session. - The packaged
400-notify-sendhook puts the list of process names into asu -cshell string. A process picks its own name withprctl(PR_SET_NAME)(15 bytes). A name that closes the quote and adds shell syntax is executed by the shellsustarts, and with the forged session that shell runs as root.
The reporter confirmed root on Debian 12 bookworm (3.6-4+deb12u3) and Ubuntu 24.04 (3.6-7ubuntu4.5). On Debian 13 trixie (3.11-1) the session spoof works and notify-send runs as root with attacker-chosen DISPLAY and text, but command execution wasn’t reproduced. The attacker waits for the next root apt run, which includes routine upgrades by an admin. The reporter didn’t test unattended-upgrades.
The hook exits early unless /usr/bin/notify-send (package libnotify-bin) is installed, so hosts without it are not exposed to the root-shell path. They still get the session misclassification and the terminal-escape issue fixed alongside it.
What to do now:
- Install your distribution’s fixed
needrestartas soon as it ships. On 18 November neither Debian nor Ubuntu had one. Upstream fixed it in needrestart 3.11.1. - Until then, turn off the notify-send hook: add
NR_NOTIFYD_DISABLE_NOTIFY_SEND='1'to/etc/needrestart/notify.conf, or set$nrconf{sendnotify} = 0;in a file under/etc/needrestart/conf.d/. - On multi-user hosts and shared build machines, treat this as urgent: any local account, including a compromised service account, can wait for the next root
aptrun.
Affected packages and projects
| Ecosystem | Package | Affected versions | Fixed or safe version |
|---|---|---|---|
| Upstream | needrestart | before 3.11.1 | 3.11.1 (tagged 17 Nov 2026 20:30 UTC) and master after e8ae1f2 |
| Debian 12 bookworm | needrestart | 3.6-4+deb12u3 (root confirmed) | not fixed as of 18 Nov. Upstream says the second patch needs a backport to 3.6 |
| Debian 13 trixie, forky, sid | needrestart | 3.11-1 (session spoof, root notify-send) | not fixed as of 18 Nov |
| Ubuntu 24.04 LTS noble | needrestart | 3.6-7ubuntu4.5 (root confirmed) | not fixed as of 18 Nov |
| Ubuntu 16.04, 18.04, 20.04, 22.04, 26.04, 26.10 | needrestart | listed as vulnerable by Ubuntu | not fixed as of 18 Nov |
The reporter didn’t check other distributions. Upstream notes the notify hook runs whenever needrestart runs, so hosts that call needrestart from monitoring or configuration management, not only from apt, are exposed too.
Technical analysis
1. Filing a process under root’s session
needrestart reads each process’s cgroup path and runs it through a chain of regexes to work out the owning uid and session. From needrestart before the fix:
# `systemd --user` manager
if($cgroup =~ m@/user\@(\d+)\.service/init\.scope$@ && $ptable->{$pid}->{fname} ne "(sd-pam)") {
...
}
if($cgroup =~ m@/user-(\d+)\.slice/session-(\d+)\.scope@) { # <-- no ^ anchor
print STDERR "$LOGPREF #$pid part of user session: uid=$1 sess=$2\n" if($nrconf{verbosity} > 1);
push(@{ $sessions{$1}->{"session #$2"}->{ $ptable->{$pid}->{fname} } }, $pid);
next;
}
if($cgroup =~ m@/user\@(\d+)\.service(/.+\.slice)*/([^/]+\.service)$@) { ... }
if($cgroup =~ m@/user\@(\d+)\.service@) { ... }
- systemd delegates each user’s
user@UID.servicesubtree to that user, so they can create cgroup directories under it and move their own processes into them. - A real user service lives at something like
/user.slice/user-1000.slice/user@1000.service/app.slice/foo.service. That path doesn’t contain/user-N.slice/session-N.scopeback to back, so the session regex doesn’t match it. - If the user creates
.../user@1000.service/app.slice/x/user-0.slice/session-1.scopeand moves a process there, the unanchored session regex finds/user-0.slice/session-1.scopein the middle of the path and records the process under uid 0, session #1. It never reaches theuser@1000.servicechecks below.
The fix anchors all four matches so they only accept systemd’s slice components from the start of the path:
- if($cgroup =~ m@/user\@(\d+)\.service/init\.scope$@ && $ptable->{$pid}->{fname} ne "(sd-pam)") {
+ if($cgroup =~ m@^(?:/[^/]+\.slice)*/user\@(\d+)\.service/init\.scope$@ && $ptable->{$pid}->{fname} ne "(sd-pam)") {
...
- if($cgroup =~ m@/user-(\d+)\.slice/session-(\d+)\.scope@) {
+ if($cgroup =~ m@^(?:/[^/]+\.slice)*/user-(\d+)\.slice/session-(\d+)\.scope@) {
...
- if($cgroup =~ m@/user\@(\d+)\.service(/.+\.slice)*/([^/]+\.service)$@) {
+ if($cgroup =~ m@^(?:/[^/]+\.slice)*/user\@(\d+)\.service(/.+\.slice)*/([^/]+\.service)$@) {
...
- if($cgroup =~ m@/user\@(\d+)\.service@) {
+ if($cgroup =~ m@^(?:/[^/]+\.slice)*/user\@(\d+)\.service@) {
^(?:/[^/]+\.slice)* allows only .slice path components before the user slice or service, so text buried inside a user-owned subtree no longer matches (7874c08). The commit message notes this was tested against systemd layouts only, and container setups with a different cgroup prefix may now be classified differently.
2. Turning a process name into a root command
For each session with stale processes, needrestart runs the notify hooks with NR_USERNAME, NR_SESSION and NR_SESSPPID set, and passes the process list (names and PIDs) on stdin. The Debian and Ubuntu 3.6 hook (ex/notify.d/400-notify-send in upstream v3.6):
NSEND='/usr/bin/notify-send'
test -x "$NSEND" || exit 1 # no libnotify-bin: hook does nothing
case "$NR_SESSION" in
session*)
DBUS_SESSION_BUS_ADDRESS=$(sed -z -n s/^DBUS_SESSION_BUS_ADDRESS=//p "/proc/$NR_SESSPPID/environ")
export DISPLAY=$(sed -z -n s/^DISPLAY=//p "/proc/$NR_SESSPPID/environ")
...
if [ -z "$DISPLAY" ]; then exit 1; fi # attacker sets DISPLAY in their own environ
MSGTITLE=$(gettext 'Relogin or restarts required!')
MSGBODY=$(gettext '...')'\n'$(cat) # stdin: "<process name>[<pid>]" list
su -p -s /bin/sh -c "$NSEND -a needrestart -u critical -i dialog-warning \"$MSGTITLE\" \"$MSGBODY\"" "$NR_USERNAME"
;;
esac
NR_USERNAMEisrootbecause of the forged session, sosu ... rootstarts/bin/shas root.$MSGBODYis expanded by the outer shell into the-cstring beforesuruns. The inner root shell then parses it again. A process name containing"followed by shell syntax breaks out of the quoted argument.- The
DISPLAYcheck reads the environment of the session’s process, which the attacker controls, so it doesn’t stop anything.
The fix passes the text through the environment so the inner shell only ever expands it as data (b1996a1):
- MSGTITLE=$(gettext 'Relogin or restarts required!')
- MSGBODY=$(gettext 'Your session is running obsolete binaries or libraries as listed below.
+ NR_NOTIFY_TITLE=$(gettext 'Relogin or restarts required!')
+ NR_NOTIFY_BODY=$(gettext 'Your session is running obsolete binaries or libraries as listed below.
<i><b>Please consider a relogin or restart of the affected processes!</b></i>')'\n'$(cat)
- su -p -s /bin/sh -c "$NSEND -a needrestart -u critical -i dialog-warning \"$MSGTITLE\" \"$MSGBODY\"" "$NR_USERNAME"
+ # Pass the text to su through the environment: the inner shell expands it as
+ # data, so process names in the body are never parsed as shell code.
+ export NR_NOTIFY_TITLE NR_NOTIFY_BODY
+
+ su -p -s /bin/sh -c "$NSEND -a needrestart -u critical -i dialog-warning \"\$NR_NOTIFY_TITLE\" \"\$NR_NOTIFY_BODY\"" "$NR_USERNAME"
The \$ escapes keep the variable names literal in the -c string. su -p preserves the environment, so the root shell substitutes the values inside double quotes, where they stay one argument each.
3. Escape sequences in process names
The third patch (e8ae1f2) replaces every byte outside printable ASCII with ? in displayed process names and in the text sent to hooks:
- push(@{$fnames{ $ptable->{$pid}->{fname} }}, $pid);
+ push(@{$fnames{ $ptable->{$pid}->{fname} =~ s/[^\x20-\x7e]/?/gr }}, $pid);
Before it, a process name could carry terminal escape sequences into the admin’s apt output, or a newline that split a line of the machine-readable NEEDRESTART-PID output.
4. Why trixie behaves differently
On trixie’s 3.11-1 the reporter could still forge root’s session and get notify-send run as root with the attacker’s DISPLAY and text, but didn’t reproduce command execution. The upstream patch series applies to 3.11 with offsets, and the fix to the hook’s quoting is needed there too. Treat trixie as affected and patch it: a root notify-send talking to an attacker-chosen X display isn’t something to leave in place.
IOCs
This is a local privilege escalation with no malware or network component. Signs of an attempt:
| Type | Indicator | Notes |
|---|---|---|
| cgroup | Directories named user-<N>.slice or session-<N>.scope nested inside any user@<UID>.service subtree under /sys/fs/cgroup | legitimate systemd layouts never put these below a user service |
| Process | Processes whose comm contains ", ;, $(, backticks, ` | or&` |
| Process | su -p -s /bin/sh -c /usr/bin/notify-send ... running as root with a body containing shell metacharacters | visible in process accounting or auditd execve records during apt runs |
| Log | needrestart verbose output reporting part of user session: uid=0 for a process owned by a non-root user | run needrestart -v -b to see classifications |
Detection and remediation
# 1. Installed version
dpkg-query -W needrestart
# 2. Is the notify-send hook able to run? (no libnotify-bin = no root-shell path)
dpkg -s libnotify-bin 2>/dev/null | grep -E '^(Status|Version)'
ls -l /etc/needrestart/notify.d/400-notify-send
# 3. Look for forged session directories inside user service subtrees
find /sys/fs/cgroup -path '*/user@*.service/*' \( -name 'user-*.slice' -o -name 'session-*.scope' \) 2>/dev/null
# 4. Look for processes with shell metacharacters in their names
for p in /proc/[0-9]*; do c=$(cat "$p/comm" 2>/dev/null); case "$c" in *[\"\;\$\`\|\&]*) echo "${p#/proc/} $c";; esac; done
# 5. Past root shells spawned by the hook (if auditd records execve)
ausearch -m EXECVE -i 2>/dev/null | grep -E 'notify-send.*dialog-warning' | head
Mitigate now, then upgrade when your distribution ships a fix:
# Option A: disable only the notify-send hook
echo "NR_NOTIFYD_DISABLE_NOTIFY_SEND='1'" | sudo tee -a /etc/needrestart/notify.conf
# Option B: stop needrestart sending any user notifications
echo '$nrconf{sendnotify} = 0;' | sudo tee /etc/needrestart/conf.d/99-no-notify.conf
# Option C (desktop-free servers): remove libnotify-bin if nothing needs it
sudo apt-get remove libnotify-bin
# Later: take the fixed package
sudo apt-get update && sudo apt-get install --only-upgrade needrestart
Apply the mitigation before your next apt run on a multi-user host, since that run is the trigger. If you find forged cgroup directories or suspicious process names, treat the host as rooted: review /etc/sudoers*, /root/.ssh/authorized_keys, setuid binaries and systemd units changed since the last apt run.
Timeline
| Date (UTC) | Event |
|---|---|
| 2026-10-23 | Armaan Sandhu reports the issue to needrestart upstream |
| 2026-11-05 | Reported to the Debian and Ubuntu security teams |
| 2026-11-08 | Reported to the linux-distros list |
| 2026-11-17 12:15 | Upstream commits b1996a1, 7874c08 and e8ae1f2 |
| 2026-11-17 20:30 | Coordinated disclosure (21:30 CET). Upstream tags security release v3.11.1 |
| 2026-11-17 20:45 | Write-up posted to oss-security |
| 2026-11-17 | Ubuntu publishes the CVE with priority High |
| 2026-11-18 | Debian (bookworm, trixie, forky, sid) and Ubuntu (16.04 to 26.10) still list the package as vulnerable |
From research to remediation
Check whether this pattern exists in your codebase
Turn this research into a remediation workflow. Scan dependencies and package manifests for similar supply-chain risk, then prioritize fixes with reachability context.
References
- oss-security (17 November 2026), Armaan Sandhu: needrestart, local root via a forged session cgroup and the notify-send hook (CVE-2026-124757)
- Fix 1/3: liske/needrestart commit b1996a1, notify.d: pass the notification text to su through the environment
- Fix 2/3: liske/needrestart commit 7874c08, needrestart: anchor the systemd cgroup matches
- Fix 3/3: liske/needrestart commit e8ae1f2, needrestart: replace non-ASCII and control characters in process names
- needrestart v3.11.1 security release tag
- Debian security tracker: CVE-2026-124757
- Ubuntu CVE tracker: CVE-2026-124757 (priority High)