Headline
CVE-2021-4301: Prevent $phpwcms['db_prepend'] from SQL injection · slackero/phpwcms@77dafb6
A vulnerability was found in slackero phpwcms up to 1.9.26 and classified as critical. Affected by this issue is some unknown functionality. The manipulation of the argument $phpwcms[‘db_prepend’] leads to sql injection. The attack may be launched remotely. Upgrading to version 1.9.27 is able to address this issue. The name of the patch is 77dafb6a8cc1015f0777daeb5792f43beef77a9d. It is recommended to upgrade the affected component. VDB-217418 is the identifier assigned to this vulnerability.
@@ -1,4 +1,17 @@ <?php /** * phpwcms content management system * * @author Oliver Georgi [email protected] * @copyright Copyright © 2002-2021, Oliver Georgi * @license http://opensource.org/licenses/GPL-2.0 GNU GPL-2 * @link http://www.phpwcms.org * **/
if (!defined(‘PHP8’)) { die(“You Cannot Access This Script Directly, Have a Nice Day.”); }
if(!empty($step)) {
@@ -85,7 +98,7 @@
mysqli_free_result($result);
if($result = mysqli_query($db, ‘SELECT * FROM ‘. ($phpwcms[“db_prepend”] ? $phpwcms[“db_prepend”].’_’ : ‘’).’phpwcms_user’)) { if($result = mysqli_query($db, 'SELECT * FROM ‘. ($phpwcms[“db_prepend”] ? mysqli_real_escape_string($db, $phpwcms[“db_prepend”]) . ‘_’ : ‘’) . ‘phpwcms_user’)) {
$_db_prepend_error = true; mysqli_free_result($result); @@ -128,7 +141,7 @@
// now read and display sql queries
$_db_prepend = ($phpwcms[“db_prepend”] ? $phpwcms[“db_prepend”].’_’ : ‘’); $_db_prepend = $phpwcms[“db_prepend”] ? mysqli_real_escape_string($db, $phpwcms[“db_prepend”]) . ‘_’ : '’;
$sql_data = read_textfile($DOCROOT . ‘/setup/default_sql/phpwcms_init.sql’); $sql_data = $sql_data . read_textfile($DOCROOT . ‘/setup/default_sql/phpwcms_inserts.sql’); @@ -219,8 +232,8 @@ } else { mysqli_query($db, “SET SQL_MODE=NO_AUTO_VALUE_ON_ZERO,NO_ENGINE_SUBSTITUTION”); mysqli_query($db, “SET NAMES '".mysqli_real_escape_string($db, $phpwcms[“charset”])."’”); $phpwcms[“db_prepend”] = ($phpwcms[“db_prepend”]) ? $phpwcms[“db_prepend”]."_" : ""; $sql = "INSERT INTO ".$phpwcms[“db_prepend”]."phpwcms_user (usr_login, usr_pass, usr_email, ". $_db_prepend = $phpwcms[“db_prepend”] ? mysqli_real_escape_string($db, $phpwcms[“db_prepend”]) . “_” : ""; $sql = "INSERT INTO " . $_db_prepend . "phpwcms_user (usr_login, usr_pass, usr_email, ". "usr_admin, usr_aktiv, usr_name, usr_fe, usr_wysiwyg ) VALUES ('". mysqli_real_escape_string($db, $phpwcms[“admin_user”])."’, '". mysqli_real_escape_string($db, md5($phpwcms[“admin_pass”]))."’, '".