Ticket #6566 (closed defect (bug): wontfix)

Opened 4 years ago

Last modified 23 months ago

custom-built roles can create administrator users

Reported by: Denis-de-Bernardy Owned by: anonymous
Priority: normal Milestone:
Component: Security Version: 2.5
Severity: minor Keywords: capabilities close
Cc:

Description

If you create a custom role using the role manager, and let that role edit options for any reasons (e.g. you want to set up some kind of demo site), then users with that role can open registrations, and assign administrator as the default role, then let themselves in as administrator.

Fix:

	function default_role($o)
	{
		if ( $o == 'administrator' && get_option('users_can_register') )
		{
			global $wp_roles;
			
			foreach ( $wp_roles->role_names as $role => $name )
			{
				if ( $role != 'administrator' )
				{
					$o = $role;
					add_action('shutdown', create_function('', "update_option('default_role', '$role');"));
					break;
				}
			}
		}
		
		return $o;
	} # default_role()

add_filter('option_default_role', 'default_role');

Change History

  • Keywords capabilities added
  • Status changed from new to closed
  • Resolution set to invalid
  • Milestone 2.5.2 deleted

This is by design. The edit_options capability is intended to allow a user to edit options ;-) . See also #6014.

I've discussed these sorts of issues with the author of the role manager plugin and the conclusion seems to be that if you're not sure what each capability actually allows, you shouldn't be messing with them :-)

It may be a documentation issue but I'm reluctant to accept it as a bug so I'm going to close for now.

  • Milestone set to 3.0

true, but this prevents anyone from creating a proper demo site.

  • Status changed from closed to reopened
  • Resolution invalid deleted

comment:4   dd322 years ago

  • Keywords close added

This is IMO, a wontfix.

If you wish to have a demo site, with people being able to edit options, Then you need to lock certain options down. Its nothing new, You have a user that can change security-related then they must be trusted.

Add a filter to the sanitization hook for that function, and always return the old setting. Job done.

  • Status changed from reopened to closed
  • Resolution set to wontfix
  • Milestone 3.0 deleted
Note: See TracTickets for help on using tickets.