Repository: Mailu/Mailu

Issue:
refining the default password scheme
In https://github.com/Mailu/Mailu/pull/647 the default scheme was switched to BCRYPT. The argumentation was:

> bcrypt is fast¹ and secure[...]

While it's actually secure, bcypt is not fast. It is _designed_ to be slow - to consume a very high amount of CPU resources to make brute-force attacs expensive.

Unfortunately, such a password scheme is not a good choice for a stateless system where many auth checks are done in a very short time. The current bcrypt strength of 12 consumes ~0.7s of CPU time for each authentication.

This might work for low-volume sites but can easily max out multiple cpus if there's some user traffic.

We should default to something alternative like PBKDF2 that ensures fast response times for auth requests.


Discussion:

Resolving patch:
diff --git a/core/admin/mailu/configuration.py b/core/admin/mailu/configuration.py
--- a/core/admin/mailu/configuration.py
+++ b/core/admin/mailu/configuration.py
@@ -51,7 +51,7 @@
     'RECAPTCHA_PUBLIC_KEY': '',
     'RECAPTCHA_PRIVATE_KEY': '',
     # Advanced settings
-    'PASSWORD_SCHEME': 'BLF-CRYPT',
+    'PASSWORD_SCHEME': 'PBKDF2',
     'LOG_LEVEL': 'WARNING',
     # Host settings
     'HOST_IMAP': 'imap',


Test patch:
diff --git a/tests/compose/core/mailu.env b/tests/compose/core/mailu.env
--- a/tests/compose/core/mailu.env
+++ b/tests/compose/core/mailu.env
@@ -129,8 +129,8 @@ WEBSITE=https://mailu.io
 COMPOSE_PROJECT_NAME=mailu
 
 # Default password scheme used for newly created accounts and changed passwords
-# (value: BLF-CRYPT, SHA512-CRYPT, SHA256-CRYPT, MD5-CRYPT, CRYPT)
-PASSWORD_SCHEME=BLF-CRYPT
+# (value: PBKDF2, BLF-CRYPT, SHA512-CRYPT, SHA256-CRYPT)
+PASSWORD_SCHEME=PBKDF2
 
 # Header to take the real ip from
 REAL_IP_HEADER=
@@ -144,4 +144,4 @@ REJECT_UNLISTED_RECIPIENT=
 # Test for initial admin create
 INITIAL_ADMIN_ACCOUNT=admin
 INITIAL_ADMIN_DOMAIN=mailu.io
-INITIAL_ADMIN_PW=FooBar
\ No newline at end of file
+INITIAL_ADMIN_PW=FooBar
diff --git a/tests/compose/fetchmail/mailu.env b/tests/compose/fetchmail/mailu.env
--- a/tests/compose/fetchmail/mailu.env
+++ b/tests/compose/fetchmail/mailu.env
@@ -129,8 +129,8 @@ WEBSITE=https://mailu.io
 COMPOSE_PROJECT_NAME=mailu
 
 # Default password scheme used for newly created accounts and changed passwords
-# (value: BLF-CRYPT, SHA512-CRYPT, SHA256-CRYPT, MD5-CRYPT, CRYPT)
-PASSWORD_SCHEME=BLF-CRYPT
+# (value: PBKDF2, BLF-CRYPT, SHA512-CRYPT, SHA256-CRYPT)
+PASSWORD_SCHEME=PBKDF2
 
 # Header to take the real ip from
 REAL_IP_HEADER=
diff --git a/tests/compose/filters/mailu.env b/tests/compose/filters/mailu.env
--- a/tests/compose/filters/mailu.env
+++ b/tests/compose/filters/mailu.env
@@ -129,8 +129,8 @@ WEBSITE=https://mailu.io
 COMPOSE_PROJECT_NAME=mailu
 
 # Default password scheme used for newly created accounts and changed passwords
-# (value: BLF-CRYPT, SHA512-CRYPT, SHA256-CRYPT, MD5-CRYPT, CRYPT)
-PASSWORD_SCHEME=BLF-CRYPT
+# (value: PBKDF2, BLF-CRYPT, SHA512-CRYPT, SHA256-CRYPT)
+PASSWORD_SCHEME=PBKDF2
 
 # Header to take the real ip from
 REAL_IP_HEADER=
diff --git a/tests/compose/rainloop/mailu.env b/tests/compose/rainloop/mailu.env
--- a/tests/compose/rainloop/mailu.env
+++ b/tests/compose/rainloop/mailu.env
@@ -129,8 +129,8 @@ WEBSITE=https://mailu.io
 COMPOSE_PROJECT_NAME=mailu
 
 # Default password scheme used for newly created accounts and changed passwords
-# (value: BLF-CRYPT, SHA512-CRYPT, SHA256-CRYPT, MD5-CRYPT, CRYPT)
-PASSWORD_SCHEME=BLF-CRYPT
+# (value: PBKDF2, BLF-CRYPT, SHA512-CRYPT, SHA256-CRYPT)
+PASSWORD_SCHEME=PBKDF2
 
 # Header to take the real ip from
 REAL_IP_HEADER=
diff --git a/tests/compose/roundcube/mailu.env b/tests/compose/roundcube/mailu.env
--- a/tests/compose/roundcube/mailu.env
+++ b/tests/compose/roundcube/mailu.env
@@ -129,8 +129,8 @@ WEBSITE=https://mailu.io
 COMPOSE_PROJECT_NAME=mailu
 
 # Default password scheme used for newly created accounts and changed passwords
-# (value: BLF-CRYPT, SHA512-CRYPT, SHA256-CRYPT, MD5-CRYPT, CRYPT)
-PASSWORD_SCHEME=BLF-CRYPT
+# (value: PBKDF2, BLF-CRYPT, SHA512-CRYPT, SHA256-CRYPT)
+PASSWORD_SCHEME=PBKDF2
 
 # Header to take the real ip from
 REAL_IP_HEADER=
diff --git a/tests/compose/webdav/mailu.env b/tests/compose/webdav/mailu.env
--- a/tests/compose/webdav/mailu.env
+++ b/tests/compose/webdav/mailu.env
@@ -129,8 +129,8 @@ WEBSITE=https://mailu.io
 COMPOSE_PROJECT_NAME=mailu
 
 # Default password scheme used for newly created accounts and changed passwords
-# (value: BLF-CRYPT, SHA512-CRYPT, SHA256-CRYPT, MD5-CRYPT, CRYPT)
-PASSWORD_SCHEME=BLF-CRYPT
+# (value: PBKDF2, BLF-CRYPT, SHA512-CRYPT, SHA256-CRYPT)
+PASSWORD_SCHEME=PBKDF2
 
 # Header to take the real ip from
 REAL_IP_HEADER=