Subject: [pgjdbc/pgjdbc] PR #3664: fix: allow sslMode=verify-full connections with any authentication type even with channelBinding=require

From: "vlsi (@vlsi)" <[email-masked]>
Date: Sat, 14 Jun 2025 10:25:29 +0000

Previously, `channelBinding=require` required scram authentication, and it effectively prevented certificate-based authentication.

The change aligns `channelBinding=require` behaviour to ensure it "prevents MITM"

Then MITM prevention could be:
a) `channelBinding=require` + `sslMode=verify-full` + any auth
  This would require clients to configure server's certificate at the client.
b) `channelBinding=require` + `sslMode=require` + SCRAM auth
  This would be easier to configure (no need to configure server's certificate at the client)
    at a cost of reconfiguring the user to use SCRAM auth.

Follow-up to 9217ed16cb2918ab1b6b9258ae97e6ede244d8a0

---

From: "davecramer (@davecramer)" <[email-masked]>
Date: Sat, 14 Jun 2025 10:41:14 +0000

makes sense. I don't think it would break anything

---

From: "sehrope (@sehrope)" <[email-masked]>
Date: Sat, 14 Jun 2025 11:31:00 +0000

I don't think this is a good idea. I agree the previous fix breaks channel_binding=require with verify-full / md5-auth. But that's because the broken part of that was not ensuring that we are using SASL (rather than md5 auth). Channel binding mandates using SASL which does more than just verifying the TLS certificate. It ensures that the server knows the clients password by completing the SASL handshake.

In the extreme case, you could have sslmode=verify-full + plaintext auth. With a compromised network and CA chain, that would expose you to giving out the plaintext password to a rogue server. With channel binding mandating SASL, the server itself with your password hash would have to be compromised.

We should confirm and match the behavior of libpq. I'm pretty sure it rejects connections if you request channel binding with a non-SASL auth scheme.

---

From: "vlsi (@vlsi)" <[email-masked]>
Date: Sat, 14 Jun 2025 14:42:45 +0000

Well, if someone compromises CA, you are in trouble anyway.