Fix multiple privilege escalation vulnerabilities (thanks to X Chen for advice)

This commit is contained in:
Fedor A. Fetisov 2013-12-22 04:08:47 +04:00
parent f9fd80423f
commit 01dba643ba
19 changed files with 44 additions and 6 deletions

View File

@ -24,8 +24,6 @@ $can_modifyprofile = 3;
$can_count = 4; $can_count = 4;
$can_viewnotifications = 5; $can_viewnotifications = 5;
$permission_ids = array( $permission_ids = array(
$can_administrate => "admin", $can_administrate => "admin",
$can_takeover => "takeover", $can_takeover => "takeover",
@ -239,6 +237,21 @@ function check_login($redirect = true)
return $_SESSION["${mysqlprefix}operator"]; return $_SESSION["${mysqlprefix}operator"];
} }
function check_permissions()
{
$check = false;
if (func_num_args() > 1) {
$args = func_get_args();
$operator = array_shift($args);
foreach ($args as $permission) {
$check = $check || is_capable($permission, $operator);
}
}
if (!$check) {
die("Permission denied.");
}
}
function get_logged_in() function get_logged_in()
{ {
global $mysqlprefix; global $mysqlprefix;

View File

@ -26,6 +26,10 @@ $opId = verifyparam("op", "/^\d{1,10}$/");
$page = array('opid' => $opId, 'avatar' => ''); $page = array('opid' => $opId, 'avatar' => '');
$errors = array(); $errors = array();
if ($opId && ($opId != $operator['operatorid'])) {
check_permissions($operator, $can_administrate);
}
$canmodify = ($opId == $operator['operatorid'] && is_capable($can_modifyprofile, $operator)) $canmodify = ($opId == $operator['operatorid'] && is_capable($can_modifyprofile, $operator))
|| is_capable($can_administrate, $operator); || is_capable($can_administrate, $operator);

View File

@ -21,6 +21,7 @@ require_once('../libs/settings.php');
$operator = check_login(); $operator = check_login();
csrfchecktoken(); csrfchecktoken();
check_permissions($operator, $can_administrate);
$page = array('agentId' => ''); $page = array('agentId' => '');
$errors = array(); $errors = array();

View File

@ -21,6 +21,7 @@ require_once('../libs/groups.php');
require_once('../libs/getcode.php'); require_once('../libs/getcode.php');
$operator = check_login(); $operator = check_login();
check_permissions($operator, $can_administrate);
loadsettings(); loadsettings();
$imageLocales = get_image_locales_map("../locales"); $imageLocales = get_image_locales_map("../locales");

View File

@ -21,6 +21,7 @@ require_once('../libs/groups.php');
require_once('../libs/getcode.php'); require_once('../libs/getcode.php');
$operator = check_login(); $operator = check_login();
check_permissions($operator, $can_administrate);
loadsettings(); loadsettings();
$stylelist = get_style_list("../styles"); $stylelist = get_style_list("../styles");

View File

@ -21,6 +21,7 @@ require_once('../libs/groups.php');
$operator = check_login(); $operator = check_login();
csrfchecktoken(); csrfchecktoken();
check_permissions($operator, $can_administrate);
$page = array('grid' => ''); $page = array('grid' => '');
$errors = array(); $errors = array();

View File

@ -21,6 +21,7 @@ require_once('../libs/groups.php');
$operator = check_login(); $operator = check_login();
csrfchecktoken(); csrfchecktoken();
check_permissions($operator, $can_administrate);
function get_group_members($groupid) function get_group_members($groupid)
{ {

View File

@ -20,6 +20,7 @@ require_once('../libs/operator.php');
$operator = check_login(); $operator = check_login();
csrfchecktoken(); csrfchecktoken();
check_permissions($operator, $can_administrate);
if (isset($_GET['act']) && $_GET['act'] == 'del') { if (isset($_GET['act']) && $_GET['act'] == 'del') {

View File

@ -20,6 +20,7 @@ require_once('../libs/operator.php');
require_once('../libs/chat.php'); require_once('../libs/chat.php');
$operator = check_login(); $operator = check_login();
check_permissions($operator, $can_administrate, $can_viewnotifications);
$page = array(); $page = array();

View File

@ -21,14 +21,11 @@ require_once('../libs/operator.php');
require_once('../libs/pagination.php'); require_once('../libs/pagination.php');
$operator = check_login(); $operator = check_login();
check_permissions($operator, $can_administrate, $can_viewnotifications);
$page = array(); $page = array();
$errors = array(); $errors = array();
if (!is_capable($can_administrate, $operator) && !is_capable($can_viewnotifications, $operator)) {
die("Permission denied.");
}
setlocale(LC_TIME, getstring("time.locale")); setlocale(LC_TIME, getstring("time.locale"));
# locales # locales

View File

@ -131,6 +131,9 @@ if (isset($_POST['login']) && isset($_POST['password'])) {
if (!$opId && !is_capable($can_administrate, $operator)) { if (!$opId && !is_capable($can_administrate, $operator)) {
$errors[] = "You are not allowed to create operators"; $errors[] = "You are not allowed to create operators";
} }
elseif ($opId && ($opId != $operator['operatorid'])) {
check_permissions($operator, $can_administrate);
}
$canmodify = ($opId == $operator['operatorid'] && is_capable($can_modifyprofile, $operator)) $canmodify = ($opId == $operator['operatorid'] && is_capable($can_modifyprofile, $operator))
|| is_capable($can_administrate, $operator); || is_capable($can_administrate, $operator);

View File

@ -20,6 +20,7 @@ require_once('../libs/operator.php');
$operator = check_login(); $operator = check_login();
csrfchecktoken(); csrfchecktoken();
check_permissions($operator, $can_administrate);
if (isset($_GET['act']) && $_GET['act'] == 'del') { if (isset($_GET['act']) && $_GET['act'] == 'del') {
$operatorid = isset($_GET['id']) ? $_GET['id'] : ""; $operatorid = isset($_GET['id']) ? $_GET['id'] : "";

View File

@ -41,6 +41,10 @@ $page['groups'] = get_all_groups($link);
mysql_close($link); mysql_close($link);
$errors = array(); $errors = array();
if ($opId && ($opId != $operator['operatorid'])) {
check_permissions($operator, $can_administrate);
}
$canmodify = ($opId == $operator['operatorid'] && is_capable($can_modifyprofile, $operator)) $canmodify = ($opId == $operator['operatorid'] && is_capable($can_modifyprofile, $operator))
|| is_capable($can_administrate, $operator); || is_capable($can_administrate, $operator);

View File

@ -21,6 +21,7 @@ require_once('../libs/settings.php');
$operator = check_login(); $operator = check_login();
csrfchecktoken(); csrfchecktoken();
check_permissions($operator, $can_administrate);
$page = array('agentId' => ''); $page = array('agentId' => '');
$errors = array(); $errors = array();

View File

@ -35,6 +35,10 @@ $opId = verifyparam("op", "/^\d{1,10}$/");
$page = array('opid' => $opId, 'canmodify' => is_capable($can_administrate, $operator) ? "1" : ""); $page = array('opid' => $opId, 'canmodify' => is_capable($can_administrate, $operator) ? "1" : "");
$errors = array(); $errors = array();
if ($opId && ($opId != $operator['operatorid'])) {
check_permissions($operator, $can_administrate);
}
$op = operator_by_id($opId); $op = operator_by_id($opId);
if (!$op) { if (!$op) {

View File

@ -21,6 +21,7 @@ require_once('../libs/settings.php');
$operator = check_login(); $operator = check_login();
csrfchecktoken(); csrfchecktoken();
check_permissions($operator, $can_administrate);
$page = array('agentId' => ''); $page = array('agentId' => '');
$errors = array(); $errors = array();

View File

@ -24,6 +24,7 @@ require_once('../libs/expand.php');
require_once('../libs/settings.php'); require_once('../libs/settings.php');
$operator = check_login(); $operator = check_login();
check_permissions($operator, $can_administrate);
$stylelist = array(); $stylelist = array();
$stylesfolder = "../styles"; $stylesfolder = "../styles";

View File

@ -119,6 +119,7 @@ function get_auxiliary($s)
$operator = check_login(); $operator = check_login();
csrfchecktoken(); csrfchecktoken();
check_permissions($operator, $can_administrate);
$source = verifyparam("source", "/^[\w-]{2,5}$/", $default_locale); $source = verifyparam("source", "/^[\w-]{2,5}$/", $default_locale);
$target = verifyparam("target", "/^[\w-]{2,5}$/", $current_locale); $target = verifyparam("target", "/^[\w-]{2,5}$/", $current_locale);

View File

@ -20,6 +20,7 @@ require_once('../libs/operator.php');
require_once('../libs/settings.php'); require_once('../libs/settings.php');
$operator = check_login(); $operator = check_login();
check_permissions($operator, $can_administrate);
$default_extensions = array('mysql', 'gd', 'iconv'); $default_extensions = array('mysql', 'gd', 'iconv');