Repository navigation
feat(agent): add the inbound identity-binding discriminator (#638) - #715
Merged
Merged
Conversation
Envoy's SAN-matcher failure prints the SANs of the certificate being VALIDATED — the PEER's — so ssl_fail_verify_san is a CLIENT-side counter about the SERVER's certificate. Inverted, the wrong identity in a #638 event belongs to a server cert: the inbound filter chain → SDS server-secret binding of the proxy that TERMINATED the connection. #686's outbound check watches the client side and cannot fire for it. On every snapshot the agent now reads each local pod's inbound listener back out of the snapshot it just handed Envoy, extracts each chain's DownstreamTlsContext server-cert secret name, and compares it with the SPIFFE ID of the pod that listener entry belongs to: - INFO "inbound identity binding" on a first bind or a change - WARN "inbound chain bound to a foreign identity" + the counter aether.agent.identity.inbound_binding_mismatch - WARN "inbound chain references a secret absent from the snapshot" (the chain reached Envoy before its own SVID) - a summary line above 200 changed chains in one snapshot The binding holds by construction inside proxy.NewInboundListener, which is the point: a counter that stays 0 through a #638 event, with INFO lines showing correct re-binds, moves the defect out of the agent's snapshot and into Envoy's SDS/secret lifecycle across the hot restart. Fail-open: observes after SetSnapshot, never blocks or alters it. docs/runbook.md gains the attribution recipe for the ledger join — upstream_host → pod → node vs. the node whose proxy was restarting, with the documented false-zero traps (LogsQL field syntax, max_over_time). Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
…tity-discriminator
bpalermo
added a commit
that referenced
this pull request
Sep 5, 2026
… absence is not a false zero (#638) (#717) The OTel SDK exports a counter only after its first Add. Both discriminator counters (outbound #686, inbound #715) are never incremented in the healthy case, so neither series existed in Prometheus on talos-main rev200 and a grading increase() would return no data, indistinguishable from zero. Seed both at process start; test pins it. 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 7, 2026
) (#741) Agent startup no longer exits when SPIRE is not serving yet. The one-shot, fatal `commonspire.NewSource` (25s bound, #668) is replaced by a `WaitingSource` runnable that retries forever with bounded, jittered backoff, serves `ErrNoSVIDYet` meanwhile, and announces the wait at INFO with attempt/elapsed — escalating to WARN after `--spire-wait-warn-after` (2m). Everything downstream already tolerated a late identity: the SDS bridge dials lazily and now also serves the node SVID on the source's `Updated()` wake rather than the next 30s tick; the registrar watch loop defers (INFO, no `watch_errors`, no backoff escalation) while the SVID is pending; the xDS cache omits upstream mTLS until `SetNodeIdentity` lands and Envoy tolerates the absent secret (#715). The trust domain is seeded with the mesh domain through a small atomic holder and reconciled against the real SVID when it arrives. Readiness gains a `spire-svid` check beside `cni-chained`, with a 2m dwell equal to the warn threshold: the controller's node-taint guard re-arms `aether.io/agent-not-ready:NoSchedule` after 30s of NotReady and spire-server does not tolerate that taint, so a hard-from-t=0 gate would fence the cluster against spire-server's own rescheduling. New metrics: `aether.agent.spire.wait_seconds` (seconds-oriented buckets, #732), `aether.agent.spire.source_restarts` (expected 0), `aether.agent.spire.svid_ready`. Chart: `spire.waitWarnAfter: 2m` threaded to all four components. Runbook: "The agent is stuck waiting for SPIRE". The `--spire-enabled=false` path (#421) is unchanged, and nothing in `runAgent` or `PreListen` is reordered (#700/#712). The controller/registrar/edge sources still create synchronously; PR 2 moves them. 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.
The inversion, in three lines
Envoy's
default_validator.cc:332printsverify cert failed: SAN matcher, certificate SANs are [...]for the certificate it is validating — the one the peer presented.So
envoy_cluster_ssl_fail_verify_san_totalis a client-side counter about the server's certificate, and every #638 ledger join read it backwards.The mis-bound identity is therefore a server cert: the inbound filter chain → SDS server-secret binding of whichever proxy terminated the connection (for same-node traffic, the restarting proxy itself) — which is exactly the observed "node-wide constant per time slice" shape, and which #686's client-side check structurally cannot see.
What lands
agent/internal/xds/cache/inboundidentitybinding.go, called fromgenerateSnapshotafter a successfulSetSnapshot, so a logged binding is one Envoy actually received. Per snapshot it reads each local pod's inbound listener back out of the proto, pulls each chain'sDownstreamTlsContext.tls_certificate_sds_secret_configs[0].name, and compares it withproxy.SpiffeIDFromPodover theCNIPodthat listener entry belongs to:inbound identity binding—chain(<listener>/<chain>),pod,pod_spiffe_id,secret(what the chain will present),previous_secret(empty on a first bind),secret_served,snapshot_version. Edge-triggered: first bind or change only, steady state is silent.inbound chain bound to a foreign identity+ the new nil-safe counteraether.agent.identity.inbound_binding_mismatch(exported asaether_agent_identity_inbound_binding_mismatch_total) — the node would terminate mesh mTLS for this pod while presenting a co-located workload's SVID. Reported on the edge, so a persistent mismatch is counted once per state.inbound chain references a secret absent from the snapshot— the chain reached Envoy before its own SVID did. That is the other candidate mechanism named in the issue ("a chain that exists before its own secret has landed may fall back to the default/first secret"). Reported, not counted: it is not a foreign bind.inbound identity bindings changedsummary carries the distinct pod→identity transitions instead.Cleartext (SPIRE off) chains carry no transport socket and are skipped — no certificate to bind or mis-bind. Fail-open throughout: it observes the snapshot and never blocks, alters or delays it.
Does the invariant hold by construction?
Yes, inside one build.
proxy.NewInboundListener(ingress.go) derives the chain's server-cert SDS name from the same*cniv1.CNIPodit names the listener and chains after, so a Go-level mismatch cannot be constructed there.The check is still worth having, and is stated that way in the code, because it does not read that Go string — it reads the emitted proto and joins it against the pod recorded as owning the entry. That catches what construction cannot rule out: a listener entry rebuilt from, or left behind by, a different pod than the one now owning the netns (netns reuse after a missed CNI DEL — the same substrate #686 documents for the outbound index), a rebuild path (
gamma.go,l4route.go,capture.go,udspolicy.go) re-generating from the wrong entry, and the unserved-secret window above.What it proves either way
snapshot_version.inbound chain references a secret absent from the snapshotin the burst window → the chain-before-its-SVID ordering is real and is the first thing to fix.Attribution recipe
docs/runbook.mdgains a section next to the existing #638/outbound material: the LogsQL to pull the events (_stream:{service.name="aether-proxy"}+log_name:aether_access_logs AND upstream_transport_failure_reason:"CERTIFICATE_VERIFY_FAILED", field syntax only), theupstream_host→ pod → node join that produces the terminating-node column the issue asks for, and the comparison againstenvoy_server_hot_restart_epochfor the node whose proxy was restarting — with the documented false-zero traps called out (never| stats, never an instant query on a series that ages out with the proxy generation,max_over_timemandatory, control-test every negative).Validated
agent/internal/xds/cache/inboundidentitybinding_test.go: first sight names every chain then goes silent; a legitimate re-bind logs the transition and is not a mismatch; a listener built for a co-located workload while the entry belongs to another pod WARNs and increments the counter (and is not re-counted while it persists); an unserved secret WARNs but is not counted, and clears when the SVID lands; cleartext emits nothing; the rate guard summarises.bazel test --test_arg=-test.short //agent/...— 34/34 pass.make gazelle,make format-check,bazel build --config=lint --@aspect_rules_lint//lint:fail_on_violationon the touched packages — clean (gocognit gate included).🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr