The folks at bit.io just published an excellent
review of PostgreSQL
security,
with a startling conclusion: the vast majority of PostgreSQL
connections that are happening over the public internet are
insecure, due to a combination of server misconfigurations and most
clients unfortunately defaulting to unsafe settings.
In short: most Postgres clients either don’t enforce TLS at all on
the connections to servers, or enforce that a TLS handshake happens
but don’t verify that the certificate is valid and matches the
expected hostname. What this means in practice is that those
connections can be trivially interposed by anyone sitting between
the client and server - a classic Machine in the Middle (MitM)
attack.