This is based on Demonoid's email change recovery. I tried to create a similar method they use for the secret key which is 64 characters long.
Right now there is a SQL injection into account-ce.php which has the following build:
So the url [ICODE]/account-ce.php?id=1&secret=1bd58e7017f3661a5b32bb66b352fea7&email=new_admin_mail@mail.com[/ICODE] will change the admin email and give access to the attacker to the admin mail which they can reset via password reset.
secret is generated by[ICODE] md5($email)[/ICODE] which can easily be decrypted.
--------------------------------
My fix is instead of generating email hash via md5, to generate a really strong cryptographically secure key.
1. Go to database, users -> change column 'edit_secret' and set varchar to 64.
2. Find the following in the account.php -
Replace with: -
3. Open account-ce.php
Find [ICODE]if ($md5 != md5($sec . $email . $sec)) [/ICODE]
Replace with [ICODE]if ($md5 != $sec)[/ICODE]
Right now there is a SQL injection into account-ce.php which has the following build:
$id = (int) $_GET["id"];
$md5 = $_GET["secret"];
$email = $_GET["email"];So the url [ICODE]/account-ce.php?id=1&secret=1bd58e7017f3661a5b32bb66b352fea7&email=new_admin_mail@mail.com[/ICODE] will change the admin email and give access to the attacker to the admin mail which they can reset via password reset.
secret is generated by[ICODE] md5($email)[/ICODE] which can easily be decrypted.
--------------------------------
My fix is instead of generating email hash via md5, to generate a really strong cryptographically secure key.
1. Go to database, users -> change column 'edit_secret' and set varchar to 64.
2. Find the following in the account.php -
if ($changedemail) {
$sec = mksecret();
$hash = md5($sec . $email . $sec);
$obemail = rawurlencode($email);
$updateset[] = "editsecret = " . sqlesc($sec);
$thishost = $_SERVER["HTTP_HOST"];
$thisdomain = preg_replace('/^www\./is', "", $thishost);
$body = <<<EOD
You have requested that your user profile (username {$CURUSER["username"]})
on {$site_config["SITEURL"]} should be updated with this email address ($email) as
user contact.
If you did not do this, please ignore this email. The person who entered your
email address had the IP address {$_SERVER["REMOTE_ADDR"]}. Please do not reply.
To complete the update of your user profile, please follow this link:
{$site_config["SITEURL"]}/account-ce.php?id={$CURUSER["id"]}&secret=$hash&email=$obemail
Your new email address will appear in your profile after you do this. Otherwise
your profile will remain unchanged.
EOD;
sendmail($email, "$site_config[SITENAME] profile update confirmation", $body, "From: $site_config[SITEEMAIL]", "-f$site_config[SITEEMAIL]");
$mailsent = 1;
} //changedemailReplace with: -
// Here we generate a cryptographically secure key via random_bytes
function crypt_secret(int $length = 64){ // 64 = 32
$length = ($length < 4) ? 4 : $length;
return bin2hex(random_bytes(($length-($length%2))/2));
}
// Here we get the new hash method
if ($changedemail) {
$hash = crypt_secret();
$obemail = rawurlencode($email);
$updateset[] = "editsecret = " . sqlesc($hash);
$thishost = $_SERVER["HTTP_HOST"];
$thisdomain = preg_replace('/^www\./is', "", $thishost);
$body = <<<EOD
You have requested that your user profile (username {$CURUSER["username"]})
on {$site_config["SITEURL"]} should be updated with this email address ($email) as
user contact.
If you did not do this, please ignore this email. The person who entered your
email address had the IP address {$_SERVER["REMOTE_ADDR"]}. Please do not reply.
To complete the update of your user profile, please follow this link:
{$site_config["SITEURL"]}/account-ce.php?id={$CURUSER["id"]}&secret=$hash&email=$obemail
Your new email address will appear in your profile after you do this. Otherwise
your profile will remain unchanged.
EOD;
sendmail($email, "$site_config[SITENAME] profile update confirmation", $body, "From: $site_config[SITEEMAIL]", "-f$site_config[SITEEMAIL]");
$mailsent = 1;
} //changedemail3. Open account-ce.php
Find [ICODE]if ($md5 != md5($sec . $email . $sec)) [/ICODE]
Replace with [ICODE]if ($md5 != $sec)[/ICODE]
