Support running under OpenShift arbitrary UIDs (restricted-v2 SCC)#36545
Open
snecklifter wants to merge 1 commit intovespa-engine:masterfrom
Open
Support running under OpenShift arbitrary UIDs (restricted-v2 SCC)#36545snecklifter wants to merge 1 commit intovespa-engine:masterfrom
snecklifter wants to merge 1 commit intovespa-engine:masterfrom
Conversation
Make Vespa containers compatible with OpenShift 4.20's default security context which assigns arbitrary UIDs with GID 0. Key changes: - RPM spec: set writable dirs to root group (GID 0) with 0775 perms - rhel-prestart.sh: use writability checks instead of strict ownership - vespa-run-as-vespa-user: skip setuid/setgid when non-root - Go user code: graceful fallback for arbitrary UIDs, add VESPA_SKIP_USER_CHECK env var - standalone-container.sh: conditional chown, relaxed user validation - common-env.sh: fallback to numeric UID when no known user exists - systemd services: parameterize User= directive via CMake Co-Authored-By: Claude Opus 4.7 <[email protected]>
Open
3 tasks
Author
|
Given the restricted-v2 scc partially mitigates CVE-2026-31431 (copy/fail) it might be good to review this? |
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
restricted-v2Security Context Constraint (SCC), which runs containers with arbitrary UIDs and GID 0 (root group)Background: OpenShift SCCs and the root group
OpenShift uses Security Context Constraints (SCCs) to control what pods can do at runtime. The default
restricted-v2SCC enforces:1000660000+), not the UID specified in the Dockerfilesetuid()/setgid()are blocked;CAP_SETUIDandCAP_SETGIDare droppedAs stated in the OpenShift documentation:
Why root group ownership is safe
Using GID 0 as the group owner does not grant root privileges. It simply allows any UID assigned to the root group (which OpenShift always does) to read/write the directories. The actual user remains unprivileged — it cannot escalate to UID 0, bind privileged ports, or perform any root-level operations.
Changes
RPM spec (
dist/vespa.spec)%attrdirectives changed from(-,vespa,vespa)to(0775,vespa,root)— GID 0 with group-writevespauser added to root group viausermod -a -G root/etc/passwdmade group-writable to support runtime UID injectionStartup scripts
rhel-prestart.sh: Replaced strict user/group name ownership checks with writability checks ([ -w "$4" ]). Non-root processes can no longer fail startup due to ownership mismatchcommon-env.sh: Added fallback to numeric UID when neithervespanornobodyuser exists in/etc/passwdstandalone-container.sh:chownis now conditional on running as root; user validation relaxed for arbitrary UIDsUser switching
vespa-run-as-vespa-user(C++): Detects non-root execution and skipssetuid()/setgid()/setgroups(), proceeding withexecvp()directlyfind_user.go,switch_user.go): Falls back to numeric UID string whenuser.Current()fails;CheckCorrectUser()andMaybeSwitchUser()proceed with warnings instead of exiting when non-root. AddedVESPA_SKIP_USER_CHECKenv var for explicit bypassSystemd services
User=vespawithUser=@VESPA_USER@CMake template variable in both service filesCompanion PR
The corresponding container image changes are in vespa-engine/docker-image (Dockerfiles and entrypoint script).
Test plan
0775withrootgroup--user=$(id -u):0to simulate OpenShift arbitrary UIDvespa-start-configserverandvespa-start-servicessucceed under arbitrary UIDrhel-prestart.shpasses writability checks without rootvespa-run-as-vespa-userexecutes commands without attemptingsetuidvespauser (UID 1000) in standard Docker🤖 Generated with Claude Code