Bug 50728 - Insecure password generation
Insecure password generation
Status: NEW
Product: UCS
Classification: Unclassified
Component: General
UCS 4.4
Other Linux
: P5 normal (vote)
: ---
Assigned To: UCS maintainers
UCS maintainers
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2020-01-20 21:48 CET by Philipp Hahn
Modified: 2020-03-24 09:02 CET (History)
1 user (show)

See Also:
What kind of report is it?: Security Issue
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional): Security
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Philipp Hahn univentionstaff 2020-01-20 21:48:55 CET
There are several location with dubios code for password generation:

management/univention-self-service/umc/python/passwordreset/__init__.py Instance.create_token()
  population = ''.join(set(string.ascii_letters) | set(string.digits) - {"0", "O", "1", "I", "l"})

With Python 3.6 (Stretch only has 3.5, Buster has 3.7) <https://docs.python.org/3/library/random.html#random.choices> should be used.

management/univention-self-service/umc/python/passwordreset/__init__.py Instance.create_token()

services/univention-squid/squid_ldap_ntlm_auth createNtlmTypeTwo()
Comment 1 Florian Best univentionstaff 2020-03-24 09:02:38 CET
Can you explain?

The code is actually the following and uses random.SystemRandom() which is not a PRNG and safe for cryptographic use:

»   @staticmethod
»   def create_token(length):
»   »   # remove easily confusable characters
»   »   chars = string.ascii_letters.replace("l", "").replace("I", "").replace("O", "") + "".join(map(str, range(2, 10)))
»   »   rand = random.SystemRandom()
»   »   res = ""
»   »   for _ in range(length):
»   »   »   res += rand.choice(chars)
»   »   return res



While the other example, is broken:
486 def createNtlmTypeTwo():
487 
488 »   challenge = "".join(random.sample(string.printable + "0123456789", 8))