Opened 14 hours ago
Closed 10 hours ago
#66426 closed enhancement (fixed)
Use wp_rand() for the network admin email change hash
| Reported by: | ExtremsX | Owned by: | johnjamesjacoby |
|---|---|---|---|
| Priority: | normal | Milestone: | 7.2 |
| Component: | Security | Version: | trunk |
| Severity: | normal | Keywords: | has-patch |
| Cc: | Focuses: | multisite |
Description
update_network_option_new_admin_email() in wp-includes/ms-functions.php builds
the email-change confirmation hash with mt_rand():
$hash = md5( $value . time() . mt_rand() );
This is the multisite equivalent of update_option_new_admin_email(). In #43771
([43367]) the single-site admin email hash and the user profile email change
hash were hardened to use wp_rand() instead of mt_rand(). The network version
was missed and still uses mt_rand(). The sibling multisite hashes in the same
file (ms-functions.php:805 and :874) already use wp_rand().
Patch: use wp_rand() for the network admin email hash as well.
See #43771.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Problem
update_network_option_new_admin_email()(wp-includes/ms-functions.php) buildsthe email-change confirmation hash with
mt_rand():$hash = md5( $value . time() . mt_rand() );This is the multisite/network equivalent of the single-site
update_option_new_admin_email(). In #43771 ([43367]) the single-site adminemail hash and the user profile email change hash were both hardened to use
wp_rand()instead ofmt_rand(). The network version was not part of thatchange and still uses
mt_rand(). The sibling multisite hashes in the same file(ms-functions.php:805 and :874) already use
wp_rand().As johnbillion noted in comment:5 of #43771,
md5()here is only a URL-safeformat and not cryptographic; the unpredictability comes from the random value,
so
wp_rand()is the correct source.Fix
Use
wp_rand()for the network admin email confirmation hash, bringing it inline with its single-site counterpart:
$hash = md5( $value . time() . wp_rand() );One-line change, no behavior change. This is hardening, not an exploitable
issue (same classification as #43771), so it is filed on Trac rather than
HackerOne.
Tests
No dedicated test, matching [43367]: the change only swaps the randomness
source and produces no observable difference in behavior (
update_site_optionis still called with a random md5-formatted hash).
php -lis clean.See #43771.
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code, with code-intruder (my own static analysis tool)
Model(s): Claude Opus, Claude Haiku
Used for: code-intruder flagged the weak-token pattern (mt_rand reaching a
credential-style hash) and an AI review compared it against the sibling paths
already hardened in [43367], confirming the network version was the one left
using mt_rand. I reviewed and tested the change myself.