Repository navigation
feat: auto-discover webhook-injected SA token mounts in proxy - #8
Merged
Merged
Conversation
The proxy's --mount-roots argument is derived from the source Deployment spec (containerMountPaths in pkg/k8s/resources/resources.go). That misses mounts added at pod-admission time by webhooks — kubelet auto-mount of the default SA token at /var/run/secrets/kubernetes.io/serviceaccount, EKS Pod Identity at /var/run/secrets/eks.amazonaws.com/serviceaccount, and similar webhook-injected projected volumes. The devcontainer-side mount list (podVolumeMountPaths in pkg/admin/local.go) already comes from the live pod and so includes the webhook mounts. The result is asymmetric: the interceptor FUSE-mounts every webhook path locally, but every Stat/Read against those paths is rejected by authorize() with "not within any allowed mount root", which surfaces in the devcontainer as "Permission denied" (and a hard-to-diagnose EACCES for any SDK that reads the IRSA token from disk). Close the gap by having the proxy parse /proc/self/mountinfo at startup and append every tmpfs mount under /run/secrets/ or /var/run/secrets/ to its allowed roots. Both /run/... and /var/run/... aliases are registered so authorize() prefix-matches whichever form the client sends. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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 proxy's `--mount-roots` flag is derived from the source Deployment spec (`containerMountPaths` in `pkg/k8s/resources/resources.go`), so it misses any volume the kubelet or an admission webhook adds at pod-creation time — most notably:
The devcontainer-side mount list (`podVolumeMountPaths` in `pkg/admin/local.go`) already reads the live pod, so the interceptor obediently FUSE-mounts every webhook-injected path locally. But the proxy's `authorize()` only allows paths under the smaller spec-derived root list, so every `Stat`/`Read` against a webhook path returns `PermissionDenied` and surfaces in the devcontainer as a hard-to-diagnose `EACCES` (e.g. AWS SDK reading the IRSA token).
This PR closes the asymmetry on the proxy side without coupling to any specific webhook: parse `/proc/self/mountinfo` at startup and append every tmpfs mount under `/run/secrets/` or `/var/run/secrets/` to the allowed roots. Both `/run/...` and `/var/run/...` aliases are registered so prefix-matching authorizes whichever form the client sends.
Validation
🤖 Generated with Claude Code