Server ignores contents of SASLInitialResponse

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Server ignores contents of SASLInitialResponse
Date: 2017-05-25 03:33:37
Message-ID: CAB7nPqR0G5aF2_kc_LH29knVqwvmBc66TF5DicvpGVdke68nKw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi all,

I have noticed today that the server ignores completely the contents
of SASLInitialResponse. For example with the patch attached called
scram-trick-server:
diff --git a/src/interfaces/libpq/fe-auth.c b/src/interfaces/libpq/fe-auth.c
index f4397afc64..8fe1c8edfb 100644
--- a/src/interfaces/libpq/fe-auth.c
+++ b/src/interfaces/libpq/fe-auth.c
@@ -540,7 +540,7 @@ pg_SASL_init(PGconn *conn, int payloadlen)
conn->sasl_state = pg_fe_scram_init(conn->pguser, password);
if (!conn->sasl_state)
goto oom_error;
- selected_mechanism = SCRAM_SHA256_NAME;
+ selected_mechanism = "kunfoobar";
}
}

This sends a custom string to the server to name a SASL mechanism,
about which the server complains with a COMMERROR log:
LOG: client selected an invalid SASL authentication mechanism
However this error is completely ignored and the server continues
authentication, succeeding if the password is right. It seems to me
that the error that should be returned to the user is a password
mismatch, and that the COMMERROR message is kept only for the server
logs. Attached is a patch to fix the problem.

Open item added as well.

Thanks,
--
Michael

Attachment Content-Type Size
scram-trick-server.patch application/octet-stream 456 bytes
fix-sasl-init.patch application/octet-stream 606 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2017-05-25 03:41:12 Commit fests created for PG11 development
Previous Message Noah Misch 2017-05-25 03:11:28 Re: retry shm attach for windows (WAS: Re: OK, so culicidae is *still* broken)