Today, a way was presented how to reset an admin’s password of a WordPress installation, by just calling http://domain.dom/wp-login.php?action=rp&key[]=
So please, as long as there is no official release fixing this problem, apply this changeset to your wp-login.php.
Simply change line 190 in wp-login.php to
if ( empty( $key ) || is_array( $key ) )
Then the “arraytrick” does not work anymore. The trick was, that after bypassing if (empty($key)), the database is queried for all users having a blank user_activation_key field. This is true for all users by default (except for those, who have recently ordered an activation key for password reset). Hence, the database simply returns the first user, whose user_activation_key is empty. His password then is reset. This user is likely the admin, because he is the first user in the table.
Update:
The changeset named above is not the only change the WordPress developers made. As we can see from changeset 11800 and changeset 11801, the password reset is only done when the key is actually a string and the user calling the “reset password URL” is logged in. Both modifications are already branched, so you can take this wp-login.php or wait for the next official release.
Update2:
The official update to WordPress 2.8.4 is released! Update now!
Can you give a little more context as to where in the code this should be placed in case we have variations on wp-login.php?
Dave,
of course:
just look for the following lines:
Then replace the conditional statement with the one I mentioned in the blog post:
Thanks very much. Patched!
Now that I look at the code.. is this necessary?
It seems that while it bypasses the first condition, it won’t return a user and then throw an WP_Error, no?
John, this is not totally clear to me, too, because I never looked into WordPress deeply. But it seems that exactly this point is the clue; instead of not returning a user, the admin user seems to be returned in case of
key=[]. Weird. To know for sure, one has to know the database structure. If you have a better explanation, then let us know!Btw: You can use the
<pre lang="php">tag to get beautiful code! I will quickly edit your comment, hopyfully that’s okay for youJohn, the explanation is pretty simple. I found this in the wp-hackers mainlinglist:
Hence, the problem is that all users have a blank
user_activation_keyby default. Querying for such users returns the first one, which is likely the adminUpdating WordPress to 2.8.4 (available now via the usual upgrade processes) will fix this problem.
Thanks Joe. It only lasted about 24 hours until they released it