freenode
Kernel & Low-Level

Kernel patches would cap privileges inside user namespaces

A second proposal lets sandboxes strip high-risk capabilities such as network admin, while reviewers float a broader redesign of kernel attack-surface privileges.

Unprivileged Linux processes that create a user namespace still receive a full set of capabilities inside it, and Hallgrimur H. Gunnarsson has posted a revised mechanism to put a ceiling on that grant. The change matters because those namespaced rights, especially network administration and raw sockets, reach kernel code that long assumed a trusted caller and has accounted for a large share of local privilege-escalation bugs. Many sandboxes use user namespaces only for UID, mount, PID, or network isolation and never need those rights, but today there is no configurable way to withhold them while still allowing them for workloads that do.

The series, from Google, follows earlier work by Jonathan Calmels and a first proposal that used a global sysctl and clone3(). Christian Brauner and Andy Lutomirski objected to that interface. Gunnarsson's revision follows their suggestion: a bounding set on the namespace itself, plus a per-credential userns capability mask, both controlled through prctl, with a strict securebit that also drops the usual permitted-capability exemption. Child namespaces inherit the tighter ceiling, so bits once excluded stay excluded. The mask is exposed as CapUns in /proc status so tools can see it.

The series also closes a ptrace gap. Same-namespace tracing currently looks only at permitted or effective capabilities, so a task whose ceiling had been lowered could trace a less-restricted task with the same UID and use it to create a wider child namespace. Tracing now requires the target's userns ceiling to be a subset of the tracer's. Gunnarsson wrote that implicit parent-owner rights are uniformly bounded by the owned namespace's ceiling, and that he would rather keep that stricter behavior unless reviewers object. Holding an explicit ptrace capability in an ancestor namespace still works.

Lutomirski argued the design still misses a large surface: mount administration has no capability bit of its own. After considering a dedicated userns bit that would have to be held alongside CAP_SYS_ADMIN, he offered a counterproposal he did not claim was better: a new set of "exposure privileges," or eprivs, which would not grant new rights but would gate operations that expose kernel attack surface. Casey Schaufler said he had explored a similar idea, which he called chits, aimed at the sprawl of CAP_SYS_ADMIN, though he could not find the old patches. Jarkko Sakkinen said the bounding-set approach looks complementary to his own work on setting up namespaces from outside.