Repository navigation
fix(chart): run the plugin unprivileged and drop unused host access - #44
Merged
Merged
Conversation
The plugin container ran privileged with the host root filesystem mounted at /host, and its ClusterRole could get and list nodes. None of that is used: the OCI hook that edits container filesystems is run by containerd on the host, not in this pod, and the code never reads /host or calls the nodes API. A compromised plugin was therefore root on the node. Run as uid 0 (for the NRI socket and /run/cainjekt) with all capabilities dropped, a read-only root filesystem, no privilege escalation and the default seccomp profile. The Helm securityContext is a value, so nodes whose SELinux policy needs a privileged pod can opt back in. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: Jan Lauber <jan.lauber@protonmail.ch>
Without it a client that sends headers slowly holds a connection open forever. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: Jan Lauber <jan.lauber@protonmail.ch>
Under SELinux enforcing (RKE2 with selinux: true, SLE Micro, RHEL), the default container_t domain may not connect to containerd's NRI socket or write /run/cainjekt and /opt/cainjekt, which carry host labels. container-selinux has no rule for either. spc_t lifts only the SELinux confinement; capabilities stay dropped. Nodes without SELinux ignore it. Signed-off-by: Jan Lauber <jan.lauber@protonmail.ch>
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.
Why
The plugin container ran with
privileged: true, had the host's/mounted at/host, and couldget/listnodes. None of this is used:/hostand never calls the nodes API.As a result, a bug that let an attacker run code in the plugin would have made them root on the node.
What
Helm chart and kustomize manifests
securityContextvalue. The default isrunAsUser: 0, all capabilities dropped,readOnlyRootFilesystem, no privilege escalation, and theRuntimeDefaultseccomp profile. Root is still needed for the NRI socket and/run/cainjekt.host-rootvolume and its mount.nodesrule from the ClusterRole.Other
ReadHeaderTimeout: 5s, so slow clients can't hold connections open.docs/architecture.md, and added a troubleshooting entry todocs/usage.md.Upgrade note
On nodes whose SELinux policy blocks hostPath access for unprivileged pods (e.g. RHEL/OpenShift), set
securityContext: {privileged: true}. This path is untested. Please try it on one such node before rolling out.Tests
All 5 E2E tests pass on kind, with the Helm test on the chart defaults:
make helm-lintandmake lintpass.For the local run I had to work around a kind problem: kind v0.31 can't
kind loadinto a node image whose containerd config is v4.🤖 Generated with Claude Code