Skip to content

Commit db476f1

Browse files
committed
issue2551253 - Modify password PBKDF2 method to use SHA512
Implement new PBKDF2-SHA512 more secure password hash function. Intended to be future default once I get more feedback. upgrading.txt: added doc for using it now. reference.py: Added enabling future features to use case for interfaces.py. admin.py: Changed perftest password command to use the default password function. Can be used to verify that new hash is enabled properly.
1 parent 58def37 commit db476f1

File tree

4 files changed

+89
-16
lines changed

4 files changed

+89
-16
lines changed

CHANGES.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ Features:
139139
- issue2551265 - deprecate SSHA password hash method. Users using SSHA
140140
passwords will have their passwords transprently upgraded to PBKDF2
141141
derived hash on next login. (John Rouillard)
142+
- issue2551253 - Modify password PBKDF2 method to use SHA512. New
143+
hash function using PBKDF2-SHA512 available. Will be default in
144+
future. Directions for upgrading security by using it now is
145+
included in upgrading.txt. (John Rouillard)
142146

143147
2022-07-13 2.2.0
144148

doc/reference.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1498,6 +1498,7 @@ this you can:
14981498
* monkey patch core code to add new functionality
14991499
* modify the email gateway
15001500
* add new rest endpoints
1501+
* enable experimental or future features
15011502

15021503
but with great power comes great responsibility.
15031504

doc/upgrading.txt

Lines changed: 83 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -209,24 +209,37 @@ SQLite databases. If you want to keep using the data set the
209209
Update ``config.ini``'s ``password_pbkdf2_default_rounds`` (required)
210210
---------------------------------------------------------------------
211211

212-
Roundup hashes passwords using PBKDF2 with SHA1. PBKDF2 has a
213-
parameter that makes hashing a password more difficult to do.
214-
The original 10000 value was set years ago. It has not been
215-
updated for advancements in computing power.
212+
Roundup hashes passwords using PBKDF2 with SHA1. In this release, you
213+
can `upgrade to PBKDF2-SHA512 from current PBKDF2-SHA1`. If you
214+
upgrade, you want to set the default rounds according to the
215+
PBKDF2-SHA512 upgrading directions. Note that this algorithm is
216+
expected to be the default in a future version of Roundup.
217+
218+
If you don't want to upgrade, we recommend that you increase the
219+
default number of rounds from the original 10000. PBKDF2 has a
220+
parameter that makes hashing a password more difficult to do. The
221+
original 10000 value was set years ago. It has not been updated for
222+
advancements in computing power.
216223

217224
This release of Roundup changes the value to 2000000 (2
218225
million). This exceeds the current `recommended setting of
219226
1,300,000`_ for PBKDF2 when used with SHA1.
220227

221-
If you were using the old 10000 value, it will be automatically
222-
upgraded to 2 million by using ``roundup-admin``'s
223-
``updateconfig``. If you were not using the old 10000 default,
224-
you should update it manually.
228+
.. caution::
225229

226-
After the change users will still be able to log in using the
227-
older 10000 round hashed passwords. If ``migrate_passwords`` is
228-
set to ``yes``, passwords will be automatically re-hashed using
229-
the new higher value when the user logs in.
230+
If you were using the old 10000 value, **it will be automatically
231+
upgraded** to 2 million by using ``roundup-admin``'s
232+
``updateconfig``. If you were not using the old 10000 default, you
233+
should update it manually.
234+
235+
After the change users will still be able to log in using the older
236+
10000 round hashed passwords. If ``migrate_passwords`` is set to
237+
``yes``, passwords will be automatically re-hashed using the new
238+
higher value when the user logs in. If
239+
``password_pbkdf2_default_rounds`` is set to a lower value than was
240+
used to hash a password, the password will not be rehashed so the
241+
higher value will be kept. The lower value will be used only if the
242+
password is changed using the web or command line.
230243

231244
Increasing the number of rounds will slow down re-hashing. That's the
232245
whole point. Sadly it will also slow down logins. Usually the hash
@@ -240,17 +253,17 @@ You can see how long it will take by using the new ``roundup-admin``
240253
``perftest`` command. After you have finished migrating your database,
241254
run::
242255

243-
roundup-admin -i <tracker_home> perftest password rounds=10000
256+
roundup-admin -i <tracker_home> perftest password scheme=PBKDF2 rounds=10000
244257

245258
and then::
246259

247-
roundup-admin -i <tracker_home> perftest password rounds=2,000,000
260+
roundup-admin -i <tracker_home> perftest password scheme=PBKDF2 rounds=2,000,000
248261

249262
so see the difference. Output from this command looks like::
250263

251264
Hash time: 0.203151849s scheme: PBKDF2 rounds: 10000
252265

253-
If your testing reports a hash time in the 0.5 second range for 10000
266+
If your testing reports a hash time above 0.5 seconds for 10000
254267
rounds, there may be another issue. See if executing::
255268

256269
python3 -c 'from hashlib import pbkdf2_hmac'
@@ -267,6 +280,61 @@ install an OS vendor package or some other library.
267280

268281
.. _recommended setting of 1,300,000: https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html#pbkdf2
269282

283+
Upgrade to PBKDF2-SHA512 from current PBKDF2-SHA1 (recommended)
284+
---------------------------------------------------------------
285+
286+
We recommend that you upgrade to using PBKDF2-SHA512 for hashing your
287+
passwords. This is a more secure method than the old PBKDF2 (with
288+
SHA1). Because the algorithm is more secure, it uses a smaller value
289+
for ``password_pbkdf2_default_rounds``. Setting
290+
``password_pbkdf2_default_rounds`` to ``250000`` exceeds the current
291+
`recommended setting of 210,000`_ iterations for PBKDF2 when used with
292+
SHA512.
293+
294+
You can see how long this takes to calculate on your hardware using
295+
``roundup-admin``'s perftest command. For example::
296+
297+
roundup-admin -i <tracker_home> perftest password scheme=PBKDF2S5 rounds=250,000
298+
299+
produces::
300+
301+
Hash time: 0.161892945 seconds, scheme: PBKDF2S5, rounds: 250000
302+
303+
Any increase in the number of rounds will cause the password to
304+
automatically be rehashed to the higher value the next time the user
305+
logs in via the web interface. Changing the number of rounds to a
306+
**lower** value will not trigger a rehash during login unless the
307+
scheme is also being changed. The lower number will be used only when
308+
the password is explicitly changed using the web interface or the
309+
command line (``roundup-admin`` for example).
310+
311+
Change the default hashing scheme by adding the following lines to
312+
|the interfaces.py file|_ in your tracker home::
313+
314+
## Use PBDKF2S5 (PBKDF2-SHA512) for passwords. Re-hash old PBDFK2
315+
# Force password with scheme PBKDF2 (SHA1) to get re-hashed
316+
Password.deprecated_schemes.insert(0, Password.known_schemes[0])
317+
# choose PBKDF2S5 as the scheme to use for rehashing.
318+
Password.default_scheme = Password.experimental_schemes[0]
319+
320+
You may need to create the ``interfaces.py`` file if it doesn't exist.
321+
In the future, when the default hash is changed to PBKDF2S5, upgrade
322+
directions will include instructions to remove these lines and
323+
the file ``interfaces.py`` if it becomes empty.
324+
325+
You can verify that PBKDF2S5 is used by default by running::
326+
327+
roundup-admin -i <tracker_home> perftest password rounds=250,000
328+
329+
and verify that the scheme is PBKDF2S5.
330+
331+
.. _the interfaces.py file:
332+
reference.html#interfaces-py-hooking-into-the-core-of-roundup
333+
334+
.. |the interfaces.py file| replace:: the ``interfaces.py`` file
335+
336+
.. _recommended setting of 210,000: https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html#pbkdf2
337+
270338
jQuery updated with updates to user.help.html (recommended)
271339
-----------------------------------------------------------
272340

roundup/admin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1405,7 +1405,7 @@ def do_perftest(self, args):
14051405
from roundup.anypy.time_ import perf_counter
14061406

14071407
props = {"rounds": self.db.config.PASSWORD_PBKDF2_DEFAULT_ROUNDS,
1408-
"scheme": password.Password.known_schemes[0]}
1408+
"scheme": password.Password.default_scheme}
14091409

14101410
print_supported_schemes = lambda: print(
14111411
"Supported schemes (default is first, case "

0 commit comments

Comments
 (0)