← Back to Pull requests

feat: add support for external sds cluster #10738

Open
ramaraochavali opened this pull request with 1650 lines diff across 16 files
View on GitHub
ramaraochavali ramaraochavali commented on Nov 30, 2026 10:08 UTC
Author

Added support configuring external SDS server for listeners and backends.

  • [X] Authorship & ownership: Coding agents / AI assistants are welcome, but I have reviewed every change, understand how and why it works, can explain and maintain it, and take full responsibility for this PR. I have not submitted generated output I do not understand.

  • [X] DCO: All commits are signed off (git commit -s). See DCO: Sign your work.

  • API agreed first: If this PR contains API changes (changes under /api), the API was discussed and agreed before the implementation. The API change can be in a separate PR, or in the same PR, but the API must be agreed before implementation. N/A if this PR does not contain API changes.

  • Required checks pass: make generate gen-check, make lint, and the unit-test/coverage build pass. (Flaky e2e failures are not considered breakages, but gen-check, lint, and coverage MUST pass.)

  • Tests added/updated: New/changed code is covered by appropriate tests. N/A if this PR does not contain code changes.

  • Docs: User-facing changes update the docs, either in this PR or a follow-up PR. N/A if this PR does not contain user-facing changes.

  • Release notes: For any non-trivial change, added a release-note fragment under release-notes/current/<section>/<pr-number>-<slug>.md (see release-notes/current/README.md for sections and naming). N/A if this PR does not contain non-trivial changes.

  • Generated files committed: Ran make gen-check and committed the result if API/helm charts/modules changed.

  • Scope & compatibility: The PR is reasonably scoped (no unrelated changes) and preserves backward compatibility, or any breaking change is called out above and documented in release-notes/current/breaking_changes/.

  • Codex review: Requested a Codex review and addressed all of its comments.

  • Copilot review: Requested a Copilot review and addressed all of its comments.
  • Diff: 1650 lines (+1600 / -50) across 16 files Reviewer: ramaraochavali Review duration: 1903m
    All Vouch review confidence checks passed
    Residual risk 0.13 = Change Risk (0.86) × (1 − Review Confidence (0.84)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.86 · 1650 lines diff across 16 files
    0.86
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.92 · 5 substantive comment(s)
    0.92
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    84%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.400
    Self Review self_review
    0.140
    Mass File Touch mass_file_touch
    0.080
    Real PR Conversation Timeline
    28 items
    netlify[bot] netlify[bot] commented on Nov 30, 2026 10:08 UTC
    Bot

    <span aria-hidden="true">✅</span> Deploy Preview for cerulean-figolla-1f9435 ready!


    Built without sensitive environment variables

    | Name | Link |
    |:-:|------------------------|
    |<span aria-hidden="true">🔨</span> Latest commit | 02e24bd5931deb991dee9677d99d2724054d1c06 |
    |<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/projects/cerulean-figolla-1f9435/deploys/6b0e9ec8b82702d0a1a28d14 |
    |<span aria-hidden="true">😎</span> Deploy Preview | https://deploy-preview-10738--cerulean-figolla-1f9435.netlify.app |
    |<span aria-hidden="true">📱</span> Preview on mobile | <details><summary> Toggle QR Code... </summary><br /><br />!QR Code<br /><br />_Use your smartphone camera to open QR code link._</details> |
    ---
    <!-- cerulean-figolla-1f9435 Preview -->
    _To edit notification comments on pull requests, go to your Netlify project configuration._

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on Nov 30, 2026 10:08 UTC
    Bot

    <!-- codex-pull-request-review-summary -->
    <!-- codex-review-state:v1 {"code_review":{"commit_sha":"02e24bd5931deb991dee9677d99d2724054d1c06","has_any_findings":true,"has_unresolved_findings":true,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} -->

    <details>
    <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary>

    This comment shows the latest Codex review activity on this pull request.

    | Review | Status | Commit | Review trigger |
    | --- | --- | --- | --- |
    | 📝 Code Review | ✅ Completed <relative-time datetime="2026-12-01T10:23:28.228967Z">2026-12-01T10:23:28.228967Z</relative-time> | 02e24bd | New commits |

    <details> <summary>ℹ️ About Codex in GitHub</summary>
    <br/>

    Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review

  • Mark a draft as ready

  • Comment "@codex review" or "@codex security review".
  • Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

    </details>

    </details>

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on Nov 30, 2026 10:12 UTC
    Reviewer

    <!-- codex-review-receipt:v1 -->

    💡 Codex Review

    Here are some automated review suggestions for this pull request.

    Reviewed commit: cd09e571aa

    <details> <summary>ℹ️ About Codex in GitHub</summary>
    <br/>

    Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review

  • Mark a draft as ready

  • Comment "@codex review".
  • If Codex has suggestions, it will comment; otherwise it will react with 👍.

    When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

    </details>

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on code on Nov 30, 2026 10:12 UTC
    Code Review
    internal/utils/net/url.go:1
    @@ -35,6 +35,16 @@ func ParseURL(urlStr string) (scheme, hostAndPort string, err error) {
     		}
     
     		return u.Scheme, u.Host + u.Path, nil
    +	case "sds":
    +		// sds://<cluster-name> references an existing Envoy cluster (defined via
    +		// EnvoyProxy.spec.bootstrap or EnvoyPatchPolicy) that Envoy Gateway does not manage.
    +		if u.Host == "" {
    +			return "", "", fmt.Errorf("sds URL must specify a cluster name, use sds://<cluster-name>")
    +		}
    +		if u.Path != "" || u.RawQuery != "" || u.Fragment != "" {
    +			return "", "", fmt.Errorf("sds URL must not contain a path, query, or fragment, use sds://<cluster-name>")
    +		}
    +		return u.Scheme, u.Host, nil

    <sub><sub>!P2 Badge</sub></sub> Reject userinfo instead of dropping it from cluster names

    When an SDS Secret uses an @ in the authority (for example sds://tenant@external-sds), net/url stores the prefix in u.User, but this returns only u.Host; the Secret therefore passes validation and silently targets external-sds, either making an Envoy cluster named tenant@external-sds unaddressable or discarding credentials the user may believe were configured. Reject u.User != nil so malformed references fail instead of resolving secrets through a different cluster.

    Useful? React with 👍 / 👎.

    <!-- codex-code-review-finding:v1 -->

    codecov[bot] codecov[bot] commented on Nov 30, 2026 10:23 UTC
    Bot

    Codecov Report


    :x: Patch coverage is 97.31544% with 4 lines in your changes missing coverage. Please review.
    :white_check_mark: Project coverage is 82.85%. Comparing base (a50bb96) to head (02e24bd).
    :warning: Report is 2 commits behind head on main.

    | Files with missing lines | Patch % | Lines |
    |---|---|---|
    | internal/ir/xds.go | 77.77% | 2 Missing :warning: |
    | internal/xds/translator/sds.go | 98.44% | 2 Missing :warning: |

    <details><summary>Additional details and impacted files</summary>

    @@            Coverage Diff             @@
    ##             main   #10738      +/-   ##
    ==========================================
    + Coverage   82.84%   82.85%   +0.01%     
    ==========================================
      Files         279      279              
      Lines       44687    44781      +94     
    ==========================================
    + Hits        37019    37103      +84     
    - Misses       7667     7677      +10     
      Partials        1        1              
    

    </details>

    :umbrella: View full report in Codecov by Harness.
    :loudspeaker: Have feedback on the report? Share it here.
    <details><summary> :rocket: New features to boost your workflow: </summary>

  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

  • </details>

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on code on Nov 30, 2026 15:16 UTC
    Code Review
    internal/xds/translator/sds.go:1
    @@ -101,14 +134,81 @@ func buildSDSCluster(sdsURL string) *cluster.Cluster {
     		ConnectTimeout:       durationpb.New(defaultConnectionTimeout),
     		Http2ProtocolOptions: &corev3.Http2ProtocolOptions{},
     	}
    +
    +	if sds.TLS != nil {
    +		socket, err := buildSDSUpstreamTLSSocket(sds.TLS)

    <sub><sub>!P1 Badge</sub></sub> Verify the TLS server name from the SDS URL

    When TLS is enabled for an sds:// DNS endpoint, buildSDSUpstreamTLSSocket receives only the file settings, so the resulting context sets neither UpstreamTlsContext.sni nor SAN/auto-SAN validation from the URL host. Consequently, a virtual-hosted server may present the wrong default certificate and any otherwise-valid certificate signed by the configured CA is accepted regardless of hostname; pass the SDS host into this builder and use it for SNI and server-name verification.

    Useful? React with 👍 / 👎.

    <!-- codex-code-review-finding:v1 -->

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on code on Nov 30, 2026 15:16 UTC
    Code Review
    internal/xds/translator/sds.go:1
    @@ -120,45 +220,47 @@ func createSDSCluster(tCtx *types.ResourceVersionTable, sdsURL string) error {
     	return nil
     }
     
    -// processSDSClusters scans the IR for SDS URLs and creates clusters for them
    +// processSDSClusters scans the IR for SDS references and creates clusters for them
     func processSDSClusters(tCtx *types.ResourceVersionTable, xdsIR *ir.Xds) error {
    -	sdsURLs := make(map[string]struct{})
    +	sdsConfigs := make(map[string]*ir.SDSConfig)
     
    -	collectSDSURLs := func(dest []*ir.DestinationSetting) {
    +	collectSDS := func(sds *ir.SDSConfig) {
    +		if sds != nil && sds.GetURL() != "" {
    +			sdsConfigs[sds.GetURL()] = sds

    <sub><sub>!P2 Badge</sub></sub> Reject conflicting TLS settings for a shared SDS URL

    When two SDS references share a URL but carry different tlsSettings (including one reference having connection credentials while another has none), collectSDS silently replaces the earlier config here. Because sdsClusterNameFromURL also keys the cluster only by URL, the single emitted cluster uses whichever client certificate/CA was visited last, causing the other reference to authenticate with the wrong identity or fail; compare and reject conflicting configs or include the connection settings in the cluster identity.

    Useful? React with 👍 / 👎.

    <!-- codex-code-review-finding:v1 -->

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on code on Nov 30, 2026 15:16 UTC
    Code Review
    internal/xds/translator/sds.go:1
    @@ -101,14 +134,81 @@ func buildSDSCluster(sdsURL string) *cluster.Cluster {
     		ConnectTimeout:       durationpb.New(defaultConnectionTimeout),
     		Http2ProtocolOptions: &corev3.Http2ProtocolOptions{},
     	}
    +
    +	if sds.TLS != nil {
    +		socket, err := buildSDSUpstreamTLSSocket(sds.TLS)
    +		if err != nil {
    +			return nil, err
    +		}
    +		c.TransportSocket = socket
    +	}
    +
    +	return c, nil
    +}
    +
    +// buildSDSUpstreamTLSSocket builds the transport socket Envoy uses to secure its own
    +// connection to an external SDS server. The certificate material is always referenced by
    +// filesystem path, never inlined: Envoy Gateway doesn't read it, and it can't be sourced from
    +// SDS itself without making the SDS connection depend on the SDS connection.
    +//
    +// Each DataSource sets watched_directory so Envoy watches the mounted directory and reloads
    +// the cert/key or CA bundle itself on rotation, without Envoy Gateway pushing a new xDS update.
    +func buildSDSUpstreamTLSSocket(tlsSettings *ir.SDSTLSSettings) (*corev3.TransportSocket, error) {
    +	tlsCtx := &tlsv3.UpstreamTlsContext{
    +		CommonTlsContext: &tlsv3.CommonTlsContext{},
    +	}
    +
    +	if tlsSettings.CACertificatePath != "" {
    +		tlsCtx.CommonTlsContext.ValidationContextType = &tlsv3.CommonTlsContext_ValidationContext{
    +			ValidationContext: &tlsv3.CertificateValidationContext{
    +				TrustedCa: &corev3.DataSource{
    +					Specifier: &corev3.DataSource_Filename{Filename: tlsSettings.CACertificatePath},
    +				},
    +				WatchedDirectory: &corev3.WatchedDirectory{
    +					Path: filepath.Dir(tlsSettings.CACertificatePath),
    +				},
    +			},
    +		}
    +	}
    +
    +	if tlsSettings.CertificatePath != "" {
    +		tlsCtx.CommonTlsContext.TlsCertificates = []*tlsv3.TlsCertificate{
    +			{
    +				CertificateChain: &corev3.DataSource{
    +					Specifier: &corev3.DataSource_Filename{Filename: tlsSettings.CertificatePath},
    +				},
    +				PrivateKey: &corev3.DataSource{
    +					Specifier: &corev3.DataSource_Filename{Filename: tlsSettings.PrivateKeyPath},
    +				},
    +				WatchedDirectory: &corev3.WatchedDirectory{
    +					Path: filepath.Dir(tlsSettings.CertificatePath),

    <sub><sub>!P2 Badge</sub></sub> Require cert and key to share the watched directory

    When certificatePath and privateKeyPath are mounted in different directories, this TlsCertificate watches only the certificate's directory. A projected-volume rotation in the key directory therefore does not trigger a reload (and a cert-first two-directory rotation can leave the new pair unloaded), despite both paths being independently configurable; validate that both files share the watched directory or arrange a common watched parent.

    Useful? React with 👍 / 👎.

    <!-- codex-code-review-finding:v1 -->

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on Nov 30, 2026 15:16 UTC
    Reviewer

    <!-- codex-review-receipt:v1 -->

    💡 Codex Review

    Here are some automated review suggestions for this pull request.

    Reviewed commit: c3c2d0917e

    <details> <summary>ℹ️ About Codex in GitHub</summary>
    <br/>

    Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review

  • Mark a draft as ready

  • Comment "@codex review".
  • If Codex has suggestions, it will comment; otherwise it will react with 👍.

    When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

    </details>

    ramaraochavali ramaraochavali commented on code on Dec 01, 2026 04:16 UTC
    Code Review
    internal/xds/translator/sds.go:1
    @@ -101,14 +134,81 @@ func buildSDSCluster(sdsURL string) *cluster.Cluster {
     		ConnectTimeout:       durationpb.New(defaultConnectionTimeout),
     		Http2ProtocolOptions: &corev3.Http2ProtocolOptions{},
     	}
    +
    +	if sds.TLS != nil {
    +		socket, err := buildSDSUpstreamTLSSocket(sds.TLS)
    +		if err != nil {
    +			return nil, err
    +		}
    +		c.TransportSocket = socket
    +	}
    +
    +	return c, nil
    +}
    +
    +// buildSDSUpstreamTLSSocket builds the transport socket Envoy uses to secure its own
    +// connection to an external SDS server. The certificate material is always referenced by
    +// filesystem path, never inlined: Envoy Gateway doesn't read it, and it can't be sourced from
    +// SDS itself without making the SDS connection depend on the SDS connection.
    +//
    +// Each DataSource sets watched_directory so Envoy watches the mounted directory and reloads
    +// the cert/key or CA bundle itself on rotation, without Envoy Gateway pushing a new xDS update.
    +func buildSDSUpstreamTLSSocket(tlsSettings *ir.SDSTLSSettings) (*corev3.TransportSocket, error) {
    +	tlsCtx := &tlsv3.UpstreamTlsContext{
    +		CommonTlsContext: &tlsv3.CommonTlsContext{},
    +	}
    +
    +	if tlsSettings.CACertificatePath != "" {
    +		tlsCtx.CommonTlsContext.ValidationContextType = &tlsv3.CommonTlsContext_ValidationContext{
    +			ValidationContext: &tlsv3.CertificateValidationContext{
    +				TrustedCa: &corev3.DataSource{
    +					Specifier: &corev3.DataSource_Filename{Filename: tlsSettings.CACertificatePath},
    +				},
    +				WatchedDirectory: &corev3.WatchedDirectory{
    +					Path: filepath.Dir(tlsSettings.CACertificatePath),
    +				},
    +			},
    +		}
    +	}
    +
    +	if tlsSettings.CertificatePath != "" {
    +		tlsCtx.CommonTlsContext.TlsCertificates = []*tlsv3.TlsCertificate{
    +			{
    +				CertificateChain: &corev3.DataSource{
    +					Specifier: &corev3.DataSource_Filename{Filename: tlsSettings.CertificatePath},
    +				},
    +				PrivateKey: &corev3.DataSource{
    +					Specifier: &corev3.DataSource_Filename{Filename: tlsSettings.PrivateKeyPath},
    +				},
    +				WatchedDirectory: &corev3.WatchedDirectory{
    +					Path: filepath.Dir(tlsSettings.CertificatePath),

    I think it is common case to have both in same folder.

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on code on Dec 01, 2026 05:19 UTC
    Code Review
    internal/xds/translator/sds.go:1
    @@ -101,14 +140,110 @@ func buildSDSCluster(sdsURL string) *cluster.Cluster {
     		ConnectTimeout:       durationpb.New(defaultConnectionTimeout),
     		Http2ProtocolOptions: &corev3.Http2ProtocolOptions{},
     	}
    +
    +	if sds.TLS != nil {
    +		sni := addressSNI
    +		if sds.TLS.SNI != "" {
    +			sni = sds.TLS.SNI
    +		}
    +		socket, err := buildSDSUpstreamTLSSocket(sds.TLS, sni)
    +		if err != nil {
    +			return nil, err
    +		}
    +		c.TransportSocket = socket
    +	}
    +
    +	return c, nil
    +}
    +
    +// buildSDSUpstreamTLSSocket builds the transport socket Envoy uses to secure its own
    +// connection to an external SDS server. The certificate material is always referenced by
    +// filesystem path, never inlined: Envoy Gateway doesn't read it, and it can't be sourced from
    +// SDS itself without making the SDS connection depend on the SDS connection.
    +//
    +// Each DataSource sets watched_directory so Envoy watches the mounted directory and reloads
    +// the cert/key or CA bundle itself on rotation, without Envoy Gateway pushing a new xDS update.
    +//
    +// sni is used as the TLS ClientHello SNI, and, when tlsSettings.SubjectAltNames is empty, as the
    +// sole name verified against the presented certificate's Subject Alternative Names. Without SAN
    +// verification, Envoy trusts any certificate signed by the configured CA regardless of which host
    +// presented it. The caller derives sni from tlsSettings.SNI if set, falling back to the external
    +// SDS server's hostname; it's empty for a Unix domain socket SDS server or an IP-addressed one
    +// with no SNI override, neither of which has a hostname to verify.
    +func buildSDSUpstreamTLSSocket(tlsSettings *ir.SDSTLSSettings, sni string) (*corev3.TransportSocket, error) {
    +	tlsCtx := &tlsv3.UpstreamTlsContext{
    +		CommonTlsContext: &tlsv3.CommonTlsContext{},
    +		Sni:              sni,
    +	}
    +
    +	if tlsSettings.CACertificatePath != "" {
    +		validationContext := &tlsv3.CertificateValidationContext{

    <sub><sub>!P1 Badge</sub></sub> Require server authentication for SDS TLS

    When a Secret contains tlsSettings but omits caCertificatePath (for example {} or only a client certificate/key), NewSDSConfig still enables TLS, but this guard leaves the UpstreamTlsContext without any validation context. Envoy then accepts an unauthenticated SDS peer, so an on-path server can supply arbitrary certificate, key, or CA material; require a CA for TLS or make insecure operation an explicit opt-in.

    Useful? React with 👍 / 👎.

    <!-- codex-code-review-finding:v1 -->

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on code on Dec 01, 2026 05:19 UTC
    Code Review
    internal/xds/translator/sds.go:1
    @@ -101,14 +140,110 @@ func buildSDSCluster(sdsURL string) *cluster.Cluster {
     		ConnectTimeout:       durationpb.New(defaultConnectionTimeout),
     		Http2ProtocolOptions: &corev3.Http2ProtocolOptions{},
     	}
    +
    +	if sds.TLS != nil {
    +		sni := addressSNI
    +		if sds.TLS.SNI != "" {
    +			sni = sds.TLS.SNI
    +		}
    +		socket, err := buildSDSUpstreamTLSSocket(sds.TLS, sni)
    +		if err != nil {
    +			return nil, err
    +		}
    +		c.TransportSocket = socket
    +	}
    +
    +	return c, nil
    +}
    +
    +// buildSDSUpstreamTLSSocket builds the transport socket Envoy uses to secure its own
    +// connection to an external SDS server. The certificate material is always referenced by
    +// filesystem path, never inlined: Envoy Gateway doesn't read it, and it can't be sourced from
    +// SDS itself without making the SDS connection depend on the SDS connection.
    +//
    +// Each DataSource sets watched_directory so Envoy watches the mounted directory and reloads
    +// the cert/key or CA bundle itself on rotation, without Envoy Gateway pushing a new xDS update.
    +//
    +// sni is used as the TLS ClientHello SNI, and, when tlsSettings.SubjectAltNames is empty, as the
    +// sole name verified against the presented certificate's Subject Alternative Names. Without SAN
    +// verification, Envoy trusts any certificate signed by the configured CA regardless of which host
    +// presented it. The caller derives sni from tlsSettings.SNI if set, falling back to the external
    +// SDS server's hostname; it's empty for a Unix domain socket SDS server or an IP-addressed one
    +// with no SNI override, neither of which has a hostname to verify.
    +func buildSDSUpstreamTLSSocket(tlsSettings *ir.SDSTLSSettings, sni string) (*corev3.TransportSocket, error) {
    +	tlsCtx := &tlsv3.UpstreamTlsContext{
    +		CommonTlsContext: &tlsv3.CommonTlsContext{},
    +		Sni:              sni,
    +	}
    +
    +	if tlsSettings.CACertificatePath != "" {
    +		validationContext := &tlsv3.CertificateValidationContext{
    +			TrustedCa: &corev3.DataSource{
    +				Specifier: &corev3.DataSource_Filename{Filename: tlsSettings.CACertificatePath},
    +			},
    +			WatchedDirectory: &corev3.WatchedDirectory{
    +				Path: filepath.Dir(tlsSettings.CACertificatePath),
    +			},
    +		}
    +		subjectAltNames := tlsSettings.SubjectAltNames
    +		if len(subjectAltNames) == 0 && sni != "" {
    +			subjectAltNames = []string{sni}
    +		}
    +		for _, san := range subjectAltNames {
    +			sanType := tlsv3.SubjectAltNameMatcher_DNS
    +			if net.ParseIP(san) != nil {
    +				sanType = tlsv3.SubjectAltNameMatcher_IP_ADDRESS
    +			}
    +			validationContext.MatchTypedSubjectAltNames = append(validationContext.MatchTypedSubjectAltNames, &tlsv3.SubjectAltNameMatcher{
    +				SanType: sanType,
    +				Matcher: &matcherv3.StringMatcher{
    +					MatchPattern: &matcherv3.StringMatcher_Exact{Exact: san},

    <sub><sub>!P2 Badge</sub></sub> Use hostname-aware validation for the derived SDS SAN

    When the SDS URL hostname is covered by a normal wildcard certificate such as *.example.com, the derived value here is the concrete host external-sds.example.com, and an exact matcher compares it to the literal wildcard SAN and rejects the connection. Use Envoy's hostname-aware SNI/SAN validation for the derived default so wildcard DNS certificates retain standard TLS hostname semantics.

    Useful? React with 👍 / 👎.

    <!-- codex-code-review-finding:v1 -->

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on code on Dec 01, 2026 05:19 UTC
    Code Review
    internal/utils/net/url.go:1
    @@ -35,6 +35,23 @@ func ParseURL(urlStr string) (scheme, hostAndPort string, err error) {
     		}
     
     		return u.Scheme, u.Host + u.Path, nil
    +	case "sds":
    +		// sds://<host>:<port> addresses an external SDS server reachable over the network.
    +		// Envoy Gateway builds and owns the cluster that connects to it, the same way it does
    +		// for an SDS server reached over a Unix domain socket.
    +		if u.User != nil {
    +			return "", "", fmt.Errorf("sds URL must not contain user info, use sds://<host>:<port>")
    +		}
    +		if u.Hostname() == "" {
    +			return "", "", fmt.Errorf("sds URL must specify a host, use sds://<host>:<port>")
    +		}
    +		if u.Port() == "" {
    +			return "", "", fmt.Errorf("sds URL must specify a port, use sds://<host>:<port>")

    <sub><sub>!P2 Badge</sub></sub> Reject SDS ports outside the TCP range

    For URLs such as sds://external-sds.example.com:65536 or port 0, net/url still returns a non-empty numeric port, so the Secret passes Gateway validation; buildSDSCluster later only parses it as a uint32, yielding an invalid or unreachable SDS endpoint and leaving the referenced certificates unavailable. Parse and require a port in the range 1–65535 here.

    Useful? React with 👍 / 👎.

    <!-- codex-code-review-finding:v1 -->

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on Dec 01, 2026 05:19 UTC
    Reviewer

    <!-- codex-review-receipt:v1 -->

    💡 Codex Review

    Here are some automated review suggestions for this pull request.

    Reviewed commit: 6b26837501

    <details> <summary>ℹ️ About Codex in GitHub</summary>
    <br/>

    Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review

  • Mark a draft as ready

  • Comment "@codex review".
  • If Codex has suggestions, it will comment; otherwise it will react with 👍.

    When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

    </details>

    rudrakhp rudrakhp commented on code on Dec 01, 2026 05:41 UTC
    Code Review
    internal/xds/translator/testdata/out/xds-ir/sds-external.clusters.yaml:1
    @@ -0,0 +1,112 @@
    +- circuitBreakers:
    +    thresholds:
    +    - maxRetries: 1024
    +  commonLbConfig: {}
    +  connectTimeout: 10s
    +  dnsLookupFamily: V4_PREFERRED
    +  edsClusterConfig:
    +    edsConfig:
    +      ads: {}
    +      resourceApiVersion: V3
    +    serviceName: httproute/default/httproute-1/rule/0
    +  ignoreHealthOnHostRemoval: true
    +  loadBalancingPolicy:
    +    policies:
    +    - typedExtensionConfig:
    +        name: envoy.load_balancing_policies.least_request
    +        typedConfig:
    +          '@type': type.googleapis.com/envoy.extensions.load_balancing_policies.least_request.v3.LeastRequest
    +          localityLbConfig:
    +            localityWeightedLbConfig: {}
    +  metadata:
    +    filterMetadata:
    +      envoy-gateway:
    +        resources:
    +        - kind: HTTPRoute
    +          name: httproute-1
    +          namespace: default
    +  name: httproute/default/httproute-1/rule/0
    +  perConnectionBufferLimitBytes: 32768
    +  transportSocket:
    +    name: dummy.transport_socket
    +    typedConfig:
    +      '@type': type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext
    +      commonTlsContext: {}
    +  transportSocketMatches:
    +  - match:
    +      name: httproute/default/httproute-1/rule/0/tls/0
    +    name: httproute/default/httproute-1/rule/0/tls/0
    +    transportSocket:
    +      name: envoy.transport_sockets.tls
    +      typedConfig:
    +        '@type': type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext
    +        commonTlsContext:
    +          alpnProtocols:
    +          - istio
    +          combinedValidationContext:
    +            defaultValidationContext:
    +              matchTypedSubjectAltNames:
    +              - matcher:
    +                  exact: example.com
    +                sanType: DNS
    +            validationContextSdsSecretConfig:
    +              name: ROOTCA
    +              sdsConfig:
    +                apiConfigSource:
    +                  apiType: GRPC
    +                  grpcServices:
    +                  - envoyGrpc:
    +                      clusterName: sds_external-sds.example.com:8234_2809fb47702df86195537c339dc9e7bc
    +          tlsCertificateSdsSecretConfigs:
    +          - name: default
    +            sdsConfig:
    +              apiConfigSource:
    +                apiType: GRPC
    +                grpcServices:
    +                - envoyGrpc:
    +                    clusterName: sds_external-sds.example.com:8234_2809fb47702df86195537c339dc9e7bc
    +        sni: example.com
    +  type: EDS
    +  typedExtensionProtocolOptions:
    +    envoy.extensions.upstreams.http.v3.HttpProtocolOptions:
    +      '@type': type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions
    +      autoConfig:
    +        http2ProtocolOptions:
    +          initialConnectionWindowSize: 1048576
    +          initialStreamWindowSize: 65536
    +        httpProtocolOptions: {}
    +- connectTimeout: 10s
    +  http2ProtocolOptions: {}
    +  loadAssignment:
    +    clusterName: sds_external-sds.example.com:8234_2809fb47702df86195537c339dc9e7bc
    +    endpoints:
    +    - lbEndpoints:
    +      - endpoint:
    +          address:
    +            socketAddress:
    +              address: external-sds.example.com
    +              portValue: 8234
    +  name: sds_external-sds.example.com:8234_2809fb47702df86195537c339dc9e7bc
    +  transportSocket:
    +    name: envoy.transport_sockets.tls
    +    typedConfig:
    +      '@type': type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext
    +      commonTlsContext:
    +        tlsCertificates:

    Shouldn't this also use tlsCertificateSdsSecretConfigs's pathConfigSource for auto rotation?

    rudrakhp rudrakhp commented on code on Dec 01, 2026 05:54 UTC
    Code Review
    internal/xds/translator/sds.go:1
    @@ -120,45 +255,66 @@ func createSDSCluster(tCtx *types.ResourceVersionTable, sdsURL string) error {
     	return nil
     }
     
    -// processSDSClusters scans the IR for SDS URLs and creates clusters for them
    +// processSDSClusters scans the IR for SDS references and creates clusters for them
     func processSDSClusters(tCtx *types.ResourceVersionTable, xdsIR *ir.Xds) error {
    -	sdsURLs := make(map[string]struct{})
    +	sdsConfigs := make(map[string]*ir.SDSConfig)
     
    -	collectSDSURLs := func(dest []*ir.DestinationSetting) {
    +	collectSDS := func(sds *ir.SDSConfig) error {
    +		if sds == nil || sds.GetURL() == "" {
    +			return nil
    +		}
    +		url := sds.GetURL()
    +		if existing, ok := sdsConfigs[url]; ok && !sdsTLSSettingsEqual(existing.TLS, sds.TLS) {
    +			return fmt.Errorf("SDS references for %q have conflicting tlsSettings", url)

    Can we do conflict detection in the gateway api layer, so the error surfaces in the relevant BackendTLSPolicy status instead of blocking XDS?

    rudrakhp rudrakhp commented on code on Dec 01, 2026 05:56 UTC
    Code Review
    internal/utils/net/url.go:1
    @@ -35,6 +35,23 @@ func ParseURL(urlStr string) (scheme, hostAndPort string, err error) {
     		}
     
     		return u.Scheme, u.Host + u.Path, nil
    +	case "sds":
    +		// sds://<host>:<port> addresses an external SDS server reachable over the network.
    +		// Envoy Gateway builds and owns the cluster that connects to it, the same way it does
    +		// for an SDS server reached over a Unix domain socket.
    +		if u.User != nil {
    +			return "", "", fmt.Errorf("sds URL must not contain user info, use sds://<host>:<port>")
    +		}
    +		if u.Hostname() == "" {
    +			return "", "", fmt.Errorf("sds URL must specify a host, use sds://<host>:<port>")
    +		}
    +		if u.Port() == "" {
    +			return "", "", fmt.Errorf("sds URL must specify a port, use sds://<host>:<port>")

    Seems valid

    rudrakhp rudrakhp commented on Dec 01, 2026 05:57 UTC
    Reviewer

    Added some questions, thanks!

    ramaraochavali ramaraochavali commented on code on Dec 01, 2026 07:04 UTC
    Code Review
    internal/xds/translator/testdata/out/xds-ir/sds-external.clusters.yaml:1
    @@ -0,0 +1,112 @@
    +- circuitBreakers:
    +    thresholds:
    +    - maxRetries: 1024
    +  commonLbConfig: {}
    +  connectTimeout: 10s
    +  dnsLookupFamily: V4_PREFERRED
    +  edsClusterConfig:
    +    edsConfig:
    +      ads: {}
    +      resourceApiVersion: V3
    +    serviceName: httproute/default/httproute-1/rule/0
    +  ignoreHealthOnHostRemoval: true
    +  loadBalancingPolicy:
    +    policies:
    +    - typedExtensionConfig:
    +        name: envoy.load_balancing_policies.least_request
    +        typedConfig:
    +          '@type': type.googleapis.com/envoy.extensions.load_balancing_policies.least_request.v3.LeastRequest
    +          localityLbConfig:
    +            localityWeightedLbConfig: {}
    +  metadata:
    +    filterMetadata:
    +      envoy-gateway:
    +        resources:
    +        - kind: HTTPRoute
    +          name: httproute-1
    +          namespace: default
    +  name: httproute/default/httproute-1/rule/0
    +  perConnectionBufferLimitBytes: 32768
    +  transportSocket:
    +    name: dummy.transport_socket
    +    typedConfig:
    +      '@type': type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext
    +      commonTlsContext: {}
    +  transportSocketMatches:
    +  - match:
    +      name: httproute/default/httproute-1/rule/0/tls/0
    +    name: httproute/default/httproute-1/rule/0/tls/0
    +    transportSocket:
    +      name: envoy.transport_sockets.tls
    +      typedConfig:
    +        '@type': type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext
    +        commonTlsContext:
    +          alpnProtocols:
    +          - istio
    +          combinedValidationContext:
    +            defaultValidationContext:
    +              matchTypedSubjectAltNames:
    +              - matcher:
    +                  exact: example.com
    +                sanType: DNS
    +            validationContextSdsSecretConfig:
    +              name: ROOTCA
    +              sdsConfig:
    +                apiConfigSource:
    +                  apiType: GRPC
    +                  grpcServices:
    +                  - envoyGrpc:
    +                      clusterName: sds_external-sds.example.com:8234_2809fb47702df86195537c339dc9e7bc
    +          tlsCertificateSdsSecretConfigs:
    +          - name: default
    +            sdsConfig:
    +              apiConfigSource:
    +                apiType: GRPC
    +                grpcServices:
    +                - envoyGrpc:
    +                    clusterName: sds_external-sds.example.com:8234_2809fb47702df86195537c339dc9e7bc
    +        sni: example.com
    +  type: EDS
    +  typedExtensionProtocolOptions:
    +    envoy.extensions.upstreams.http.v3.HttpProtocolOptions:
    +      '@type': type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions
    +      autoConfig:
    +        http2ProtocolOptions:
    +          initialConnectionWindowSize: 1048576
    +          initialStreamWindowSize: 65536
    +        httpProtocolOptions: {}
    +- connectTimeout: 10s
    +  http2ProtocolOptions: {}
    +  loadAssignment:
    +    clusterName: sds_external-sds.example.com:8234_2809fb47702df86195537c339dc9e7bc
    +    endpoints:
    +    - lbEndpoints:
    +      - endpoint:
    +          address:
    +            socketAddress:
    +              address: external-sds.example.com
    +              portValue: 8234
    +  name: sds_external-sds.example.com:8234_2809fb47702df86195537c339dc9e7bc
    +  transportSocket:
    +    name: envoy.transport_sockets.tls
    +    typedConfig:
    +      '@type': type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext
    +      commonTlsContext:
    +        tlsCertificates:

    Yes. Will change

    zirain zirain commented on code on Dec 01, 2026 07:12 UTC
    Code Review
    internal/utils/net/url.go:1
    @@ -35,6 +35,23 @@ func ParseURL(urlStr string) (scheme, hostAndPort string, err error) {
     		}
     
     		return u.Scheme, u.Host + u.Path, nil
    +	case "sds":

    why we need a new type here? could we reuse the TODO http, https case?

    ramaraochavali ramaraochavali commented on code on Dec 01, 2026 08:03 UTC
    Code Review
    internal/utils/net/url.go:1
    @@ -35,6 +35,23 @@ func ParseURL(urlStr string) (scheme, hostAndPort string, err error) {
     		}
     
     		return u.Scheme, u.Host + u.Path, nil
    +	case "sds":

    we can but I chose to use new type to force tls/non-tls based on TLS settings supplied in the secret. But if you think we should switch to http/https - we can but needs validation that https needs TLSSettings

    ramaraochavali ramaraochavali commented on code on Dec 01, 2026 10:19 UTC
    Code Review
    internal/xds/translator/sds.go:1
    @@ -120,45 +255,66 @@ func createSDSCluster(tCtx *types.ResourceVersionTable, sdsURL string) error {
     	return nil
     }
     
    -// processSDSClusters scans the IR for SDS URLs and creates clusters for them
    +// processSDSClusters scans the IR for SDS references and creates clusters for them
     func processSDSClusters(tCtx *types.ResourceVersionTable, xdsIR *ir.Xds) error {
    -	sdsURLs := make(map[string]struct{})
    +	sdsConfigs := make(map[string]*ir.SDSConfig)
     
    -	collectSDSURLs := func(dest []*ir.DestinationSetting) {
    +	collectSDS := func(sds *ir.SDSConfig) error {
    +		if sds == nil || sds.GetURL() == "" {
    +			return nil
    +		}
    +		url := sds.GetURL()
    +		if existing, ok := sdsConfigs[url]; ok && !sdsTLSSettingsEqual(existing.TLS, sds.TLS) {
    +			return fmt.Errorf("SDS references for %q have conflicting tlsSettings", url)

    There is not easy way today to do it across BackendTLSPolicy, Listeners etc. That is why added it here. Not sure if there is any better approach here. Probably reusing the first secret on conflict may be simpler here without throwing error.

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on code on Dec 01, 2026 10:23 UTC
    Code Review
    internal/xds/translator/sds.go:1
    @@ -101,14 +139,124 @@ func buildSDSCluster(sdsURL string) *cluster.Cluster {
     		ConnectTimeout:       durationpb.New(defaultConnectionTimeout),
     		Http2ProtocolOptions: &corev3.Http2ProtocolOptions{},
     	}
    +
    +	if sds.TLS != nil {
    +		sni := addressSNI
    +		if sds.TLS.SNI != "" {
    +			sni = sds.TLS.SNI
    +		}
    +		socket, err := buildSDSUpstreamTLSSocket(clusterName, sds.TLS, sni)
    +		if err != nil {
    +			return nil, err
    +		}
    +		c.TransportSocket = socket
    +	}
    +
    +	return c, nil
     }
     
    -// createSDSCluster creates an SDS cluster for the given URL
    -func createSDSCluster(tCtx *types.ResourceVersionTable, sdsURL string) error {
    -	c := buildSDSCluster(sdsURL)
    +// buildSDSUpstreamTLSSocket builds the transport socket Envoy uses to secure its own
    +// connection to an external SDS server. The certificate material is always referenced by
    +// filesystem path, never inlined: Envoy Gateway doesn't read it, and it can't be sourced from
    +// SDS itself without making the SDS connection depend on the SDS connection.
    +//
    +// For the same reason, the cert/key and CA bundle can't be delivered as SDS secrets over Envoy
    +// Gateway's own ADS channel either: that would make this bootstrapping connection depend on a
    +// live subscription to Envoy Gateway's control plane for content that's static once written.
    +// Instead, each is referenced via a PathConfigSource pointing directly at
    +// tlsSettings.CertificatePath/CACertificatePath: Envoy requires that file to exist at config load
    +// time, in the shape of an SDS resource (an envoy.extensions.transport_sockets.tls.v3.Secret,
    +// wrapped exactly like an SDS DiscoveryResponse: {"resources":[{"@type":".../Secret","name":"...
    +// ","tls_certificate":{...}}]}, or "validation_context" for the CA). Envoy Gateway doesn't write
    +// this file; whatever provisions tlsSettings.CertificatePath/CACertificatePath is expected to
    +// provision it in that shape, and Envoy picks up rotations by watching the path for moves.
    +//
    +// sni is used as the TLS ClientHello SNI, and, when tlsSettings.SubjectAltNames is empty, as the
    +// sole name verified against the presented certificate's Subject Alternative Names. Without SAN
    +// verification, Envoy trusts any certificate signed by the configured CA regardless of which host
    +// presented it. The caller derives sni from tlsSettings.SNI if set, falling back to the external
    +// SDS server's hostname; it's empty for a Unix domain socket SDS server or an IP-addressed one
    +// with no SNI override, neither of which has a hostname to verify.
    +func buildSDSUpstreamTLSSocket(clusterName string, tlsSettings *ir.SDSTLSSettings, sni string) (*corev3.TransportSocket, error) {
    +	tlsCtx := &tlsv3.UpstreamTlsContext{
    +		CommonTlsContext: &tlsv3.CommonTlsContext{},
    +		Sni:              sni,
    +	}
    +
    +	if tlsSettings.CACertificatePath != "" {
    +		defaultValidationContext := &tlsv3.CertificateValidationContext{}
    +
    +		subjectAltNames := tlsSettings.SubjectAltNames
    +		if len(subjectAltNames) == 0 && sni != "" {
    +			subjectAltNames = []string{sni}
    +		}
    +		for _, san := range subjectAltNames {
    +			sanType := tlsv3.SubjectAltNameMatcher_DNS
    +			if net.ParseIP(san) != nil {
    +				sanType = tlsv3.SubjectAltNameMatcher_IP_ADDRESS
    +			}
    +			defaultValidationContext.MatchTypedSubjectAltNames = append(defaultValidationContext.MatchTypedSubjectAltNames, &tlsv3.SubjectAltNameMatcher{
    +				SanType: sanType,
    +				Matcher: &matcherv3.StringMatcher{
    +					MatchPattern: &matcherv3.StringMatcher_Exact{Exact: san},
    +				},
    +			})
    +		}
    +
    +		tlsCtx.CommonTlsContext.ValidationContextType = &tlsv3.CommonTlsContext_CombinedValidationContext{
    +			CombinedValidationContext: &tlsv3.CommonTlsContext_CombinedCertificateValidationContext{
    +				DefaultValidationContext: defaultValidationContext,
    +				ValidationContextSdsSecretConfig: &tlsv3.SdsSecretConfig{
    +					Name:      clusterName + "/ca",
    +					SdsConfig: pathConfigSource(tlsSettings.CACertificatePath),

    <sub><sub>!P1 Badge</sub></sub> Read the configured PEM files as TLS material

    When tlsSettings uses the documented .crt/.key paths, pathConfigSource interprets caCertificatePath and certificatePath as serialized SDS DiscoveryResponse files rather than PEM files. The output therefore asks Envoy to parse ca.crt/tls.crt as xDS resources, while privateKeyPath is never referenced at all, so server-auth TLS and mTLS to an external SDS server cannot load the configured credentials; build file-backed TLS certificate/validation data from all three paths, or redefine the API and examples around SDS descriptor files.

    Useful? React with 👍 / 👎.

    <!-- codex-code-review-finding:v1 -->

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on code on Dec 01, 2026 10:23 UTC
    Code Review
    internal/xds/translator/sds.go:1
    @@ -18,18 +20,21 @@ import (
     	corev3 "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
     	endpoint "github.com/envoyproxy/go-control-plane/envoy/config/endpoint/v3"
     	tlsv3 "github.com/envoyproxy/go-control-plane/envoy/extensions/transport_sockets/tls/v3"
    +	matcherv3 "github.com/envoyproxy/go-control-plane/envoy/type/matcher/v3"
     	resourcev3 "github.com/envoyproxy/go-control-plane/pkg/resource/v3"
    -	"google.golang.org/protobuf/proto"
    +	"github.com/envoyproxy/go-control-plane/pkg/wellknown"
    +	protobuf "google.golang.org/protobuf/proto"
     	"google.golang.org/protobuf/types/known/durationpb"
     
     	"github.com/envoyproxy/gateway/internal/ir"
    +	"github.com/envoyproxy/gateway/internal/utils/proto"
     	"github.com/envoyproxy/gateway/internal/xds/types"
     )
     
     const defaultConnectionTimeout = 10 * time.Second
     
     func sdsClusterNameFromURL(url string) string {
    -	address := strings.TrimPrefix(url, "unix://")
    +	address := strings.TrimPrefix(strings.TrimPrefix(url, "unix://"), "sds://")

    <sub><sub>!P2 Badge</sub></sub> Set the external endpoint as the gRPC authority

    When an external SDS server validates or routes the HTTP/2 :authority, sdsSecretConfig leaves EnvoyGrpc.Authority empty, so Envoy falls back to this generated cluster name. For an sds://external-sds.example.com:8234 endpoint that value is sds_external-sds.example.com:8234_<hash>, not the endpoint authority, and can be rejected or routed to the wrong virtual host; carry sds.Address into the Envoy gRPC authority for network SDS connections.

    Useful? React with 👍 / 👎.

    <!-- codex-code-review-finding:v1 -->

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on code on Dec 01, 2026 10:23 UTC
    Code Review
    internal/xds/translator/sds.go:1
    @@ -167,29 +336,47 @@ func processSDSClusters(tCtx *types.ResourceVersionTable, xdsIR *ir.Xds) error {
     		for _, route := range tcpListener.Routes {
     			if route.TLS != nil && route.TLS.Terminate != nil {
     				for _, cert := range route.TLS.Terminate.Certificates {
    -					if cert.SDS != nil && cert.SDS.GetURL() != "" {
    -						sdsURLs[cert.SDS.GetURL()] = struct{}{}
    +					if err := collectSDS(cert.SDS); err != nil {
    +						return err
     					}
     				}
     			}
     
     			if route.Destination != nil {
    -				collectSDSURLs(route.Destination.Settings)
    +				if err := collectSDSFromDestinations(route.Destination.Settings); err != nil {
    +					return err
    +				}
     			}
     		}
     	}
     
    -	urls := make([]string, 0, len(sdsURLs))
    -	for url := range sdsURLs {
    +	urls := make([]string, 0, len(sdsConfigs))
    +	for url := range sdsConfigs {
     		urls = append(urls, url)
     	}
     	slices.Sort(urls)
     
     	for _, url := range urls {
    -		if err := createSDSCluster(tCtx, url); err != nil {
    +		if err := createSDSCluster(tCtx, sdsConfigs[url]); err != nil {
     			return err
     		}
     	}
     
     	return nil
     }
    +
    +// sdsTLSSettingsEqual reports whether two SDS references agree on the TLS settings used to
    +// secure the connection to their (shared) SDS server. Two SDS Secrets can legitimately share a
    +// URL with different secretNames (e.g. a client cert and a CA cert served by the same external
    +// SDS server), but since they collapse onto a single Envoy cluster, they must agree on how that
    +// cluster's connection is secured.
    +func sdsTLSSettingsEqual(a, b *ir.SDSTLSSettings) bool {
    +	if a == nil || b == nil {
    +		return a == b
    +	}
    +	return a.CertificatePath == b.CertificatePath &&
    +		a.PrivateKeyPath == b.PrivateKeyPath &&
    +		a.CACertificatePath == b.CACertificatePath &&
    +		a.SNI == b.SNI &&
    +		slices.Equal(a.SubjectAltNames, b.SubjectAltNames)

    <sub><sub>!P2 Badge</sub></sub> Treat equivalent SAN lists as the same settings

    When two SDS Secrets share a URL and contain the same subjectAltNames in different orders, this returns false even though Envoy treats the SAN matchers as an unordered OR list. processSDSClusters then rejects the gateway as having conflicting settings instead of emitting the valid shared cluster; compare normalized SAN sets before declaring a conflict.

    Useful? React with 👍 / 👎.

    <!-- codex-code-review-finding:v1 -->

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on Dec 01, 2026 10:23 UTC
    Reviewer

    <!-- codex-review-receipt:v1 -->

    💡 Codex Review

    Here are some automated review suggestions for this pull request.

    Reviewed commit: 02e24bd593

    <details> <summary>ℹ️ About Codex in GitHub</summary>
    <br/>

    Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review

  • Mark a draft as ready

  • Comment "@codex review".
  • If Codex has suggestions, it will comment; otherwise it will react with 👍.

    When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

    </details>

    ramaraochavali ramaraochavali commented on code on Dec 01, 2026 11:08 UTC
    Code Review
    internal/xds/translator/sds.go:1
    @@ -101,14 +139,124 @@ func buildSDSCluster(sdsURL string) *cluster.Cluster {
     		ConnectTimeout:       durationpb.New(defaultConnectionTimeout),
     		Http2ProtocolOptions: &corev3.Http2ProtocolOptions{},
     	}
    +
    +	if sds.TLS != nil {
    +		sni := addressSNI
    +		if sds.TLS.SNI != "" {
    +			sni = sds.TLS.SNI
    +		}
    +		socket, err := buildSDSUpstreamTLSSocket(clusterName, sds.TLS, sni)
    +		if err != nil {
    +			return nil, err
    +		}
    +		c.TransportSocket = socket
    +	}
    +
    +	return c, nil
     }
     
    -// createSDSCluster creates an SDS cluster for the given URL
    -func createSDSCluster(tCtx *types.ResourceVersionTable, sdsURL string) error {
    -	c := buildSDSCluster(sdsURL)
    +// buildSDSUpstreamTLSSocket builds the transport socket Envoy uses to secure its own
    +// connection to an external SDS server. The certificate material is always referenced by
    +// filesystem path, never inlined: Envoy Gateway doesn't read it, and it can't be sourced from
    +// SDS itself without making the SDS connection depend on the SDS connection.
    +//
    +// For the same reason, the cert/key and CA bundle can't be delivered as SDS secrets over Envoy
    +// Gateway's own ADS channel either: that would make this bootstrapping connection depend on a
    +// live subscription to Envoy Gateway's control plane for content that's static once written.
    +// Instead, each is referenced via a PathConfigSource pointing directly at
    +// tlsSettings.CertificatePath/CACertificatePath: Envoy requires that file to exist at config load
    +// time, in the shape of an SDS resource (an envoy.extensions.transport_sockets.tls.v3.Secret,
    +// wrapped exactly like an SDS DiscoveryResponse: {"resources":[{"@type":".../Secret","name":"...
    +// ","tls_certificate":{...}}]}, or "validation_context" for the CA). Envoy Gateway doesn't write
    +// this file; whatever provisions tlsSettings.CertificatePath/CACertificatePath is expected to
    +// provision it in that shape, and Envoy picks up rotations by watching the path for moves.
    +//
    +// sni is used as the TLS ClientHello SNI, and, when tlsSettings.SubjectAltNames is empty, as the
    +// sole name verified against the presented certificate's Subject Alternative Names. Without SAN
    +// verification, Envoy trusts any certificate signed by the configured CA regardless of which host
    +// presented it. The caller derives sni from tlsSettings.SNI if set, falling back to the external
    +// SDS server's hostname; it's empty for a Unix domain socket SDS server or an IP-addressed one
    +// with no SNI override, neither of which has a hostname to verify.
    +func buildSDSUpstreamTLSSocket(clusterName string, tlsSettings *ir.SDSTLSSettings, sni string) (*corev3.TransportSocket, error) {
    +	tlsCtx := &tlsv3.UpstreamTlsContext{
    +		CommonTlsContext: &tlsv3.CommonTlsContext{},
    +		Sni:              sni,
    +	}
    +
    +	if tlsSettings.CACertificatePath != "" {
    +		defaultValidationContext := &tlsv3.CertificateValidationContext{}
    +
    +		subjectAltNames := tlsSettings.SubjectAltNames
    +		if len(subjectAltNames) == 0 && sni != "" {
    +			subjectAltNames = []string{sni}
    +		}
    +		for _, san := range subjectAltNames {
    +			sanType := tlsv3.SubjectAltNameMatcher_DNS
    +			if net.ParseIP(san) != nil {
    +				sanType = tlsv3.SubjectAltNameMatcher_IP_ADDRESS
    +			}
    +			defaultValidationContext.MatchTypedSubjectAltNames = append(defaultValidationContext.MatchTypedSubjectAltNames, &tlsv3.SubjectAltNameMatcher{
    +				SanType: sanType,
    +				Matcher: &matcherv3.StringMatcher{
    +					MatchPattern: &matcherv3.StringMatcher_Exact{Exact: san},
    +				},
    +			})
    +		}
    +
    +		tlsCtx.CommonTlsContext.ValidationContextType = &tlsv3.CommonTlsContext_CombinedValidationContext{
    +			CombinedValidationContext: &tlsv3.CommonTlsContext_CombinedCertificateValidationContext{
    +				DefaultValidationContext: defaultValidationContext,
    +				ValidationContextSdsSecretConfig: &tlsv3.SdsSecretConfig{
    +					Name:      clusterName + "/ca",
    +					SdsConfig: pathConfigSource(tlsSettings.CACertificatePath),

    Some how missed this. Let me fix it

    Assignees
    ramaraochavali ramaraochavali
    Labels
    risk: low confidence: 84.3% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 85.5% (HIGH) · Higher = larger blast radius
    85.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 84.3% · Lower = rushed or shallow review
    84.3%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 13.4% · Safe to merge
    13.4%