View Single Post
  #1 (permalink)  
Old 03-03-2007, 07:04 PM
kevin1 kevin1 is offline
New Pligger
 
Join Date: Feb 2007
Posts: 8
Thanks: 0
Thanked 10 Times in 2 Posts
[Fixed] Admin security bug

Right now admins can edit gods and other admins which shouldn't be the case. An admin can reset god's password and login as god.

So I made some changes to admin_users.php and user_show_center.tpl. Basically I made a function in the php:

Code:
function canIChangeUser($user_level) {
    global $amIgod, $main_smarty;
    
    //Don't want to let admins reset other admins or god
    $viewer = $main_smarty->get_template_vars('user_logged_in');
    $target = $_GET["user"];
    
    if ($viewer != $target && !$amIgod && (($user_level == 'god') || ($user_level == 'admin'))) {
        echo "Access denied";
        die;
    } 
}
And I stuck this function in the different "Mode" sections.

Also modified user_show_center.tpl to not show the edit panel if the user is an admin or a god (unless it's the viewer himself):

Code:
         {* Only show edit panel if: 
           - user is god
           - user is viewing him/herself
           - viewed person is not an admin or god
         *} 
	{if $amIgod || $user_logged_in eq $userdata[nr].user_login || ($userdata[nr].user_level neq 'admin' && $userdata[nr].user_level neq 'god')}
		    <div id="admin_view_user_edit">
   etc...
admin_user.php also includes the header redirective to go back to user list instead of the tpl with the "go back to user" button. The button just goes back in window history, and if you edited the user's name, things get messed up.

Lemme know what u think.
Attached Files
File Type: php admin_users.php (18.6 KB, 37 views)
File Type: tpl user_show_center.tpl (2.1 KB, 50 views)
Reply With Quote
The Following 8 Users Say Thank You to kevin1 For This Useful Post: