The vulnerability, CVE-2025-49146, arises from the pgjdbc driver incorrectly allowing fallback to insecure authentication methods when channelBinding=require is configured. The channelBinding feature is intended to prevent man-in-the-middle attacks by cryptographically linking the TLS channel to the authentication mechanism.
The provided patch (commit 9217ed16) modifies the org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication method. Before this patch, this method did not enforce the channelBinding=require setting for non-SASL authentication methods. If a user configured channelBinding=require but the server proposed an authentication method like MD5 or password (which do not support channel binding), the driver would proceed with the insecure authentication, failing to honor the require directive.
The patch introduces new logic within doAuthentication to check the ChannelBindingOption. If it's set to REQUIRE, the code now verifies that the authentication request (areq) is for SASL (AUTH_REQ_SASL, AUTH_REQ_SASL_CONTINUE, AUTH_REQ_SASL_FINAL). If it's not a SASL method, or if it's AUTH_REQ_OK (server skips authentication) without a completed SASL handshake, a PSQLException is thrown, rejecting the connection. This ensures that when channel binding is required, only authentication methods that support it (specifically SCRAM via SASL in this context) are permitted.
Therefore, the doAuthentication function, in its pre-patch state, is the vulnerable function because it failed to correctly implement the channelBinding=require security control, allowing connections with authentication methods that do not support channel binding.