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

Use better random string generator in 2fa lib #14321

Merged
merged 1 commit into from Apr 11, 2019
Merged

Conversation

tsteur
Copy link
Member

@tsteur tsteur commented Apr 7, 2019

No description provided.

@tsteur tsteur added the Needs Review PRs that need a code review label Apr 7, 2019
@tsteur tsteur added this to the 3.10.0 milestone Apr 7, 2019
@diosmosis
Copy link
Member

The docs for Common::getRandomString say Do not use for security related purposes (the string is not truly random)., maybe we should use random_bytes() if it's available?

@fdellwing
Copy link
Contributor

The best way imho is using random_bytes(), but this will only work for PHP7+.

So if this is not a problem, you should use this polyfill (https://github.com/paragonie/random_compat) and than use bin2hex(random_bytes($secretLength));.

If you do not want to implement another dependency, you can do your own PHP7+ check and otherwise use bin2hex(openssl_random_pseudo_bytes($secretLength));.

@tsteur
Copy link
Member Author

tsteur commented Apr 8, 2019

I doubt openssl_random_pseudo_bytes will be available everywhere. @diosmosis I think we can remove the content as in most cases it will use random_int and the comment was probably never removed after updating the getRandomInt method.

@diosmosis
Copy link
Member

@tsteur makes sense to me

@tsteur tsteur merged commit 31a5493 into 3.x-dev Apr 11, 2019
@tsteur tsteur deleted the randomint2falib branch April 11, 2019 02:55
@mattab mattab added the c: Security For issues that make Matomo more secure. Please report issues through HackerOne and not in Github. label Jun 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: Security For issues that make Matomo more secure. Please report issues through HackerOne and not in Github. Needs Review PRs that need a code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants