Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues accessing the SNI (server name) from the TLS inspector within External Authorization CheckRequest #34002

Closed
marc-barry opened this issue May 7, 2024 · 5 comments · Fixed by #34100
Labels
area/ext_authz area/tls_sni question Questions that are neither investigations, bugs, nor enhancements

Comments

@marc-barry
Copy link
Contributor

Title: Access the SNI (server name) from the TLS inspector within External Authorization CheckRequest

Description:

We make use of External Authorization as both a network and HTTP filter. In both cases we set the include_tls_session value to true. For the documentation is states:

(bool) Specifies if the TLS session level details like SNI are sent to the external service.
When this field is true, Envoy will include the SNI name used for TLSClientHello, if available, in the tls_session.

When include_tls_session is set to true one would expect that service.auth.v3.AttributeContext.TLSSession is set. I have ensured that https://www.envoyproxy.io/docs/envoy/latest/configuration/listeners/listener_filters/tls_inspector is set and can confirm that in all cases %REQUESTED_SERVER_NAME% is populated in the logs. I am using the SNI dynamic forward proxy to route the traffic based on the SNI.

Is there possibly an issue with the SNI being sent to External Authorization when using the TLS Inspector? Is there another way I can access the SNI if this manner isn't working properly? Perhaps through some form of metadata that comes across in the CheckRequest.

Note, I have built the authorization endpoint with gRPC using https://github.com/envoyproxy/go-control-plane. i.e. handling the requests with Check(ctx context.Context, req *auth.CheckRequest) (*auth.CheckResponse, error).

Relevant Links:

@marc-barry marc-barry added the triage Issue requires triage label May 7, 2024
@phlax phlax added area/ext_authz area/tls_sni question Questions that are neither investigations, bugs, nor enhancements and removed triage Issue requires triage labels May 8, 2024
@phlax
Copy link
Member

phlax commented May 8, 2024

cc @ggreenway @KBaichoo @esmet @tyxia

@ggreenway
Copy link
Contributor

The documentation isn't clear about this, but include_tls_session only works when using a tls transport socket. This could probably be fixed to also work with TlsInspector; a PR to do that would be welcome.

@marc-barry
Copy link
Contributor Author

@ggreenway Thanks for the clarification. Are you able to give me a few hints about where to look in the code about where the external auth looks at the transport socket when include_tls_session is true? I presume I could just read the server name from SNI (i.e. TLS inspector) and then are probably filters that already read it like the SNI dynamic forward proxy.

@ggreenway
Copy link
Contributor

Start by looking here and here. And then look at how the sni dynamic forward proxy is looking it up, and in CheckRequestUtils::setTLSSession if the existing path is empty, check the value from tls inspector.

@marc-barry
Copy link
Contributor Author

@ggreenway #34100 is my attempt to handle this. I'm having troubles understanding what exact unit test (or tests) that I broke. I know the file, just not which tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ext_authz area/tls_sni question Questions that are neither investigations, bugs, nor enhancements
Projects
None yet
3 participants