You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2024/09/10 15:50:03 UTC

(couchdb) 01/01: enhance default security of passwords

This is an automated email from the ASF dual-hosted git repository.

rnewson pushed a commit to branch more-secure-defaults
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 490da27e592deebde93c587a28ee8f11024a0443
Author: Robert Newson <rn...@apache.org>
AuthorDate: Tue Sep 10 16:04:19 2024 +0100

    enhance default security of passwords
    
    * enable the lockout protectios against online password attacks
    * change default password to PBKDF2
    * increase workfactor of new PBKDF2 hashes to protect against
      offline password attacks
---
 rel/overlay/etc/default.ini             | 4 ++--
 src/couch/src/couch_auth_lockout.erl    | 2 +-
 src/couch/src/couch_password_hasher.erl | 2 +-
 src/couch/src/couch_passwords.erl       | 2 +-
 src/couch/src/couch_users_db.erl        | 2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/rel/overlay/etc/default.ini b/rel/overlay/etc/default.ini
index f5e792f28..41cd9de32 100644
--- a/rel/overlay/etc/default.ini
+++ b/rel/overlay/etc/default.ini
@@ -331,7 +331,7 @@ bind_address = 127.0.0.1
 ;timeout = 600 ; number of seconds before automatic logout
 ;auth_cache_size = 50 ; size is number of cache entries
 ;allow_persistent_cookies = true ; set to false to disallow persistent cookies
-;iterations = 50000 ; iterations for password hashing
+;iterations = 6000000 ; iterations for password hashing
 ;min_iterations = 1
 ;max_iterations = 1000000000
 ;password_scheme = pbkdf2
@@ -1068,7 +1068,7 @@ url = {{nouveau_url}}
 ; warn - CouchDB will log a warning if repeated authentication failures occur
 ; enforce - CouchDB will reject requests with a 403 status code if repeated
 ; authentication failures occur
-;mode = off
+;mode = enforce
 
 ; The number of authentication failures above which lockout occurs.
 ;threshold = 5
diff --git a/src/couch/src/couch_auth_lockout.erl b/src/couch/src/couch_auth_lockout.erl
index 5b2e3e51a..ceed57f11 100644
--- a/src/couch/src/couch_auth_lockout.erl
+++ b/src/couch/src/couch_auth_lockout.erl
@@ -61,7 +61,7 @@ lockout(#httpd{} = Req, UserName, UserSalt) ->
     end.
 
 lockout_mode() ->
-    case config:get("chttpd_auth_lockout", "mode", "off") of
+    case config:get("chttpd_auth_lockout", "mode", "enforce") of
         "off" ->
             off;
         "warn" ->
diff --git a/src/couch/src/couch_password_hasher.erl b/src/couch/src/couch_password_hasher.erl
index 70d43d6e9..d947500d6 100644
--- a/src/couch/src/couch_password_hasher.erl
+++ b/src/couch/src/couch_password_hasher.erl
@@ -117,7 +117,7 @@ needs_upgrade(UserProps) ->
     TargetPRF = ?l2b(chttpd_util:get_chttpd_auth_config("pbkdf2_prf", "sha256")),
     CurrentIterations = couch_util:get_value(<<"iterations">>, UserProps),
     TargetIterations = chttpd_util:get_chttpd_auth_config_integer(
-        "iterations", 50000
+        "iterations", 6000000
     ),
     case {TargetScheme, TargetIterations, TargetPRF} of
         {CurrentScheme, CurrentIterations, _} when CurrentScheme == <<"simple">> ->
diff --git a/src/couch/src/couch_passwords.erl b/src/couch/src/couch_passwords.erl
index 74f35e42e..14ca69188 100644
--- a/src/couch/src/couch_passwords.erl
+++ b/src/couch/src/couch_passwords.erl
@@ -44,7 +44,7 @@ hash_admin_password("simple", ClearPassword) ->
     ?l2b("-hashed-" ++ couch_util:to_hex(Hash) ++ "," ++ ?b2l(Salt));
 hash_admin_password("pbkdf2", ClearPassword) ->
     PRF = chttpd_util:get_chttpd_auth_config("pbkdf2_prf", "sha256"),
-    Iterations = chttpd_util:get_chttpd_auth_config("iterations", "50000"),
+    Iterations = chttpd_util:get_chttpd_auth_config("iterations", "6000000"),
     Salt = couch_uuids:random(),
     DerivedKey = couch_passwords:pbkdf2(
         list_to_existing_atom(PRF),
diff --git a/src/couch/src/couch_users_db.erl b/src/couch/src/couch_users_db.erl
index b8d583421..857a62afa 100644
--- a/src/couch/src/couch_users_db.erl
+++ b/src/couch/src/couch_users_db.erl
@@ -101,7 +101,7 @@ save_doc(#doc{body = {Body}} = Doc) ->
             ok = validate_password(ClearPassword),
             PRF = chttpd_util:get_chttpd_auth_config("pbkdf2_prf", "sha256"),
             Iterations = chttpd_util:get_chttpd_auth_config_integer(
-                "iterations", 50000
+                "iterations", 6000000
             ),
             DerivedKey = couch_passwords:pbkdf2(
                 list_to_existing_atom(PRF), ClearPassword, Salt, Iterations