mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Casey Schaufler <casey@schaufler-ca.com>
To: Andy Lutomirski <luto@amacapital.net>, Andy Lutomirski <luto@kernel.org>
Cc: "Hallgrimur H. Gunnarsson" <halg@google.com>,
	"Christian Brauner" <brauner@kernel.org>,
	"Serge Hallyn" <sergeh@kernel.org>,
	"Paul Moore" <paul@paul-moore.com>,
	"James Morris" <jmorris@namei.org>,
	"David Howells" <dhowells@redhat.com>,
	"Jarkko Sakkinen" <jarkko@kernel.org>,
	"Kees Cook" <kees@kernel.org>, "Jonathan Corbet" <corbet@lwn.net>,
	"Shuah Khan" <skhan@linuxfoundation.org>,
	"Randy Dunlap" <rdunlap@infradead.org>,
	"Mickaël Salaün" <mic@digikod.net>,
	"Jonathan Calmels" <jcalmels@3xx0.net>,
	"Jann Horn" <jannh@google.com>,
	"Günther Noack" <gnoack@google.com>,
	"Singh KP" <kpsingh@kernel.org>,
	linux-fsdevel@vger.kernel.org,
	linux-security-module@vger.kernel.org, linux-api@vger.kernel.org,
	containers@lists.linux.dev, keyrings@vger.kernel.org,
	linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	"Casey Schaufler" <casey@schaufler-ca.com>
Subject: Re: [PATCH v2 1/4] userns: introduce capability bounding set for user namespaces
Date: Mon, 23 Nov 2026 09:22:29 -0800	[thread overview]
Message-ID: <4db941ba-3001-4019-8910-63e534b29f89@schaufler-ca.com> (raw)
In-Reply-To: <CALCETrV=zSxb6sgA08DLiK2bQovdMEj9ycG=Cc71mLn2C5Pgeg@mail.gmail.com>

On 11/20/2026 9:09 AM, Andy Lutomirski wrote:
>> On Nov 19, 2026, at 2:52 PM, Andy Lutomirski <luto@kernel.org> wrote:
>> On Thu, Nov 19, 2026 at 2:43 AM Hallgrimur H. Gunnarsson
>> <halg@google.com> wrote:
>>> When a process creates a new user namespace, it receives a full set of
>>> capabilities (CAP_FULL_SET) scoped to that namespace. While namespaced
>>> in scope, several of these capabilities (such as CAP_NET_ADMIN and
>>> CAP_NET_RAW) expose broad kernel attack surface that many sandboxes and
>>> containers never need. However, there is currently no configurable way
>>> to withhold such capabilities from user namespaces while still granting
>>> them to workloads that require them.
>>
>> One thought (from the rootns thread): the other decent sized attack
>> surface here is CAP_MOUNT_ADMIN.  Which doesn't exist as a capability
>> bit.
>>
>> A sort of horrible solution (but maybe not so awful) would be to
>> declare that the bits in cap_userns aren't actually capability bits,
>> and that you need the bit in cap_userns *and* the bit in cap_effective
>> to do sensitive things, and that mounting needs cap_userns to have
>> NSCAP_MOUNT_ADMIN *and* cap_effective to have CAP_SYS_ADMIN.
>>
>> I want to sleep on this.  It might actually solve several problems,
>> e.g. controlling creation of ipv4 and ipv6 loopback or tunnel devices
>> or whatever.
> I slept on it. Here’s a counterproposal.  I’m not saying I think this
> is better than this patch set, but I think it’s worth weighting the
> options.
>
> Define a whole new set of privilege bits.  As a
> poorly-painted-bikeshed option, I’ll call them eprivs (for exposure
> privileges - it’s a crappy name but at least it’s pronounceable).

I played with a mechanism I called "chits" (all the good terms for security
bits have been consumed for a very long time) that looks a lot like
what you're proposing. I did it to address the CAP_SYS_ADMIN problem,
where any use of the capability opens up a whole barrel of worms.
I cannot, unfortunately, find my patches. :( The basic approach is:

A process has an optional set of chits. A process without a chit set is
unaffected by the mechanism. A process with a chit set is allowed only
those operations for which it has a chit. The existing but empty chit set
allows no operations. A process may drop a chit, but not the set, which,
again, can be empty.

Because I was after CAP_SYS_ADMIN, I envisioned a call
	cap_able_chit(capability, chit-list)
but there's no reason there couldn't be a
	chit_able(chit-list)
as well.

I wrote this as an LSM, but the system-wide aspect of it made that
a questionable choice.

If you have any interest, I could dig more deeply to try to find the
patches. Otherwise, I'm happy to look at what you come up with.

>
> An epriv is not permission to do something *to* an object; it’s
> permission to do something that exposes a meaningful attack surface
> within the kernel. So there’s no ns_has_epriv because there is no
> object.  These are kind of the opposite of object capabilities.
> Additionally, an epriv never grants the ability to do something that
> one couldn’t do in an epriv-less world.
>
> For now, all tasks have all eprivs, even not-yet-defined ones, unless
> user code or config explicitly changes this.  (Maybe some day secure
> boot might remove certain eprivs.)
>
> There should never be a check like ns_capable || has_epriv. It’s also
> &&, or perhaps caps are not checked at all.
>
> Example eprivs include:
>
> EPRIV_FSOPEN_VIRT: may fsconfig, fsopen, etc a virtual fs like fuse or
> tmpfs or overlayfs.
>
> EPRIV_CLONE_TREE: may clone a mount tree
>
> EPRIV_MOVE_MOUNT: may move mounts around (but only if you also have
> CAP_SYS_ADMIN on the correct namespace, of course)
>
> EPRIV_FIREWALL_TC: may configure any firewalling configuration or tc
> configuration (this includes iptables, nftables, and ebtables)
>
> EPRIV_NET_RAW: may use raw/packet sockets (like CAP_NET_RAW)
>
> EPRIV_TUNTAP: may create and attach to tun/tap interfaces
>
> EPRIV_IP_LOOPBACK: may set up IPv4 and IPv6 loopback using whatever
> new facility we add
>
> EPRIV_NETLINK: may use netlink at all
>
> EPRIV_NET_ADMIN: may use traditional CAP_NET_ADMIN abilities (all
> CAP_NET_ADMIN checks will also check EPRIV_NET_ADMIN)
>
> EPRIV_OPEN_FILE_HANDLE: May use open_by_handle_at, etc.
>
> EPRIV_UNSHARE_USERNS: may unshare userns
>
> EPRIV_UNSHARE_NONUSERNS: may unshare any other namespace
>
> EPRIV_MOUNT_CGROUPv1, EPRIV_MOUNT_CGROUPv2: may create a new mount of
> these subsystems
>
> EPRIV_PTRACE: there are lots of different variations that might make sense.
>
> EPRIV_MOUNT_PROC_PIDONLY: may mount proc-pidonly
>
> EPRIV_MOUNT_PROC_NOTPIDONLY: may mount proc not-pidonly
>
> EPRIV_MOUNT_SYSFS: may mount sysfs
>
> Example eprivs that are questionable:
>
> EPRIV_DMESG: the kernel log is a specific object, and I think it's
> better to control access using something kernel-log-specific.
>
>
>
> There is no operation that increases eprivs -- even without
> no_new_privs set, a task will never gain an epriv, nor will a child
> ever have an epriv that its creator did not have at the time the child
> was created.
>
> The evolution rules could be as simple as, on fork/clone, the child
> inheriting exactly the parent's eprivs.
>
> Or we could bind eprivs to a userns instead of a task, but that could
> be more limiting and awkward than we want.
>
>
> What do you all think?
>
>
> FWIW, I had an LLM make an inventory (surely not exhaustive) of
> recent-ish CVEs and how they relate to this list.  (The below is the
> only part of this email that is LLM-generated, although I added
> EPRIV_SYSFS because I didn't realize that nonroot userns could mount
> it until I asked an LLM, sigh.)  To me, the list and its breakdown
> suggests that there is quite a lot of room for meaningful attack
> surface reductions while still leaving large parts of userns
> available, and that my epriv proposal captures much of this but the
> cap_userns proposal may be too coarse-grained.
>
> (I also asked about eBPF, and my LLM came up with a lot of CVEs, but
> there's an existing BPF token mechanism and I therefore did not
> propose EPRIV_LOAD_EBPF.)
>
> --- begin LLM output ---
>
> **EPRIV_FSOPEN_VIRT:** CVE-2022-0185*, CVE-2023-0386*, CVE-2023-2640*,
> CVE-2023-32629*, CVE-2025-38499*
>
> **EPRIV_CLONE_TREE:** CVE-2025-38499* (only if the check also covers
> the relevant internal mount-cloning path; explicit `open_tree()`
> restrictions alone are insufficient)
>
> **EPRIV_MOVE_MOUNT:** CVE-2025-37988
>
> **EPRIV_FIREWALL_TC:** CVE-2022-25636, CVE-2022-1015, CVE-2022-1016,
> CVE-2022-32250, CVE-2022-34918, CVE-2022-48911*, CVE-2022-2588,
> CVE-2023-32233, CVE-2023-35001, CVE-2023-4004, CVE-2023-4015,
> CVE-2023-4244, CVE-2023-5197, CVE-2023-6817, CVE-2023-3609,
> CVE-2023-4623, CVE-2023-4921, CVE-2024-1086, CVE-2024-0607,
> CVE-2024-27397, CVE-2024-26925, CVE-2025-38001, CVE-2026-23111
>
> **EPRIV_NET_RAW:** None identified.
>
> **EPRIV_TUNTAP:** None identified as requiring TUN/TAP. Some
> packet-triggered exploits may optionally use it, but that does not
> establish it as a necessary blocker.
>
> **EPRIV_IP_LOOPBACK:** None identified.
>
> **EPRIV_NETLINK:** Also those blocked by `EPRIV_FIREWALL_TC`, insofar
> as the documented attack paths use netlink. No additional CVEs
> identified.
>
> **EPRIV_NET_ADMIN:** Also those blocked by `EPRIV_FIREWALL_TC`,
> insofar as the vulnerable operations require `CAP_NET_ADMIN`. No
> additional CVEs identified.
>
> **EPRIV_OPEN_FILE_HANDLE:** CVE-2025-38306*
>
> **EPRIV_UNSHARE_USERNS:** Also those blocked by `EPRIV_FSOPEN_VIRT`,
> `EPRIV_MOVE_MOUNT`, `EPRIV_FIREWALL_TC`, `EPRIV_OPEN_FILE_HANDLE`,
> `EPRIV_MOUNT_CGROUPv1`, and `EPRIV_MOUNT_SYSFS`, plus CVE-2025-38058*.
> More generally, blocks the documented unprivileged user-namespace
> setup for the entire inventory when no usable user namespace already
> exists.
>
> **EPRIV_UNSHARE_NONUSERNS:** Also the namespace-dependent attack paths
> blocked by `EPRIV_FIREWALL_TC`, `EPRIV_MOVE_MOUNT`,
> `EPRIV_MOUNT_CGROUPv1`, `EPRIV_MOUNT_SYSFS`, and many of those blocked
> by `EPRIV_FSOPEN_VIRT`. Coverage depends on whether the necessary
> non-user namespaces already exist.
>
> **EPRIV_MOUNT_CGROUPv1:** CVE-2022-0492*
>
> **EPRIV_MOUNT_CGROUPv2:** None identified.
>
> **EPRIV_PTRACE:** None identified.
>
> **EPRIV_LOAD_EBPF:** None identified.
>
> **EPRIV_MOUNT_PROC_PIDONLY:** None identified.
>
> **EPRIV_MOUNT_PROC_NOTPIDONLY:** None identified.
>
> **EPRIV_MOUNT_SYSFS:** CVE-2025-22089*
>
> CVEs not cleanly blocked by an operation-specific bit
> Excluding the two EPRIV_UNSHARE_* gates:
>
> - CVE-2025-38058: No explicit unmount privilege. The vulnerable race
> involves umount(2) and path lookup.
>
> - CVE-2022-0492: The cgroup-v1 mount bit covers the documented
> new-mount attack path, but not necessarily configuration of
> release_agent on an existing writable hierarchy.
>
> - CVE-2025-38499: The correct gate depends on which filesystem-context
> or internal cloning operation reaches clone_private_mnt(). I would not
> count EPRIV_CLONE_TREE as a definitive blocker without checking the
> exact call paths.

  reply	other threads:[~2026-11-23 17:22 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 10:42 [PATCH v2 0/4] userns: per-namespace capability bounding set Hallgrimur H. Gunnarsson
2026-11-19 10:42 ` [PATCH v2 1/4] userns: introduce capability bounding set for user namespaces Hallgrimur H. Gunnarsson
2026-11-19 15:05   ` Jarkko Sakkinen
2026-11-19 19:19     ` Hallgrimur H. Gunnarsson
2026-11-19 20:14       ` Jarkko Sakkinen
2026-11-19 22:52   ` Andy Lutomirski
2026-11-20 17:09     ` Andy Lutomirski
2026-11-23 17:22       ` Casey Schaufler [this message]
2026-11-23 19:35         ` [PATCH v2 1/4] userns: introduce capability bounding set for user namespacesg Jarkko Sakkinen
2026-11-23 19:38           ` Jarkko Sakkinen
2026-11-23 20:18             ` Jarkko Sakkinen
     [not found]   ` <sashiko-outbox-223014@kernel.org>
2026-11-20 11:35     ` [PATCH v2 1/4] userns: introduce capability bounding set for user namespaces Hallgrimur H. Gunnarsson
2026-11-19 10:42 ` [PATCH v2 2/4] capability: bound ptrace and cred subset checks by userns ceilings Hallgrimur H. Gunnarsson
2026-11-19 10:42 ` [PATCH v2 3/4] proc: expose userns capability mask as CapUns in /proc/<pid>/status Hallgrimur H. Gunnarsson
2026-11-19 10:42 ` [PATCH v2 4/4] selftests/capabilities: add userns capability bounding set tests Hallgrimur H. Gunnarsson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4db941ba-3001-4019-8910-63e534b29f89@schaufler-ca.com \
    --to=casey@schaufler-ca.com \
    --cc=brauner@kernel.org \
    --cc=containers@lists.linux.dev \
    --cc=corbet@lwn.net \
    --cc=dhowells@redhat.com \
    --cc=gnoack@google.com \
    --cc=halg@google.com \
    --cc=jannh@google.com \
    --cc=jarkko@kernel.org \
    --cc=jcalmels@3xx0.net \
    --cc=jmorris@namei.org \
    --cc=kees@kernel.org \
    --cc=keyrings@vger.kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=luto@kernel.org \
    --cc=mic@digikod.net \
    --cc=paul@paul-moore.com \
    --cc=rdunlap@infradead.org \
    --cc=sergeh@kernel.org \
    --cc=skhan@linuxfoundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®