Skip to content

fix(inject): drop all capabilities in linkerd-init - #15825

Open
DrFaust92 wants to merge 1 commit into
linkerd:mainfrom
DrFaust92:fix/proxy-init-drop-all
Open

DrFaust92 wants to merge 1 commit into
linkerd:mainfrom
DrFaust92:fix/proxy-init-drop-all

Conversation

@DrFaust92

Copy link
Copy Markdown
Contributor

Problem

linkerd-init adds NET_ADMIN and NET_RAW but doesn't drop anything (charts/partials/templates/_proxy-init.tpl). Unless the workload's first container drops ALL, which injectProxyInit then copies over, the init container also keeps every default capability of the container runtime: CHOWN, DAC_OVERRIDE, FOWNER, SETUID, SETGID, KILL and so on.

With the default non-root user (65534) those stay in the bounding set only, because the proxy image grants cap_net_raw,cap_net_admin+eip as file capabilities on linkerd2-proxy-init and the xtables-*-multi binaries (Dockerfile.proxy). With proxyInit.runAsRoot: true, the process has all of them.

Solution

When linkerd-init is not privileged, it now drops ALL and then adds NET_ADMIN, NET_RAW and any capabilities copied from the workload, as before. This is already what gets rendered when the workload's first container drops ALL (inject_emojivoto_deployment_capabilities.golden.yml), so the combination isn't new.

When proxyInit.privileged or proxyInit.closeWaitTimeoutSecs is set, the container is privileged and gets every capability regardless of drop, so the existing rendering is kept there.

Validation

  • Regenerated the golden files with go test ./cli/cmd/... --update and updated the proxy injector fixtures in controller/proxy-injector/fake/data. The only change in them is the added drop: [ALL] on linkerd-init. go test passes for every package outside test/integration.
  • Rendered linkerd install with default values, proxyInit.runAsRoot=true, proxyInit.runAsRoot=true,proxyInit.closeWaitTimeoutSecs=10 and proxyInit.privileged=true. The first two get drop: [ALL], and the two privileged ones are unchanged.
  • On a kind cluster, I installed the control plane with the CLI built from this branch and the edge-26.11.3 images, and injected a sample client and server with linkerd inject --manual from the same CLI:
    • Every linkerd-init container rendered with add: [NET_ADMIN, NET_RAW] and drop: [ALL] (plus NET_BIND_SERVICE for the client, which adds it) and exited 0.
    • The client's requests to the server returned 200, and the server proxy counted them as inbound with tls="true" and the client's identity.
    • After linkerd upgrade --set proxyInit.runAsRoot=true, the control plane's linkerd-init containers ran as UID 0 with the same capabilities, exited 0, and the pods became ready.

The proxy injector in the cluster ran the released image, so the webhook path is covered by the fixture tests rather than the kind run.

This PR was prepared with an AI assistant (Claude Code) and reviewed by me.

🤖 Generated with Claude Code

linkerd-init adds NET_ADMIN and NET_RAW but keeps the container
runtime's default capabilities, unless the workload's first container
drops them. iptables only needs the two added capabilities, and the
proxy image grants exactly those as file capabilities on the binaries
linkerd-init runs.

Drop ALL in linkerd-init, then add NET_ADMIN, NET_RAW and any
capabilities the workload adds. When proxyInit.privileged or
proxyInit.closeWaitTimeoutSecs is set, the container is privileged and
gets every capability regardless, so the existing behaviour is kept
there.

Signed-off-by: Ilia Lazebnik <ilia.lazebnik@gmail.com>
@DrFaust92
DrFaust92 requested a review from a team as a code owner November 28, 2026 02:48
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