Strip null bytes from MySQL username
In old PHP versions this could lead to allow/deny rules bypass. Signed-off-by: Michal Čihař <michal@cihar.com>
This commit is contained in:
parent
5ba96c8804
commit
285e5623b6
@ -899,6 +899,24 @@ function PMA_sanitizeMySQLHost($name)
|
||||
return $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitizes MySQL username
|
||||
*
|
||||
* * strips part behind null byte
|
||||
*
|
||||
* @param string $name User given username
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function PMA_sanitizeMySQLUser($name)
|
||||
{
|
||||
$position = strpos($name, chr(0));
|
||||
if ($position !== false) {
|
||||
return substr($name, 0, $position);
|
||||
}
|
||||
return $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Safe unserializer wrapper
|
||||
*
|
||||
|
||||
@ -333,7 +333,7 @@ class AuthenticationCookie extends AuthenticationPlugin
|
||||
|
||||
if (! empty($_REQUEST['pma_username'])) {
|
||||
// The user just logged in
|
||||
$GLOBALS['PHP_AUTH_USER'] = $_REQUEST['pma_username'];
|
||||
$GLOBALS['PHP_AUTH_USER'] = PMA_sanitizeMySQLUser($_REQUEST['pma_username']);
|
||||
$GLOBALS['PHP_AUTH_PW'] = empty($_REQUEST['pma_password'])
|
||||
? ''
|
||||
: $_REQUEST['pma_password'];
|
||||
|
||||
@ -158,6 +158,9 @@ class AuthenticationHttp extends AuthenticationPlugin
|
||||
unset($usr_pass);
|
||||
}
|
||||
|
||||
// sanitize username
|
||||
$PHP_AUTH_USER = PMA_sanitizeMySQLUser($PHP_AUTH_USER);
|
||||
|
||||
// User logged out -> ensure the new username is not the same
|
||||
$old_usr = isset($_REQUEST['old_usr']) ? $_REQUEST['old_usr'] : '';
|
||||
if (! empty($old_usr)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user