Skip to content

Commit 1c9b6e8

Browse files
committed
Verify that the server constructed the SCRAM nonce correctly.
The nonce consists of client and server nonces concatenated together. The client checks the nonce contained the client nonce, but it would get fooled if the server sent a truncated or even empty nonce. Reported by Steven Fackler to security@postgresql.org. Neither me or Steven are sure what harm a malicious server could do with this, but let's fix it.
1 parent d951db2 commit 1c9b6e8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/interfaces/libpq/fe-auth-scram.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,8 @@ read_server_first_message(fe_scram_state *state, char *input,
430430
}
431431

432432
/* Verify immediately that the server used our part of the nonce */
433-
if (strncmp(nonce, state->client_nonce, strlen(state->client_nonce)) != 0)
433+
if (strlen(nonce) < strlen(state->client_nonce) ||
434+
memcmp(nonce, state->client_nonce, strlen(state->client_nonce)) != 0)
434435
{
435436
printfPQExpBuffer(errormessage,
436437
libpq_gettext("invalid SCRAM response (nonce mismatch)\n"));

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