Repository navigation
feat(xds): support SNI based dynamic forward proxy for TLSRoute - #9184
zhaohuabing merged 4 commits into
Conversation
Allow a Backend of type DynamicResolver to be referenced by a TLSRoute so Envoy Gateway can act as an SNI based dynamic forward proxy. The upstream host is resolved from the TLS SNI of the incoming connection and the raw TLS bytes are forwarded unchanged (passthrough). - Add the envoy.filters.network.sni_dynamic_forward_proxy network filter to the TCP filter chain of dynamic resolver routes, sharing the same DNS cache as the dynamic forward proxy cluster (fixed upstream port 443). - Ensure the tls_inspector listener filter is present so the SNI is available. - Deny loopback SNIs with a network RBAC filter to mitigate SSRF, mirroring the loopback protection of the HTTP dynamic forward proxy. - Reject a dynamic resolver combined with multiple backendRefs on a TLSRoute. Fixes envoyproxy#8787 Signed-off-by: Andrea De Murtas <[email protected]>
✅ Deploy Preview for cerulean-figolla-1f9435 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7ef38b568c
ℹ️ About Codex in GitHub
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".
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #9184 +/- ##
==========================================
+ Coverage 75.29% 75.37% +0.08%
==========================================
Files 252 253 +1
Lines 41564 41642 +78
==========================================
+ Hits 31295 31389 +94
+ Misses 8142 8123 -19
- Partials 2127 2130 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
A dynamic resolver backend forwards the connection based on the SNI and requires TLS passthrough. When the parent listener terminates TLS, Envoy consumes the downstream handshake before tcp_proxy and would forward the decrypted stream to the SNI host on port 443, breaking the intended passthrough forwarding. Reject a dynamic resolver backend on a TLS terminate listener during translation (ResolvedRefs=False) and gate the SNI dynamic forward proxy filter to passthrough routes only. Addresses review feedback on envoyproxy#8787. Signed-off-by: Andrea De Murtas <[email protected]>
|
@andreademurtas, thanks for the contribution! The PR looks good. Could you please add an e2e test covering TLSRoute with DFP backends? |
Add an end-to-end test verifying that a TLSRoute referencing a DynamicResolver backend forwards based on the SNI. A dedicated TLS passthrough backend serves a self-signed certificate whose SAN matches its in-cluster FQDN, so the SNI used to route also resolves the upstream and is validated by the client. Signed-off-by: Andrea De Murtas <[email protected]>
|
Thanks @zhaohuabing! Added in d4fb58f: a new e2e test (TLSRouteDynamicResolverBackend) routing a TLSRoute to a DynamicResolver backend over TLS passthrough. A dedicated TLS backend serves a self-signed cert whose SAN matches its in-cluster FQDN, so the SNI used to route also resolves the upstream and is validated by the client. |
|
This pull request has been automatically marked as stale because it has not had activity in the last 30 days. Please feel free to give a status update now, ping for review, when it's ready. Thank you for your contributions! |
…ic-forward-proxy Signed-off-by: Andrea De Murtas <[email protected]>
…9582) The tls-secret-1 added in #9184 for tlsroute-dynamic-resolver-with-tls-terminate.in.yaml carries a tls.key that does not match its tls.crt, so the secret fails validation: No valid secrets exist: envoy-gateway/tls-secret-1 must contain a matching tls.crt and tls.key: tls: private key does not match public key. As a result the listener is never programmed, it is dropped from both infraIR and xdsIR, and the TLSRoute reports ResolvedRefs=True instead of the intended "Dynamic resolver backend is only supported with TLS passthrough listeners" error. The test therefore no longer exercises the dynamic resolver + TLS terminate path it was written for, and gen-check fails on main because the committed .out.yaml does not match what the translator now produces. Replace tls.key with the key that actually matches tls.crt, the same one used by the other 24 testdata files sharing this certificate. The committed .out.yaml is correct as-is and is left unchanged. Signed-off-by: Huabing (Robin) Zhao <[email protected]>
…envoyproxy#9184/envoyproxy#9030 SDS changes main's new TLSRoute dynamic-resolver support referenced a destSettings variable that doesn't exist on this branch, which renamed it to allDs/backendClusterRefs earlier in this branch's own history. git's 3-way merge combined the two without a textual conflict, silently producing code that failed to compile. Adapt the check to use allDs (a dynamic resolver is never merge-eligible, so it can only appear there) while counting both allDs and backendClusterRefs for the single-destination requirement. Signed-off-by: Muhammad Waqar <[email protected]>
…envoyproxy#9184/envoyproxy#9030 SDS changes main's new TLSRoute dynamic-resolver support referenced a destSettings variable that doesn't exist on this branch, which renamed it to allDs/backendClusterRefs earlier in this branch's own history. git's 3-way merge combined the two without a textual conflict, silently producing code that failed to compile. Adapt the check to use allDs (a dynamic resolver is never merge-eligible, so it can only appear there) while counting both allDs and backendClusterRefs for the single-destination requirement. Signed-off-by: Muhammad Waqar <[email protected]>
What type of PR is this?
feat(xds)
What this PR does / why we need it:
Envoy supports SNI based dynamic forward proxy through the combination of the
tls_inspectorlistener filter, thesni_dynamic_forward_proxynetwork filter and the dynamic forward proxy cluster. Until now this could not be configured with Envoy Gateway because aBackendof typeDynamicResolvercould only be used by anHTTPRoute, not by aTLSRoute.This PR allows a
DynamicResolverBackendto be referenced by aTLSRoute, so Envoy Gateway can act as an SNI based dynamic forward proxy. The upstream host is resolved from the TLS SNI of the incoming connection and the raw TLS bytes are forwarded unchanged (passthrough).Example:
Implementation details:
envoy.filters.network.sni_dynamic_forward_proxynetwork filter to the TCP filter chain of dynamic resolver routes, sharing the same DNS cache as the dynamic forward proxy cluster. The upstream port is fixed at443, the conventional port for SNI based forwarding.tls_inspectorlistener filter is present so the SNI is available to the filter.localhost,127.0.0.1,::1) with a network RBAC filter to mitigate SSRF against the proxy's own loopback interface, mirroring the loopback protection already applied to the HTTP dynamic forward proxy.backendRefson aTLSRoute, consistent with the existing behavior forHTTPRoute.No API changes are included.
Testing:
internal/gatewayapi/testdata/tlsroute-dynamic-resolver*.yaml).tls_inspector+ loopback RBAC +sni_dynamic_forward_proxy+tcp_proxy) and the dynamic forward proxy cluster with a matching DNS cache (internal/xds/translator/testdata/.../tls-route-dynamic-resolver.*).Which issue(s) this PR fixes:
Fixes #8787
Release Notes: Yes