[wp-trac] [WordPress Trac] #58860: Potential security issue in is_super_admin

WordPress Trac noreply at wordpress.org
Thu Jul 20 09:44:15 UTC 2023


#58860: Potential security issue in is_super_admin
--------------------------+-----------------------------
 Reporter:  Stachethemes  |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Security      |    Version:  6.2.2
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 function is_super_admin( $user_id = false ) {

         if ( ! $user_id ) {
                 $user = wp_get_current_user();
         } else {
                 $user = get_userdata( $user_id );
         }

         ...

 }

 If user is logged in as super admin and do

 is_super_admin(0);

 it will return true;

 It would be best to use strict comparison:

 function is_super_admin( $user_id = false ) {

         if ( false === $user_id ) {
                 $user = wp_get_current_user();
         } else {
                 $user = get_userdata( $user_id );
         }

         ...

 }

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/58860>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list