Skip to content
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

Should rndstr() use SystemRandom instead of random? #206

Closed
bjmc opened this issue May 13, 2016 · 1 comment
Closed

Should rndstr() use SystemRandom instead of random? #206

bjmc opened this issue May 13, 2016 · 1 comment

Comments

@bjmc
Copy link
Contributor

bjmc commented May 13, 2016

The rndstr() function is used in various places to generate nonces, session ids, etc. Internally, it relies on the Python random module that uses a deterministic pseudorandom number generator.

The documentation for random includes a vague but stern warning:

Warning The pseudo-random generators of this module should not be used for security purposes. Use os.urandom() or SystemRandom if you require a cryptographically secure pseudo-random number generator.

Would it be better for rndstr() to use random = SystemRandom()? I'm not enough of an expert to say whether a CSPRNG is strictly necessary for all the places where rndstr is used, but maybe better safe than sorry?

@rohe
Copy link
Collaborator

rohe commented May 13, 2016

In most if not all places it's used a cryptographically secure pseudo-random number is necessary but I agree that it's better to be safe then sorry so I'll change it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants