Skip to content

Commit 71940b3

Browse files
committed
Dynamic No New Privileges (NNP) via bpf
Signed-off-by: Christian Brauner <[email protected]>
1 parent af776dc commit 71940b3

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,44 @@ associated problem space.
1010
point that out explicitly and clearly in the associated patches and Cc
1111
`Christian Brauner <brauner (at) kernel (dot) org`.**
1212

13+
### Dynamic No New Privileges (NNP) via bpf
14+
15+
On newer systems the use of privilege escalating binaries (suid, sgid,
16+
file capabilities) can be avoided. This model is illustrated in
17+
systemd's `run0` tool.
18+
19+
So it is possible to turn on `PR_SET_NO_NEW_PRIVS` (NNP) for systemd
20+
itself and thus for every process on the system. However, that breaks
21+
sandboxed workloads. Sandboxed workloads such as containers may run
22+
a single process without a full-fledged daemon that could supervise
23+
privileged operations. In such cases suid execution must be allowed.
24+
25+
Ideally sandboxes that require execution of privilege escalating
26+
binaries must use a user namespace with a non-identity idmapping.
27+
28+
Instead of revamping the fairly inflexible NNP implementation, execution
29+
of privilege escalating binaries should be supervised by a bpf LSM.
30+
31+
When a privilege escalating binary is executed in the initial user
32+
namespace the bpf LSM program will cause the kernel to skip elevating
33+
privileges and instead execute the binary with the caller's privileges.
34+
This is equivalent to the NNP behavior.
35+
36+
If a privilege escalating binary is executed in a non-initial user
37+
namespace the bpf LSM program will allow the kernel to escalate the
38+
caller's privileges to a higher privilege level.
39+
40+
This will allow unprivileged containers to execute privilege escalating
41+
binaries but completely isolate regular services from doing so.
42+
43+
This can of course be configurable on a per-service basis if needed.
44+
45+
This will require hooking up a new security hook into the kernel's exec
46+
codepath.
47+
48+
**Use-Case:** Wean all of userspace off of privilege escalating
49+
binaries.
50+
1351
### xattrs for pidfd
1452

1553
Since pidfds have been moved to a separate pidfs filesystem it is easy

0 commit comments

Comments
 (0)