-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
TLS bumping: decrypting communications between internal and external services #18928
Comments
/cc @lizan @asraa @ggreenway |
Can you please elaborate on the desired traffic flow (client envoy's possition, server, which connections are TLS vs plaintext)? |
I am curious what kind of cert is needed for the google/bing access. If the upstream is google/bing, envoy doesn't terminate tls but initiate tls. The straw man flow confuses me: is the cert applied in downstream connection or upstream connection? |
@ggreenway @lambdai I mean envoy needs to terminate downstream TLS first, then we can apply many filters to control internal service accessing external network, and after that envoy initiates TLS to upstream. The mimic cert will be applied to downstream connection. There is no change to upstream connection. Thanks for your comments. |
Ok, I think I understand now. Let me paraphrase to make sure I understand: you'd like for envoy to have a CA cert/key, trusted by the downstream client, and for envoy to dynamically generate a TLS cert signed by the CA cert/key for whatever name is in the SNI of a connection? |
@ggreenway Yes, exactly. Does it make sense for you? |
I wrote some PoC code for dynamically generating cert, and I tested the downstream TLS handshake using the mimic cert. For API change, envoy currently requires certs(static or sds) set in config yaml file, and the code path doesn't take the case I mentioned into consideration. To support this feature I need a proper API introduced to indicate we will do TLS handshake using dynamic cert . I would like you could help me on this new API definition, I'm thinking about adding "tls_root_certificates" to CommonTlsContext, and it is only valid when the commonTlsContext is part of DownstreamTlsContext: [extensions.transport_sockets.tls.v3.CommonTlsContext]
[extensions.transport_sockets.tls.v3.TlsRootCertificate]
Do you think it is reasonable? |
I think a more general approach would be to implement this as a listener filter. It could either run after There have been other feature requests to support extremely large numbers of fixed/pre-generated certs and to choose the correct one at runtime, and this implementation could support that use case as well. Does that sound workable to you? |
Generating certs in a listener filter sounds workable. But an API for a listener filter might not be enough, the old |
I think we could add a |
Yes, it's Let me list several questions and answers to make the design clear:
|
Yeah this all makes sense, having generating part in transport socket sounds reasonable to me. We might need a cache to store generated cert so they aren't generated for every connection. |
Perhaps SDS should be acts as that counted cache. RDS/ECDS/EDS maintains the N:1 mapping (N subscription 1 config) and it's not surprising to introduce to SDS. @LuyaoZhong My understanding is that your POC is generating CSR, if this functionality can be moved to SDS, some of the SDS server could be leveraged |
1. Introduce API to set root CA cert/key to enable this feature e.g. common_tls_context: tls_root_ca_certificate: cert: {"filename": "root-ca.pem"} private_key: {"filename": "root-ca.key"} 2. Generate/reuse dynamic certificates pair in TLS transport socket and set SSL* a. if there is no corresponding cached certs, create CSR and create certs signed from root CA, then cache the generated certs to local cache looked up by host name b. if there is corresponding cached certs, reuse them Signed-off-by: Luyao Zhong <[email protected]>
I investigated the API, related classes and workflow, and completed the first version of code, see #19137. In this code version, we have done:
common_tls_context:
tls_root_ca_certificate:
cert: {"filename": "root-ca.pem"}
private_key: {"filename": "root-ca.key"}
I'll split the patch, polish the code, reword the original proposal description after some design details settle down. |
This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions. |
This is no stale. |
This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions. |
This issue has been automatically closed because it has not had activity in the last 37 days. If this issue is still valid, please ping a maintainer and ask them to label it as "help wanted" or "no stalebot". Thank you for your contributions. |
@LuyaoZhong I think you're missing a chunk of work in your proposed solution: You will need a way to delay the TLS handshake until you have the cert. This will probably involve a custom handshaker, which will have the integration points with your other code that fetches/generates the cert. |
@soulxu SDS can not satisfy my requirement, The lack of on-demand in Istio is one of the gaps. Envoy does not support that as well. Besides, each sds config is corresponding to one secret provider in transport socket which can only fetch one single extensions.transport_sockets.tls.v3.TlsCertificate, if we need multiple certificates we will require the control plane to distribute more sds configs, I don't know how to implement this functionality. How to carry information from dataplane to sds server is another problem, these information is used to mimicking certs, but we have request format limitations when use xDS protocol.
@ggreenway We can delay the TLS handshake until we have the cert with current proposal. I give more details about how it work and address your comments in bumping doc. |
Thanks! Not sure I understand correctly, Is the problem that currently each TlsCertificateConfigProvider only return one secret? Not sure if that possible to change Actually, I'm thinking it will be great if the custom certificate provider can return the same tls certicate config (https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/transport_sockets/tls/v3/common.proto#envoy-v3-api-msg-extensions-transport-sockets-tls-v3-tlscertificate) This is will be consistent with SDS provider and static cert provider, then you can utilize most of other part codes I thought. Like you also can config the private key provider, and the other part of tls transport will help make it works. Apologize if I still do not understand correctly.
I got it. Seems your key requirement is mimicking certs on-demand, which lead to you to consider the on-demand SDS. I'm just thinking that the admin or operator can pre-defined the allowed sites to access, then the control plane generates those mimicking certs first before deploying the Envoy. But yes, I'm not sure that matching your original requirement or not. be curious, in your use case, would you allow your admin/operator to control which site can be mimick? |
Yes, my plan is to let the cert provider return a tls certificate config list #19582 (comment). This is going to be updated to the cert provider PR.
Control plane can not mimic the certs based on real server cert, so this must be handle in Envoy after connecting upstream.
Yes, we will allow admin/operator to set a bumping list or a list that we don't want bumping. |
@ggreenway kindly ping :) |
@ggreenway Thanks for your comments. Please have a look at my reply in bumping doc. |
@ggreenway Thanks for your comments to help make the design details clear, I reply in bumping doc. Please have a look and let me know if you have other concern about this design. |
@ggreenway kindly ping :) |
I don't have any other comments. I think more will come out as you explore implementation. |
@ggreenway Thanks. We will explore implementation based on design clarified in bumping doc. 4 work items were worked out:
We will create issue or PR for these work item, let's we discuss the implementation details there. cc @mattklein123 @lambdai @soulxu Thanks for your comments. |
Hi @LuyaoZhong, thanks for raising this as it is an important security use case. I have a question about the proposal and the intended support - would this work with HTTP CONNECT like you describe in your presentation video (https://events.istio.io/istiocon-2022/sessions/introducing-tls-bumping/) as well? |
Yes, making this work with HTTP CONNECT is one of our goals. We are going to utilize internal listener feature to handle HTTP CONNECT. The data flow looks like this: Client -> ListenerA(HCM with CONNECT termination) -> InternalListenerB(TLS Bumping) -> Upstream server. Would you mind share your use case or scenario? We'd like to know more about requirements from real world. |
Forward proxy is the main use case where the user points the browser/system proxy at Envoy. One of things that is not optimal in Envoy is the need for the internal listener for the bumping TLS termination but I guess a new custom filter would be needed which can satisfy both CONNECT termination and the payload TLS termination and mimicking. |
A new custom filter was an alternative, we had #19346 as PoC before, but this can only work for HTTP/1.0. To support HTTP/2 even QUIC, a complicated network filter is required, and we can predict that we need to copy a lot of logic from HCM to process http protocol, but the filter is just for handling CONNECT eventually. So we need to evaluate if it is worth a new filter. It's ideal to make CONNECT termination and TLS bumping together, but due to the limitation of envoy framework, it is hard to implement currently. :( |
@LuyaoZhong do you know if this implementation will be compatible with the custom handshaker extension ?? I.E. to be able to send some of the relevant server cert information (SANs, CN, etc...) or the certificate itself to a custom handshaker extension?? |
@amthorn Sorry for late response, I missed your comment. I think the answer is yes, just let the custom handshaker extension to interact with cert provider. |
@LuyaoZhong What if my custom handshaker already implemented a cert-provider interface?? Can i disable the envoy one and use the one my handshaker provides?? (We pass the SNI currently which forwards to the cert provider, but with this change we'd forward the SANs/CN into the handshaker instead of the SNI) |
@amthorn If you are asking if cert provider can work with custom handshaker in general, Yes, you need to implement a custom handshaker which can fetch certs from a cert provider instance. We can discuss on #19308 and #19582 If you are asking if tls bumping can work with custom handshaker, I think it depends on custom handshaker, in our current design we rely on envoy to loading certs and create a default handshaker to select cert based on SNI, when switching custom handshaker, we need to consider implementing similar functionalities to support tls bumping. |
I was asking about the latter. You answered my question, I think changes would be required to a handshaker that already does it's own SNI-based certificate lookup (It is not enabled for certificate bumping). If i understand correctly, the two options we have are that either:
I'm not expecting a response, just stating my understanding so that you can correct it if i'm wrong. |
I built a poc with xDS and ALS which kind of does what this is supposed to do: https://github.com/epk/envoy-egress-mitm:
There's a suite in |
@LuyaoZhong Are you guys still pursuing this? |
Hi @vermajit, @epk , Thanks in advance! |
Also looking at Envoy as a forward proxy, however, it's unclear to me of TLS Bumping is supported or not. |
We don't support it today. |
hi @LuyaoZhong @soulxu @amthorn @epk and team is there any progress? what is the plan? any alternatives as of may 2024? |
TLS Bumping in Envoy Design Doc
2022.10.31
PoC: #23192
README and configurations are in tls_bumping subdir
2022.07.13
4 work items were worked out.
Implement CertificateProvider mechanism #19308
Implement Certificate Provider Framework (#19308) #19582
SNI-based cert selection in TLS transport socket #21739
SNI-based cert selection during TLS handshake #22036
Add a bumping filter for cert mimicking #22581
WiP Add Bumping filter #22582
WIP: Local cert provider #23063
2022.04.24 update
Mimicking certs only based on SNI is probably not enough, we require server real certificate and ensure to copy subject, subject alt name, extensions, knowing about the RSA key strength and many more. Original proposal was to set up client-first secure connection, to meet above requirements we need server-first secure connection.
Therefore, we expect the workflow like this:
Original Proposal
Title: decrypting communications between internal and external services
Description:
Changes (straw man)
Any comments are welcome.
The text was updated successfully, but these errors were encountered: