Skip to content

Commit 67d28bd

Browse files
committed
libpq: Bail out during SSL/GSS negotiation errors
This commit changes libpq so that errors reported by the backend during the protocol negotiation for SSL and GSS are discarded by the client, as these may include bytes that could be consumed by the client and write arbitrary bytes to a client's terminal. A failure with the SSL negotiation now leads to an error immediately reported, without a retry on any other methods allowed, like a fallback to a plaintext connection. A failure with GSS discards the error message received, and we allow a fallback as it may be possible that the error is caused by a connection attempt with a pre-11 server, GSS encryption having been introduced in v12. This was a problem only with v17 and newer versions; older versions discard the error message already in this case, assuming a failure caused by a lack of support for GSS encryption. Author: Jacob Champion Reviewed-by: Peter Eisentraut, Heikki Linnakangas, Michael Paquier Security: CVE-2024-10977 Backpatch-through: 12
1 parent f7ca23a commit 67d28bd

File tree

2 files changed

+16
-19
lines changed

2 files changed

+16
-19
lines changed

doc/src/sgml/protocol.sgml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1513,10 +1513,10 @@ SELCT 1/0;<!-- this typo is intentional -->
15131513

15141514
<para>
15151515
The frontend should also be prepared to handle an ErrorMessage
1516-
response to SSLRequest from the server. This would only occur if
1517-
the server predates the addition of <acronym>SSL</acronym> support
1518-
to <productname>PostgreSQL</productname>. (Such servers are now very ancient,
1519-
and likely do not exist in the wild anymore.)
1516+
response to SSLRequest from the server. The frontend should not display
1517+
this error message to the user/application, since the server has not been
1518+
authenticated
1519+
(<ulink url="https://www.postgresql.org/support/security/CVE-2024-10977/">CVE-2024-10977</ulink>).
15201520
In this case the connection must
15211521
be closed, but the frontend might choose to open a fresh connection
15221522
and proceed without requesting <acronym>SSL</acronym>.
@@ -1590,12 +1590,13 @@ SELCT 1/0;<!-- this typo is intentional -->
15901590

15911591
<para>
15921592
The frontend should also be prepared to handle an ErrorMessage
1593-
response to GSSENCRequest from the server. This would only occur if
1594-
the server predates the addition of <acronym>GSSAPI</acronym> encryption
1595-
support to <productname>PostgreSQL</productname>. In this case the
1596-
connection must be closed, but the frontend might choose to open a fresh
1597-
connection and proceed without requesting <acronym>GSSAPI</acronym>
1598-
encryption.
1593+
response to GSSENCRequest from the server. The frontend should not display
1594+
this error message to the user/application, since the server has not been
1595+
authenticated
1596+
(<ulink url="https://www.postgresql.org/support/security/CVE-2024-10977/">CVE-2024-10977</ulink>).
1597+
In this case the connection must be closed, but the frontend might choose
1598+
to open a fresh connection and proceed without requesting
1599+
<acronym>GSSAPI</acronym> encryption.
15991600
</para>
16001601

16011602
<para>

src/interfaces/libpq/fe-connect.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3388,16 +3388,12 @@ PQconnectPoll(PGconn *conn)
33883388
{
33893389
/*
33903390
* Server failure of some sort, such as failure to
3391-
* fork a backend process. We need to process and
3392-
* report the error message, which might be formatted
3393-
* according to either protocol 2 or protocol 3.
3394-
* Rather than duplicate the code for that, we flip
3395-
* into AWAITING_RESPONSE state and let the code there
3396-
* deal with it. Note we have *not* consumed the "E"
3397-
* byte here.
3391+
* fork a backend process. Don't bother retrieving
3392+
* the error message; we should not trust it as the
3393+
* server has not been authenticated yet.
33983394
*/
3399-
conn->status = CONNECTION_AWAITING_RESPONSE;
3400-
goto keep_going;
3395+
libpq_append_conn_error(conn, "server sent an error response during SSL exchange");
3396+
goto error_return;
34013397
}
34023398
else
34033399
{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy