Skip to content

Implement SPIFFE trust-domain bundle management and rotation #6201

Done

Description

@jhrozek

Description

Provide the validation material both SPIFFE credential types are checked
against: X.509 roots and intermediates for X.509-SVID chains, and JWT
verification keys for JWT-SVID signatures, keyed by an explicitly configured
trust domain.

This is the largest greenfield piece of the epic and the largest risk. The
spiffee-authserver branch has no bundle or rotation code at all —
spiffe.NewMiddleware takes only an expected trust domain and relies on chain
validation configured on the TLS listener. There is nothing to harvest here, so
the work should be split along the line where existing machinery stops.

Scope

One bundle document carries both key types, so both halves share a single
fetch. Do not split this work by credential type.

  • Add a trust-domain-keyed bundle registry supplying both x509bundle.Source
    and jwtbundle.Source. Those are the interfaces x509svid.Verify (Implement X.509-SVID OAuth client authentication (spiffe_x509) #6202)
    and jwtsvid.ParseAndValidate (Implement JWT-SVID OAuth client authentication (spiffe_jwt) #6203) consume, and they are the deliverable.
  • Supply X.509 roots and intermediates for chain validation, and JWT
    verification keys restricted to the bundle's jwt-svid keys.
  • Support explicitly configured SPIFFE Bundle Endpoints.
  • Support a SPIRE Workload API bundle source for locally attested deployments.
  • Implement bundle refresh hints, sequence-number monotonicity, and an explicit
    last-known-good policy.
  • Keep Workload API and remote Bundle Endpoint configuration independent —
    neither should imply or override the other.

go-spiffe/v2 is already a direct dependency and covers most of the above:
workloadapi.NewBundleSource, spiffebundle.Set (trust-domain-keyed, already
fails closed on unknown domains), spiffebundle.Read, Bundle.RefreshHint(),
Bundle.SequenceNumber(), and federation.NewHandler for serving spec-correct
bundle documents in tests. Do not reimplement any of it. Note that go-spiffe
parses spiffe_sequence but never enforces it, so rollback protection is ours.

Two corrections to the original scope

Do not extend pkg/oauthproto/jwks.go. A SPIFFE bundle is keyed by trust
domain rather than issuer, carries spiffe_sequence and spiffe_refresh_hint,
and partitions keys by use. JWKSFetcher is issuer-keyed and discovery-driven,
so adopting it means reimplementing spiffebundle.Read worse. That file is also
an unpushed spike artifact that should not be adopted at all — see #6319 for the
separate and unrelated JWKS consolidation work.

Rotation overlap is not configurable. A bundle is an authority set, and the
trust domain publishes old and new authorities together during rotation. A local
overlap window would retain authorities the domain has already withdrawn, which
contradicts the "removed keys stop validating" criterion below. Overlap is the
bundle's content, not a knob.

Acceptance criteria

  • Bundle material is selected by a configured trust domain, never by an
    arbitrary issuer or claim taken from the credential being validated.
  • Bundle Endpoint URLs are explicitly configured and authenticated using
    WebPKI, kept separate from SPIFFE workload trust.
  • X.509 and JWT validation cannot mix keys across trust domains.
  • A rotated bundle validates its new authorities and stops validating removed
    ones on the next successful fetch, with no restart.
  • A bundle whose sequence number is lower than the current one is rejected and
    the current material is retained.
  • Removed keys stop validating once the updated bundle becomes authoritative.
  • Unknown trust domains fail closed.
  • Bundle refresh and failure behaviour is observable without logging
    credentials or key material.

Dependencies

  • Sub-issue 1 (identity, association and configuration model) — the trust
    domain this registry is keyed by is declared there.

Related

  • Part of the SPIFFE client-authentication epic

Activity

  1. added
    enhancement
    go
    on Aug 5, 2026
  2. added
    needs-triage
    on Aug 5, 2026
  3. removed
    needs-triage
    on Aug 5, 2026
  4. jhrozek commented on Aug 13, 2026

    @jhrozek
    ContributorAuthor

    Surveyed the spiffee-authserver branch for reuse. Confirming the issue text: there is nothing to salvage here.

    The branch imports go-spiffe only for spiffeid, spiffetls/tlsconfig and svid/x509svid. workloadapi, BundleSource, x509bundle and jwtbundle are never imported anywhere. Trust anchors are a single os.ReadFile into tls.Config.ClientCAs set once at startup, and the source comment says a proxy restart is required if the CA changes. The PoC root CA is a 10-year self-signed cert that was never expected to rotate, so rotation was never even approximated.

    The one thing worth reading is docs/spiffe-poc/future-directions.md, which marks trust bundle distribution as partial and sketches both upgrade paths (workloadapi.BundleSource, or periodic fetch from the federation endpoint).

    Two corrections to the scope above, based on that survey:

    Extending pkg/oauthproto/jwks.go doesn't fit. A SPIFFE bundle document is keyed by trust domain rather than issuer, carries spiffe_sequence and spiffe_refresh_hint, and partitions keys by use. JWKSFetcher is issuer-keyed and discovery-driven, so adopting it means reimplementing spiffebundle.Read worse. This also collapses the proposed JWT/X.509 split: one bundle document carries both key types, so both halves share a single fetch and the JWT half is not separately "existing machinery". The dependency is moot anyway, since pkg/networking.NewHostScopedClientBuilder already gives us an SSRF-guarded client on main.

    Rotation overlap probably shouldn't be built. A bundle is an authority set, and the trust domain publishes old and new authorities together during rotation. A local overlap window would retain authorities the domain has already withdrawn, which contradicts the "removed keys stop validating once the updated bundle becomes authoritative" criterion. The part that is genuinely ours is sequence-number monotonicity: go-spiffe parses spiffe_sequence but never enforces it, so rollback protection has to be written here.

    go-spiffe v2.7.0 is already a direct dependency and covers most of the remaining bullets: workloadapi.NewBundleSource for the Workload API source, spiffebundle.Set as a trust-domain-keyed registry that already fails closed on unknown domains, spiffebundle.Read for parsing, Bundle.RefreshHint(), and federation.NewHandler for serving spec-correct bundle documents in tests.

  5. self-assigned this
    on Aug 14, 2026
  6. jhrozek commented on Oct 21, 2026

    @jhrozek
    ContributorAuthor

    Merged so far: #6759 (7529e47) adds the file bundle source and its live loader. It polls the mounted bundle, rejects lower or conflicting sequence numbers, and keeps the last good bundle. The bundle_endpoint and workload_api sources are declared in config but still have no loader.

  7. jhrozek commented on Nov 24, 2026

    @jhrozek
    ContributorAuthor

    Closing this as done, with one scope change worth recording.

    The registry that supplies both x509bundle.Source and jwtbundle.Source is in (#6467, #6759). It selects material by configured trust domain and fails closed on unknown domains. It rejects a bundle whose sequence number is lower than the current one and keeps the current material. It tracks how old the last-known-good bundle is and warns when it goes stale. It reloads without a restart, and #7194 checks rotation against real SPIRE authorities.

    What we did not build is the Bundle Endpoint and Workload API sources. We decided early on that the auth server should not hold a Workload API socket or an SVID of its own. Instead, SPIRE publishes its bundle to a ConfigMap (k8s_configmap BundlePublisher) and the auth server mounts it read-only and polls the file. Sockets only appear on the attested client workload. bundle_endpoint and workload_api still exist as reserved source types in the config and CRD, but they are rejected at validation.

    If someone needs a non-Kubernetes deployment that pulls a bundle straight from a Bundle Endpoint, that is a new issue with its own design, not a gap in this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

authenticationauthorizationenhancementgo

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions