pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Daniel Gustafsson <dgustafsson@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Make SCRAM iteration count configurable
Date: Mon, 27 Mar 2023 07:51:35 +0000
Message-ID: <E1pghde-005bVe-U9@gemulon.postgresql.org> (raw)

Make SCRAM iteration count configurable

Replace the hardcoded value with a GUC such that the iteration
count can be raised in order to increase protection against
brute-force attacks.  The hardcoded value for SCRAM iteration
count was defined to be 4096, which is taken from RFC 7677, so
set the default for the GUC to 4096 to match.  In RFC 7677 the
recommendation is at least 15000 iterations but 4096 is listed
as a SHOULD requirement given that it's estimated to yield a
0.5s processing time on a mobile handset of the time of RFC
writing (late 2015).

Raising the iteration count of SCRAM will make stored passwords
more resilient to brute-force attacks at a higher computational
cost during connection establishment.  Lowering the count will
reduce computational overhead during connections at the tradeoff
of reducing strength against brute-force attacks.

There are however platforms where even a modest iteration count
yields a too high computational overhead, with weaker password
encryption schemes chosen as a result.  In these situations,
SCRAM with a very low iteration count still gives benefits over
weaker schemes like md5, so we allow the iteration count to be
set to one at the low end.

The new GUC is intentionally generically named such that it can
be made to support future SCRAM standards should they emerge.
At that point the value can be made into key:value pairs with
an undefined key as a default which will be backwards compatible
with this.

Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Jonathan S. Katz <jkatz@postgresql.org>
Discussion: https://postgr.es/m/F72E7BC7-189F-4B17-BF47-9735EB72C364@yesql.se

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/b577743000cd0974052af3a71770a23760423102

Modified Files
--------------
doc/src/sgml/config.sgml                      | 20 ++++++++++++++++++++
src/backend/libpq/auth-scram.c                |  9 +++++++--
src/backend/utils/misc/guc_tables.c           | 13 +++++++++++++
src/backend/utils/misc/postgresql.conf.sample |  1 +
src/common/scram-common.c                     |  3 +--
src/include/common/scram-common.h             |  2 +-
src/include/libpq/scram.h                     |  3 +++
src/interfaces/libpq/fe-auth-scram.c          |  4 ++--
src/interfaces/libpq/fe-auth.c                |  4 +++-
src/interfaces/libpq/fe-auth.h                |  1 +
src/interfaces/libpq/fe-connect.c             |  2 ++
src/interfaces/libpq/fe-exec.c                |  4 ++++
src/interfaces/libpq/libpq-int.h              |  1 +
src/test/authentication/t/001_password.pl     | 25 ++++++++++++++++++++++++-
src/test/regress/expected/password.out        |  7 ++++++-
src/test/regress/sql/password.sql             |  5 +++++
16 files changed, 94 insertions(+), 10 deletions(-)



Message-ID: <E1pghde-005bVe-U9@gemulon.postgresql.org>
Permalink:  ../E1pghde-005bVe-U9@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1pghde-005bVe-U9@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: dgustafsson@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Make SCRAM iteration count configurable
  In-Reply-To: <E1pghde-005bVe-U9@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox