user: fail closed when supplementary groups cannot be set - #288
Open
carrerasdarren-cell wants to merge 1 commit into
Open
user: fail closed when supplementary groups cannot be set#288carrerasdarren-cell wants to merge 1 commit into
carrerasdarren-cell wants to merge 1 commit into
Conversation
An expected EPERM after denying setgroups in a new user namespace can still leave inherited supplementary groups attached to the child. Query the remaining group count and abort before exec unless the credential state is actually clean. Add regression coverage for both an inherited-group failure and a clean no-groups launch.
carrerasdarren-cell
force-pushed
the
fix/fail-closed-setgroups
branch
from
July 24, 2026 01:53
baf7f7f to
93c3cad
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
EPERMpath only when the parent deliberately deniedsetgroups(2)and no supplementary groups remainEPERMcaseSecurity rationale
setresgid()andsetresuid()do not clear supplementary groups. Ifsetgroups(2)fails and nsjail continues, a jailed command can retain group-based access held by its launcher.The original change made unexpected
setgroups(2)failures fatal, while preserving theEPERMthat follows an intentionaldenywrite to/proc/<pid>/setgroupsin an unprivileged user namespace. Further testing found that this expected-error path also needs to verify the resulting credentials:CLONE_NEWUSERinherits supplementary groups, anddenyprevents the child from clearing them.With nsjail launched as UID/GID
1000and inherited supplementary GID1234, the current PR baseline wrotedeny, receivedEPERM, and still executed the jailed command./proc/self/statusconfirmed one supplementary group remained:The namespace renders the unmapped GID as the overflow value, but the credential still carries the host group membership. This can preserve access to group-readable host files exposed to the jail.
The updated patch shares the exact parent-side
setgroups-deny predicate with the child. Every unexpected failure stops beforeexecve; after the expectedEPERM, it callsgetgroups(0, nullptr)and proceeds only if the supplementary-group count is zero.Verification
-Werrorflags1234: exited0and retained one supplementary group255beforeexecve0strace -e inject=setgroups:error=EPERMwithout the intentional deny path: exited255git diff --checkThe broader integration target then reached its existing
pastanetworking test and stopped because the minimal test container did not include the optionalpastaexecutable.