Skip to content

fix(chart): run the plugin unprivileged and drop unused host access - #44

Merged
janlauber merged 3 commits into
mainfrom
fix/chart-least-privilege
Oct 28, 2026
Merged

janlauber merged 3 commits into
mainfrom
fix/chart-least-privilege

Conversation

@janlauber

Copy link
Copy Markdown
Member

Why

The plugin container ran with privileged: true, had the host's / mounted at /host, and could get/list nodes. None of this is used:

  • The OCI hook that edits container filesystems is run by containerd on the host, not in this pod.
  • The code never reads /host and 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

  • New securityContext value. The default is runAsUser: 0, all capabilities dropped, readOnlyRootFilesystem, no privilege escalation, and the RuntimeDefault seccomp profile. Root is still needed for the NRI socket and /run/cainjekt.
  • Removed the host-root volume and its mount.
  • Removed the nodes rule from the ClusterRole.

Other

  • Metrics server: ReadHeaderTimeout: 5s, so slow clients can't hold connections open.
  • Docs: rewrote the Privileges section of docs/architecture.md, and added a troubleshooting entry to docs/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:

  • Helm
  • Manifest
  • InitContainer
  • RestartReinjection
  • StatusFile

make helm-lint and make lint pass.

For the local run I had to work around a kind problem: kind v0.31 can't kind load into a node image whose containerd config is v4.

🤖 Generated with Claude Code

janlauber and others added 2 commits September 23, 2026 15:09
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>
@janlauber
janlauber requested a review from a team as a code owner September 23, 2026 14:07
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>
@janlauber
janlauber merged commit c95dbc7 into main Oct 28, 2026
8 checks passed
@janlauber
janlauber deleted the fix/chart-least-privilege branch October 28, 2026 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant