↓ Skip to main content
  1. Blog/

How to detect CIFSwitch

·3 mins·
The exploit in action

CIFSwitch (CVE-2026-46243) is a vulnerability found this year in Linux, between the kernel (CIFS subsystem) and the userspace helper cifs.upcall from the cifs-utils package. The vulnerability allows a local unprivileged user to escalate privileges to root and execute arbitrary code.

Root cause:

During Kerberos authentication for SMB mounts, the kernel queries the cifs.spnego key via keyrings, and the request-key (create cifs.spnego * * /usr/sbin/cifs.upcall %k) rule runs cifs.upcall as root.

Before the patch was released, the key type lacked vet_description: the kernel did not verify the origin of the description, and an unprivileged process could call request_key("cifs.spnego", <fake description>), while the helper considers pid, creduid, and upcall_target fields as trusted since they are received from the kernel.

The bug dates back to 2007 (f1d662a, kernel 2.6.24) and affects a large group of Linux distributions. The vulnerability has a CVSS of 7.1–7.8 (High), and PoC exploits are available on the Internet.

Attack mechanics:

  1. The user creates a user+mount namespace via unshare -Ur -m — a sandbox for the future root process.

  2. A fake nsswitch.conf and libnss_pwn.so.2 are bind-mounted over /etc/nsswitch.conf and NSS directories within the namespace. In parallel, mount -t cifs //127.0.0.1/share is performed to load the cifs module.

  3. request_key("cifs.spnego", "ver=0x2;...;uid=0x0;creduid=0x0;pid=<attacker_pid>;upcall_target=app;user=root") is called.

  4. The cifs.upcall helper with upcall_target=app executes switch_to_process_ns(pid) — switching to the attacker’s mount namespace — and before dropping privileges via setuid(), it calls getpwuid(0) -> NSS -> loading libnss_pwn.so.2 into the root-owned cifs.upcall.

  5. The .so library writes “ALL=(ALL:ALL) NOPASSWD: ALL” to /etc/sudoers.d/ or creates a SUID copy of bash in /var/tmp/cifsupcall_rootsh*; followed by a root shell. In general, any activity in now possible from cifs.upcall (see screenshot above).

Detection:

— request_key()/add_key() calls with cifs.spnego type from an unprivileged process: legitimate requests originate from the kernel under spnego_cred, userspace-initiated calls are anomalous.

— unshare -Ur -m call from a regular user: indicator of sandbox preparation.

— Bind-mount over /etc/nsswitch.conf, appearance of libnss_*.so in user directories.

— cifs.upcall activity: writes to /etc/sudoers.d/*, SUID files in /var/tmp, loading .so from atypical directories. Best correlation — modification of nsswitch.conf + loading NSS module into cifs.upcall

— PoC artifacts: /tmp/cifs-upcall-sudoers-poc-, SUID-shell /var/tmp/cifs_upcall_rootsh*, sudoers entry with comment “# cifs.upcall namespace NSS PoC”.

— mount -t cifs //127.0.0.1/share call from an unprivileged process (forced autoload).

Mitigation:

— Install the patched kernel with commit 3da1fdf4efbc (backport to all stable branches). The patch adds .vet_description, rejecting requests not from the kernel’s private spnego_cred.

— If CIFS is not needed: rmmod cifs and install cifs /bin/false in /etc/modprobe.d, remove cifs-utils.

— Disable unprivileged user namespaces user.max_user_namespaces=0; on Debian/Ubuntu — kernel.unprivileged_userns_clone=0): it breaks the attack chain, but can affect rootless containers.

Related