Posted by Damien Tournoud on June 27, 2010 at 3:39pm
13 followers
| Project: | Drupal core |
| Version: | 7.x-dev |
| Component: | base system |
| Category: | task |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
| Issue tags: | needs backport to D7, needs security review, Novice |
Issue Summary
I asked Pierre Joye, from the PHP team, to review our random number generation function (drupal_random_bytes()).
He suggested to use openssl_random_pseudo_bytes() if available (that's available since PHP 5.3), as it seems to be the only reliable source of random numbers of Windows for now.
Comments
#1
Something like that should do it.
#2
Can't see a reason not to include openssl_random_pseudo_bytes() for a better system agnostic solution
#3
This looks RTBC to me.
It could be good to extend the code comment so it mentions that it is the only reliable source of random numbers on Microsoft Windows.
#4
Note that the patch needs a reroll for
core/. If we're doingfunction_exists(), we can also backport this.#5
anyone do a real test, I read this from PHP.net
and seems fixed on latest PHP version..
http://stackoverflow.com/questions/1940168/openssl-random-pseudo-bytes-i...
#6
Since we only require 5.3.2, we might want to do a version check here. Moving back to needs review.
#7
Tagging as novice for
elseif (function_exists('openssl_random_pseudo_bytes')). It should be at least5.3.25.3.4.#8
Here's a patch that does what's been requested in #7.
But, shouldn't it check for PHP 5.3.4 since that version fixed openssl_random_pseudo_bytes locking on Windows?
#9
#8: You're correct, 5.3.4, not 5.3.2. Thanks!
#10
Ok, here's the re-roll.
#11
Patch is doing what was agreed on comment 7 and 9.
#12
Manually tested ??
Maybe bump up PHP version again? PHP 5.3.8 and below has hash collision vulnerability. I think all hosting will bump up their PHP version.
#13
The hash collision is unrelated to this patch.
#14
@#13,
yes, unrelated :)
#15
Yes, from a PHP 5.3.9
Since I do not have a non *nix platform to test the exact case, I have just commented the /dev/urandom if and only left the elseif as if; and it works fine.
#16
Committed to 8.x. We may be able to remove the version check before we release 8.x. We'll see.
#17
Re-rolled patch for Drupal 7.x.
#18
#17 Works!
Drupal v7.12
PHP v5.3.5
Ubuntu v11.10
#19
Yay for more randomness. :)
Committed and pushed to 7.x. Thanks!
#20
Automatically closed -- issue fixed for 2 weeks with no activity.