Skip to content

Commit

Permalink
Escape user and hostname when getting auth plugin
Browse files Browse the repository at this point in the history
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
  • Loading branch information
MauricioFauth committed Mar 5, 2020
1 parent 09c89ba commit 89fbcd7
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions libraries/classes/Server/Privileges.php
Original file line number Diff line number Diff line change
Expand Up @@ -1812,8 +1812,11 @@ public static function getCurrentAuthenticationPlugin(
&& $mode == 'change'
) {
$row = $GLOBALS['dbi']->fetchSingleRow(
'SELECT `plugin` FROM `mysql`.`user` WHERE '
. '`User` = "' . $username . '" AND `Host` = "' . $hostname . '" LIMIT 1'
'SELECT `plugin` FROM `mysql`.`user` WHERE `User` = "'
. $GLOBALS['dbi']->escapeString($username)
. '" AND `Host` = "'
. $GLOBALS['dbi']->escapeString($hostname)
. '" LIMIT 1'
);
// Table 'mysql'.'user' may not exist for some previous
// versions of MySQL - in that case consider fallback value
Expand All @@ -1824,8 +1827,11 @@ public static function getCurrentAuthenticationPlugin(
list($username, $hostname) = $GLOBALS['dbi']->getCurrentUserAndHost();

$row = $GLOBALS['dbi']->fetchSingleRow(
'SELECT `plugin` FROM `mysql`.`user` WHERE '
. '`User` = "' . $username . '" AND `Host` = "' . $hostname . '"'
'SELECT `plugin` FROM `mysql`.`user` WHERE `User` = "'
. $GLOBALS['dbi']->escapeString($username)
. '" AND `Host` = "'
. $GLOBALS['dbi']->escapeString($hostname)
. '"'
);
if (isset($row) && $row && ! empty($row['plugin'])) {
$authentication_plugin = $row['plugin'];
Expand Down

0 comments on commit 89fbcd7

Please sign in to comment.