Repository navigation
fix(security): stop trusting the aether.io/spiffe-id pod annotation as a mesh-identity override (#669) - #671
Merged
Merged
Conversation
…s a mesh-identity override (#669) A pod's mesh SPIFFE ID is now derived only from the mesh trust domain and the pod's own namespace/ServiceAccount. The aether.io/spiffe-id annotation, which reached the agent verbatim over the CNI ADD path, is rejected: it is logged at WARN and counted by aether.agent.identity.spiffe_id_override_rejected on both the CNI ADD path and the agent-restart resubscribe replay. The override was not merely cosmetic. The SPIRE bridge keys its SDS secrets by the SPIFFE ID of the SVID SPIRE actually issues, and pushes ALL of them into the one snapshot served to the node proxy. The annotation named the SDS secret the pod's inbound listener presents AND (via localWorkloads and the per-netns transport-socket matcher) the client certificate its egress presents, so a pod naming a co-located workload's identity had that workload's SVID presented on its behalf in both directions. Also reorders the endpoint envoy.lb metadata build so pod-supplied metadata.endpoint.aether.io/* keys can no longer overwrite the control plane's ip/pod/namespace/cluster/waypoint facts, and adds waypoint to the reserved subset keys. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
bpalermo
added a commit
that referenced
this pull request
Sep 4, 2026
newCNIMetrics is at cognitive complexity 16 against the lint limit of 15 on main, and no PR ever failed CI for it. #671 (763f5b3) added the fifteenth registration; #672 was branched before #671 merged, added two more to a file it saw at 13, and its CI head (f5d540a) honestly measured 15 and passed. The squash of #672 onto main produced the sixteenth. Nothing lints main after a merge, so the violation surfaced only when #676 and the #667 branch put //agent/internal/cni/server back into a PR's bazel-diff impact set. Pure mechanical extraction into registerSweepInstruments (ghost-sweep counters and the prune-breaker gauge) and registerLifecycleInstruments (the unmeshed and storage gauges, liveness instruments, identity-override counter). No metric names, descriptions, units or registration order change. Verified with fail_on_violation on //agent/internal/cni/server/... and the package tests. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
bpalermo
added a commit
that referenced
this pull request
Sep 4, 2026
#678) newCNIMetrics is at cognitive complexity 16 against the lint limit of 15 on main, and no PR ever failed CI for it. #671 (763f5b3) added the fifteenth registration; #672 was branched before #671 merged, added two more to a file it saw at 13, and its CI head (f5d540a) honestly measured 15 and passed. The squash of #672 onto main produced the sixteenth. Nothing lints main after a merge, so the violation surfaced only when #676 and the #667 branch put //agent/internal/cni/server back into a PR's bazel-diff impact set. Pure mechanical extraction into registerSweepInstruments (ghost-sweep counters and the prune-breaker gauge) and registerLifecycleInstruments (the unmeshed and storage gauges, liveness instruments, identity-override counter). No metric names, descriptions, units or registration order change. Verified with fail_on_violation on //agent/internal/cni/server/... and the package tests. Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr Co-authored-by: Claude Fable 5.1 <[email protected]>
bpalermo
added a commit
that referenced
this pull request
Sep 5, 2026
…efore merging (#679) (#685) PR CI validates a PR head against that PR's merge-base, and nothing validated main after a merge. Two PRs that each pass against their own base can combine into a state neither was ever tested in — #671 and #672 each added CNI metric registrations against a base without the other, and the second squash put newCNIMetrics at gocognit 16/15 on main, surfacing days later on the unrelated PRs #676/#677. Add .github/workflows/main.yaml (`main-post-merge`): on every push to main it runs the same build+lint+unit-test leg ci.yaml runs, with the bazel-diff impact set computed as the merge commit vs its first parent (HEAD^), falling back to a full //... build+test when bazel-diff cannot compute it. --config=ci implies --config=remote, which pins TestRunner to the local strategy, so tests stay local exactly as they are on the PR path. The pull_request path is untouched and `ci` remains the only required status check. ci-impacted-targets.sh never assumed a PR merge-base functionally, but its docs did; retitle them for the two callers and add the new workflow to the seed-file list so editing it forces a full run. The preventive half — branch protection required_status_checks.strict — is a repo settings change applied alongside this PR, not code. Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr Co-authored-by: Claude Fable 5.1 <[email protected]>
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.
Fixes #669.
What the annotation actually controlled (call-site analysis)
SpiffeIDFromPodhad five call sites; the value is trusted input to the data plane at four of them:proxy/ingress.go:75(NewInboundListener)tlsCertificateSecretName— the SDS secret every inbound mTLS chain presents (TCP floor + no-SNI h2 chain + one per served port). The validation context is separate and derived from the trust domain flag, so the annotation could not widen who is accepted.xds/cache/listener.go:141/:413localWorkloads[netns]— consumed bycache/mtls.go→proxy.InjectUpstreamMTLS, which builds the per-netnsTransportSocketMatcherand oneTransportSocketMatchper local ID. That names the client certificate the pod's egress presents (capture + outbound), for both HTTP and TCP-floor clusters.cni/server/pod.go:123,cni/server/resubscribe.go:58spiffeIDargument tospire.Bridge.SubscribePod. Bookkeeping only for issuance (selectors are the real ones), but it is also the keyUnsubscribePoddeletes from the node-wide secret map and the key its shared-identity refcount compares.proxy/authz.go:70spiffeIdin theaether.sourcedynamic-metadata namespace, forwarded to the ext_authz sidecar as the calling workload's identity (027).Real blast radius, as traced (not as assumed)
The SVID material does come from SPIRE, and
SubscribePodpasses the pod's real k8s selectors (spire.PodSelectors(ns, sa, name, uid)), so SPIRE never mints a forged identity. But the annotation does not have to make SPIRE issue anything — it only has to name a secret that already exists in the snapshot:spire/converter.gonames each SDS secret from the SPIFFE ID of the SVID SPIRE actually returned (spiffe://<td><path>), andbridge.handleSVIDUpdatestores it asb.secrets[secret.Name].bridge.pushSecretspushes every secret in that map into the single snapshot served to the node proxy. Secrets are node-wide, not scoped per pod or per netns.So:
cache/mtls.go), inbound RBAC, and the XFCC/aether.sourcecaller identity (025/027, feat(authz): RBAC local authorization with audit mode #476/fix(authz): INBOUND filters bring their own chain entry into the union #477) all see the victim. This is cross-namespace impersonation obtainable with "create a pod in my own namespace" — the weakest common Kubernetes permission.cache/mtls.gofrom the registry service name (spiffe://<td>/ns/<ns>/sa/<service>), never from the annotation. The annotation changed only what the annotated pod's own config presents — which is exactly what makes case 1 exploitable rather than self-defeating.UnsubscribePoddeletesb.secrets[sub.spiffeID]using the annotated key, and its "another pod still uses this identity" refcount compares annotated keys. An attacker pod that borrowed a co-located identity could, on its own deletion, evict the victim's SVID from the node snapshot — a co-tenant data-plane outage — and conversely leak its own.So the honest summary is: not uniformly fail-closed. Fail-closed on an unpopulated identity, fail-open (full impersonation, both directions) on any identity already present on the node — which an attacker can arrange by scheduling next to the target.
Fix chosen
Removal, per the issue's preference — validation could only ever permit the annotation to restate the derived value.
proxy.SpiffeIDFromPodnow always returnsspiffe://<trust-domain>/ns/<namespace>/sa/<service-account>(moved to a newproxy/spiffe.gonext to its test).proxy.SpiffeIDOverrideAnnotationreports the annotation so its presence is observable.CNIServer.reportRejectedSpiffeIDOverridelogs WARN (annotation,requestedSpiffeID, thespiffeIDactually used) and incrementsaether.agent.identity.spiffe_id_override_rejected. Called on the CNI ADD path and again from the restart resubscribe replay, so a pod that still carries the annotation is re-reported after an agent restart rather than going quiet.xdsconst.AnnotationSpiffeIDis kept, documented as rejected — it is now only a detection key.Also in scope: endpoint metadata ordering
ServiceLocalityLbEndpointFromRegistryEndpointapplied pod-suppliedmetadata.endpoint.aether.io/*keys after the built-inenvoy.lbkeys. Those built-ins are not decoration:ip/podback the NO_FALLBACKx-aether-ip/x-aether-podpinning selectors, andwaypointsteers the cluster's transport-socket matcher onto the structured waypoint SNI (019). A pod could therefore claim another pod's name/IP for pinned traffic, or forge the waypoint tag. Pod metadata is now applied first and filtered against the reserved key set, with the control-plane facts written last.waypointwas additionally added toreservedSubsetKeys(it passedValidSubsetKey's pattern, so it was also usable as a provider subset key).Test evidence
bazel test //agent/... //common/... //registry/... //controller/... //registrar/... //cni/... --test_output=errors→ all green (68 targets).bazel build --config=ci //agent/...green (gocognit 15).make gazelle,make formatrun.New/changed tests, none weakened:
proxy.TestSpiffeIDFromPod— table-driven over: no annotation, no annotations map, empty string, annotation restating the derived value, wrong ServiceAccount, wrong namespace, wrong trust domain, malformed URI, control-plane-identity shape. Every case must equal the derived ID.proxy.TestSpiffeIDOverrideAnnotation— the detection hook (absent / unrelated / empty / present).proxy.TestNewInboundListener_IgnoresSpiffeIDAnnotation— config-level regression: for every filter chain of an annotated pod's inbound listener, theDownstreamTlsContextcert SDS name is the derived ID and the validation context is the trust domain.server.TestReportRejectedSpiffeIDOverride— asserts the WARN record carries the requested and the used identity and that the counter increments exactly once; asserts no log and no counter touch when the annotation is absent or empty. Plus a nil-metrics (telemetry-off) case.proxy.TestServiceLocalityLbEndpointFromRegistryEndpoint_MetadataCannotForgeBuiltins— forgedip/pod/namespace/cluster/waypointmetadata is dropped, non-reserved keys still travel, and the control plane's own waypoint tag is still stamped when it decides the endpoint is remote.proxy.TestValidSubsetKey—waypointnow rejected as a provider subset key.Operator-visible behaviour change
aether.io/spiffe-idno longer does anything. Any workload that relied on it to present a non-derived identity will now presentspiffe://<td>/ns/<ns>/sa/<sa>; if a peer pins the old value, that hop breaks. Nothing in this repo (charts, e2e, conformance, proposals) set the annotation — onlydocs/configuration.md, updated here — so no in-tree consumer changes.aether.agent.identity.spiffe_id_override_rejectedafter rollout: any nonzero value is a pod trying to choose its own identity and is worth investigating, benign or not.ip,pod,namespace,clusterorwaypointare now dropped from the endpoint'senvoy.lbmetadata (they were already excluded from subset selectors). Subset routing on such a key was never functional; the only change is that the forged value no longer lands in the endpoint metadata.Not fixed here
The other identity-enforcement gap #669 mentions —
proxy/transportsocket.gosilently omitting SAN pinning whensanURIsis empty, leaving the handshake proving only trust-domain membership — is untouched. It is a distinct fail-open path (emptysanNamespaceson a service entry) and deserves its own change.🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr