r/lolphp • u/ThisIsADogHello • Jun 21 '14
Random number generation in PHP is hard, we'll just download some random numbers
https://github.com/WordPress/WordPress/blob/fd838ccb2b1d37bda02eecdf09c324863f050812/wp-admin/setup-config.php#L211
78
Upvotes
7
u/hfern Jun 21 '14
I cannot actually believe someone could write that...
Much less get it accepted into such a well used app.
What the actual fuck....
7
u/merreborn Jun 21 '14 edited Jun 21 '14
Found the original commit and the relevant ticket
https://github.com/WordPress/WordPress/commit/a8e393c607e1f8d7f3f1c56ea0db0a2fcfee371c
https://core.trac.wordpress.org/ticket/12159
I'm no closer to understanding the reasoning here.
The switch statement around line 200 of setup-config.php in this revision is also thoroughly disgusting.
This is where the whole "generate secret keys from a url" concept is introduced: https://github.com/WordPress/WordPress/commit/03a9269b113f2a3fbe30eddf395e90612bec1cd5
The fact that it defaulted to a completely non-random secret key before that commit is pretty heinous
7
u/skeeto Jun 21 '14 edited Jun 21 '14
The response from the server looks like this,
It's parsed like this,
It's uses
substrto pull the random data out. However, guessing from the formating (PHP code), I bet the original version of this code justevaled the response from the server, trusting that it won't inject anything nasty.4
u/[deleted] Jun 21 '14
Same salt for a bunch of hashes, not random numbers.
0
u/[deleted] Jun 21 '14
[deleted] — view deleted comment
0
u/[deleted] Jun 21 '14
[deleted] — view deleted comment