-
Notifications
You must be signed in to change notification settings - Fork 78
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
Support Azure's non-mutable use of cleartext passwords over TLS #218
Conversation
I can see merging something like this for azure users. However, I don’t want to merge something that makes everyone else susceptible to downgrade attacks. Please see #192 . If there was some build-time (or runtime, that's okay too maybe) flag that clearly made people aware that turning it on is a risk they're taking, then it'd be okay. |
So I've been looking at whot some of the other pg drivers do. Interestingley it seems that cleartext authentication is typically supported and cannot even be disabled. Maybe it's not even considered a big issue in the big world... 🤷 Still, it makes sense to not use cleartext by default (at least on non-TLS connections). I'd suggest to add a configuration option |
As @straight-shoota notes in #192, it's perfectly fine if sslmode=true i.e. using an encrypted connection. I added a commit to raise - as before - if NOT using an ssl connection the 2nd commit. |
If the password is transmitted over TLS, the connection is secure. But you may still not want to sent cleartext passwords. Especially considering that currently only So, I'd still suggest to have a configuration setting. We could consider to enable |
It's a non-obvious problem, and the project itself is wrong for supporting this. Also just TLS does not fix it. Only verify-full. If the attacker is in the middle, they can terminate TLS at both ends, like to the client that the server only supports clear-text when the server is doing a better auth mechanism, then get the password from the client, and do the proper auth to the server. |
Isn't this about supporting a very popular database? All the way through postgresql 13, I'm just trying to use crystal on a new project. I obviously won't be able to do that if I can't use None of us have any control over Azure or Postgresql. |
Yes, and I'm willing to merge something that does not put all the other people not using Azure at risk. Just ssl is not enough, but something where people can turn it on in such a way that they understand that it's a security risk is ok. Or SSL if it's fully validating the remote server. |
There are thousands of user scenarios, all of which are controlled by the database administrator, not the client. pg_admin.conf is a server side config file that dictates which access methods are allowed to a ip/server/database/auth method. The 'why' for such auth choice lies with the server side admin not the client. You're over policing this. The client should provide any method the server decides it wants to use. That is why every other language provides a client with cleartext and md5. FWIW, md5 is no better than cleartext on it own. |
The point is when cleartext is an option, and even if the server doesn't support it, a man in the middle attacker can lie to the client that cleartext is the only supported method, and get the password. MD5 at least has a unique salt each time, and would require brute forcing. My mind is made up on this, sorry. The only way cleartext makes it into this driver is either with
anything else is irresponsible. |
NOTE: Only allow cleartext when using an ssl connection though
That's funny! You're right, I'd didn't see that sslmode=(verify|verify-full) aren't implemented! alla And connection.cr just swallows sslmode=verify* and doesn't raise? To be minimally consistent with this thread and truly responsible, the code should raise on any attempt to use the sslmode verify* verbs. And to be consistent with this thread, Until it's fixed there should be a prominent README.md statement for require and full rejection of sslmode=(verify-full|verify). For my part, to be productive and consistent I am going to try to get Azure to surface more auth options - at least And meanwhile, use my fork... |
@straight-shoota , @will and any other Azure Postgres Users... I got a reply from Azure Support. I guess
|
Wow, that's a really great response. Even checked that the recomended alternative server works with this driver. |
As discussed in crystal-db 141, Azure insists on asking for cleartext passwords.
While not ideal, it remains supported by postgresql and in most sane azure cases, sslmode=required.