-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
get random in UUID more cryptography secure #135226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uuid1() already has security warnings, and the rest that were changed here are documented as pseudo-random. I don't think we need to change anything here, apart from maybe adding some extra documentation notes.
|
You're right. But I think changing them to a more secure way has no disadvantage. Why not make it more unpredictable with no side effects? |
|
Well, there are clearly side-effects. The UUID tests are totally broken by this change. |
|
Well it seems like its broken because the test script uses for example: this will triger a assertion error because I'll take a closer look soon |
|
|
Maybe I could add a parameter to uuid1() and uuid6() which is False by default, and if its true, using secret.randbits() instead of random.getrandbits() ? |
random.getrandbits() is used widely in lib
uuidespectially in generating clock_seqs in UUID v1 and v6if 624*32//14+1 UUIDs are leaked to hackers, they could predict the next UUID generated.
reference: https://github.com/LamentXU123/cve/blob/main/UUID.md
to make it more cryptography secure,
secrets.randbits()should be used instead ofrandom.getrandbits()