[elbe-devel] [PATCH 1/2] preprocess: Only use 5000 sha512crypt round with warning
Bastian Germann
bage at linutronix.de
Fri Jan 27 10:50:26 CET 2023
The current passlib default is > 600.000 which makes embedded systems compute
for a long time. There were complaints about it, so compute a hash that is
only as expensive as Debian's old default.
As this is considered insecure, warn about it.
Signed-off-by: Bastian Germann <bage at linutronix.de>
---
elbepack/xmlpreprocess.py | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/elbepack/xmlpreprocess.py b/elbepack/xmlpreprocess.py
index 680e7a361a..efaba7969e 100644
--- a/elbepack/xmlpreprocess.py
+++ b/elbepack/xmlpreprocess.py
@@ -5,6 +5,7 @@
#
# SPDX-License-Identifier: GPL-3.0-or-later
+import logging
import os
import re
import sys
@@ -264,13 +265,19 @@ def preprocess_passwd(xml):
xml.find(".//action/login").text = passwd.text
passwd.tag = "passwd_hashed"
- passwd.text = f'{sha512_crypt.hash(passwd.text)}'
+ passwd.text = f'{sha512_crypt.hash(passwd.text, rounds=5000)}'
+ logging.warning("Please replace <passwd> with <passwd_hashed>. "
+ "The generated sha512crypt hash only applies 5000 rounds for "
+ "backwards compatibility reasons. This is considered insecure nowadays.")
# migrate user passwords
for adduser in xml.iterfind(".//target/finetuning/adduser[@passwd]"):
passwd = adduser.attrib['passwd']
- adduser.attrib['passwd_hashed'] = sha512_crypt.hash(passwd)
+ adduser.attrib['passwd_hashed'] = sha512_crypt.hash(passwd, rounds=5000)
del adduser.attrib['passwd']
+ logging.warning("Please replace adduser's passwd attribute with passwd_hashed. "
+ "The generated sha512crypt hash only applies 5000 rounds for "
+ "backwards compatibility reasons. This is considered insecure nowadays.")
def xmlpreprocess(fname, output, variants=None, proxy=None):
--
2.30.2
More information about the elbe-devel
mailing list