envoyproxy / envoy

Cloud-native high-performance edge/middle/service proxy
https://www.envoyproxy.io
Apache License 2.0
25k stars 4.81k forks source link

[discuss] Improving default TLS validation behavior for upstream connections #21409

Open fuhry opened 2 years ago

fuhry commented 2 years ago

Title: Decide whether to improve the default peer validation behavior in the tls transport_socket extension, at least for UpstreamTlsContext.

Description: It is known and documented that Envoy's tls transport socket extension does not verify the peer at all by default. There are numerous reasons why a technical decision like this might be justified:

But a number of things have changed recently:

And of course there's the contradiction that when CertificateValidationContext.trust_chain_verification is set to VERIFY_TRUST_CHAIN but the trusted_ca and watched_directory options are not also configured, no peer verification is actually done - and worse, this is the default. This configuration should be a fatal error, but currently it's silently accepted without even so much as a warning. It's really easy to trip up here and ship an insecure configuration if you miss that sentence in the docs!

As a user, I would assume that if the default value of trust_chain_verification is VERIFY_TRUST_CHAIN, then an unconfigured trusted_ca would use the system trust store, and an unconfigured match_typed_subject_alt_names would check the peer SAN against the SNI value or hostname/IP of the peer according to the underlying socket. If this is not going to be the case, the docs should have a big warning box advising users to configure some sort of peer verification, and Envoy should reject configurations with trust chain verification enabled but no trusted roots configured.

So the central question is:

Side questions:

Separate issues will be created to track technical work once we arrive at a decision here.

Relevant Links:

ggreenway commented 2 years ago

There's several things to track here.

Things we should do immediately:

Things that make obvious sense to add:

Things that need more discussion:

mattklein123 commented 2 years ago

I agree with @ggreenway summary. In general I would like to move the defaults to be more secure, but it's difficult with compatibility guarantees.

Changing the validation defaults. Reject configuration that doesn't opt-in to not validating peer certs.

One thing I think we could do here that is relatively low friction would be to WARN on any config which is loaded that does not do validation. Then at least the user would be aware (most users look at warnings). We could then have some CLI flag or something to squelch this warning if people really truly do want this.

I know that @alyssawilk has also thought about this before and when we last talked about this we concluded that even figuring what "validation" means is tricky, as Envoy is capable of many different types of validation including pinning, etc.

alyssawilk commented 2 years ago

yeah I think this overlaps some with https://github.com/envoyproxy/envoy/issues/17771 which unfortunately has been on the back burner for some time