Skip to content

fix(nri): set trust env on the container spec so exec'd processes get the CA - #51

Open
janlauber wants to merge 1 commit into
mainfrom
fix/exec-visible-trust-env
Open

janlauber wants to merge 1 commit into
mainfrom
fix/exec-visible-trust-env

Conversation

@janlauber

Copy link
Copy Markdown
Member

The wrapper sets SSL_CERT_FILE, REQUESTS_CA_BUNDLE and the other trust env vars on the entrypoint process only. Processes started with exec get their env from the container spec, so they never see the CA. This breaks every step of a GitHub Actions container job on ARC, because each step runs as a pod exec.

The plugin now bind-mounts the per-container CA dir read-only at /etc/cainjekt-ca and sets the trust env vars on the NRI adjustment. The plugin seeds the bundle with its own image's roots, and the hook then refines it with the container's own store. Entrypoint processes are unaffected.

This also fixes the read-only rootfs path. It set the CA path facts to host paths under /run/cainjekt/containers/, which nothing mounts into the container. They now name the paths the container sees. The .NET processor relies on that path.

Rebased onto main. go test ./... and golangci-lint pass. Not yet tested on a cluster. This PR conflicts with the feat/rootfs-boundary PR in osstore.go.

… the CA

The wrapper sets SSL_CERT_FILE/REQUESTS_CA_BUNDLE/... on the entrypoint process
only. Processes started via exec are seeded from the container spec instead and
never see them, so CA injection silently did nothing for every step of a GitHub
Actions container job (ARC's k8s container hooks run each step as a pod exec).
Python is hit hardest: requests/zeep read certifi, not the OS trust store, so the
merged store the hook writes doesn't help either.

Bind-mount the per-container CA dir read-only at /etc/cainjekt-ca and put the
trust env vars on the NRI adjustment, pointing at fixed paths under it. The
plugin seeds the merged bundle with its own image's roots so the trust-replacing
vars resolve to a complete bundle from container start; the hook then refines it
with the container's actual store. Entrypoint processes are unaffected — the
wrapper still overrides with the in-place store.

Also fixes the read-only-rootfs path, which set FactIndividualCAPath and
FactMergedCAPath to host paths under /run/cainjekt/containers/. Nothing mounted
that directory into the container, so those env vars pointed at files the
container could not see. They now name the paths as the container sees them.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@janlauber

Copy link
Copy Markdown
Member Author

On hold: the bind-mounted CA dir is labelled var_run_t on SELinux-enforcing nodes (RKE2 selinux: true, SLE Micro, RHEL), and container-selinux gives container_t no read access to it. Exec'd processes and exec probes would get trust env vars pointing at an unreadable bundle. Needs the staged dir relabelled to container_file_t (the plugin runs as spc_t, so it can) before merge.

@janlauber
janlauber force-pushed the fix/exec-visible-trust-env branch from ce47c8e to 40f6a6c Compare October 28, 2026 14:36
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