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

Local TLS Support for Cloud SQL Auth Proxy #1085

Closed
raulsiles opened this issue Feb 1, 2022 · 7 comments
Closed

Local TLS Support for Cloud SQL Auth Proxy #1085

raulsiles opened this issue Feb 1, 2022 · 7 comments
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@raulsiles
Copy link

Feature Description

There are new scenarios, complementing the ones mentioned in 2017 for issue #102, that might require local TLS support in Cloud SQL Auth Proxy to be able to use TLS (I mention SSL here just for reference) from an app, or from a local SQL client, to the proxy.

A very specific example is when MySQL is used with "caching_sha2_password" (SHA-2) authentication (vs. the standard "mysql_native_password" authentication type). In this case, MySQL server and MySQL clients, such as MySQL Workbench, enforce the usage of TLS.

For example (using Cloud SQL Auth Proxy in localhost:3307), in MySQL Workbench, if the default connection setup for TLS is used ("If available"), due to the SHA-2 authentication type, a TLS connection is required:
sha-2

If the connection TLS setting is changed to "Require", then an error is generated, as Cloud SQL Auth proxy does not support TLS:
No_SSL_support

I might understand that TLS might not be a strong requirement from a security perspective when connecting to the proxy via localhost. I'm also aware of the overhead associated to adding TLS support to the proxy, both from a binary/code perspective, and from a configuration point of view (a new proxy key and certificate need to be generated, and/or even a new CA, or capabilities to provide these files via command line options to the proxy).

However, new scenarios like the one described above might promote re-evaluating the TLS support in the proxy.

This kind of scenario might even apply to GCP infrastructures with the sidecar pattern, not just to the local SQL client and proxy scenario described above (please DM if interested).

Alternatives Considered

It seems there is no workaround for the specific MySQL issue described above.

Additional Context

Issue #102

@raulsiles raulsiles added the type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. label Feb 1, 2022
@kurtisvg
Copy link
Contributor

kurtisvg commented Feb 1, 2022

Does the workaround described in this SO post work for MySQL Workbench: https://stackoverflow.com/a/70026049/9414803?

@raulsiles
Copy link
Author

No, the "useSSL=0" directive is equivalent to the "If available" menu option I mentioned above. This directive was required in MySQL Workbench 8.0.27 due to a bug in that version that removed the "If available" menu option by mistake. In MySQL Workbench 8.0.28 the option is back, and there is no need to set it up with the directive manually.

The issue here is that, based on the standards and/or security best practices, there are scenarios where MySQL clients will enforce the usage of TLS (SHA-2 authentication is one example), and the Cloud SQL Auth Proxy does not support it.

@kurtisvg
Copy link
Contributor

kurtisvg commented Feb 2, 2022

No, the "useSSL=0" directive is equivalent to the "If available" menu option I mentioned above.

Unless MySQL Workbench is doing something weird, useSSL=0 is typically "DISABLED" which is different from the usually default "PREFERRED" (which is what I would guess "If available" is)

According to the docs for caching_sha2_password:

For each user account, the first client connection for the user after any of the following operations must use a secure connection (made using TCP using TLS credentials, a Unix socket file, or shared memory)

Since the server side proxy is using a unix domain socket, the server isn't able to tell that the connection is over TCP. Instead, there must be some client side check happening. Switching to a unix domain socket on the local proxy side should bypass whatever client check is happening?

@enocom enocom assigned kurtisvg and unassigned enocom Feb 2, 2022
@raulsiles
Copy link
Author

raulsiles commented Feb 2, 2022

Yes, potentially using Unix sockets might change the local Cloud SQL Auth Proxy behaviour, but I'm currently testing it under Windows using TCP (Unix sockets are not supported: "unsupported network: unix"). I think the solution should cover all possible scenarios, hence my suggestion to add support for TLS to the proxy.

Potentially, the other GCP scenarios I referred to related to the sidecar pattern, Unix-based, are also affected (I don't know if they are using Unix sockets or TCP).

@enocom
Copy link
Member

enocom commented Feb 3, 2022

Related to #84.

@kurtisvg kurtisvg added the priority: p3 Desirable enhancement or fix. May not be included in next release. label Apr 5, 2022
@kurtisvg
Copy link
Contributor

kurtisvg commented Apr 5, 2022

I thought I had responded to this issue earlier, but revisiting it I realize I had typed a draft but failed to send. So allow me a belated response on why this isn't likely to get prioritized 🙂

In order to support "local TLS" between the application and the proxy, we have to have 2 things:

  1. The proxy has to start being protocol aware (e.i. it needs to be able to speak "postgres" to a protocol instance)
  2. Before accepting any connections, the proxy has to know which engine type it's talking too

The first is complicated because it means we as maintainers need to have a good understanding of the protocols for to implement it ourselves. It also means a significant increase in maintenance and testing burden, as we've got to continuously tests and observe changes to the protocol and make sure any edge cases aren't missed, and if Cloud SQL adds support of more database versions in the future, we have significant work to do to match those database versions as well.

The second is problematic because it means we have to make and complete an API call before we can start accepting connections. We actually already have to do this when listening on unix domain sockets (because some postgres drivers assume a specific suffix), and it's a bit of a friction point - not only does it increase the initial start up time, but also means when that API call fails the proxy startup also fails, which means the proxy startup is a little less deterministic than we like.

Finally, there are a bunch of tools and alternatives that do cover this use case really well. Stuff like ProxySQL and PGbouncer already offer protcol-aware proxies and add a bunch of other great features like connection pooling and read/write traffic splitting. We could try to implement similar features, but almost certainly it's not going to be as good as those projects without a ton of work and community adoption. So using one of these proxies with the Auth proxy is likely better than us trying to implement something ourselves.

So in summary the benefits there are pretty limited, and the drawbacks are pretty significant. Unless we see an overwhelming amount of feedback that says otherwise, we're probably going to focus on improving the Auth proxy in other ways (we've got a pretty long list of feature requests) before we spend too much time on this case.

@enocom
Copy link
Member

enocom commented Nov 18, 2022

Closing this out as we're unlikely to pick up this work for the reasons stated above.

As usual, though, if there's more information, feel free to re-open and add comments here.

@enocom enocom closed this as completed Nov 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

3 participants