Plugin Directory

Changeset 3151072


Ignore:
Timestamp:
09/12/2024 08:27:56 PM (17 months ago)
Author:
imw3
Message:
  • Fixed broken access control vulnerability.
  • Compatible with WordPress 6.6.2
Location:
my-wp-brand
Files:
9 added
4 edited

Legend:

Unmodified
Added
Removed
  • my-wp-brand/trunk/assets/js/style-my-wp-brand.js

    r2720748 r3151072  
    2323     * Set login logo
    2424     *
    25      *
    2625     * @version 1.0.0
    2726     */
     
    4443    /**
    4544     * @ajax mwb-plugin-form
     45     *
     46     * @version 1.0.0
     47     * @version 1.1.3 Implemented a nonce value in the data object to enhance security.
    4648     */
    4749    $("#mwb-plugins-form").submit((e) => {
     
    6264                action: 'mwb_plugins_form',
    6365                plugins: plugins_data,
     66                nonce: mwb_ajax.nonce,
    6467            },
    6568            success: (response) => {
     
    7275    /**
    7376     * @ajax mwb-style-form
     77     *
     78     * @version 1.0.0
     79     * @version 1.1.3 Implemented a nonce value in the data object to enhance security.
    7480     */
    7581    $("#mwb-style-form").submit((e) => {
     
    8288            data: {
    8389                action: 'mwb_style_ajax',
     90                nonce: mwb_ajax.nonce,
    8491                hidden_admin_bar_logo: $("#show-admin-bar-logo").attr("src") ? $("#show-admin-bar-logo").attr("src") : '',
    8592                hidden_login_logo: $("#show-login-logo").attr("src") ? $("#show-login-logo").attr("src") : '',
     
    94101    /**
    95102     * @ajax mwb-author-form
     103     *
     104     * @version 1.0.0
     105     * @version 1.1.3 Implemented a nonce value in the data object to enhance security.
    96106     */
    97107    $("#mwb-author-form").submit((e) => {
     
    104114            data: {
    105115                action: 'mwb_author_form',
     116                nonce: mwb_ajax.nonce,
    106117                wp_version_hide: document.getElementById("wp-version-hide").checked === true ? 'on' : 'off',
    107118                wp_admin_footer_text: $("#wp-admin-footer-text").val() ? $("#wp-admin-footer-text").val() : '',
  • my-wp-brand/trunk/mwb-side-menu.php

    r2720748 r3151072  
    3030         * @var { $sub_menu_list } Admin all sub menu list.
    3131         */
    32         $menu_list = isset( $_POST['menu_list'] ) ? sanitize_text_field( json_encode( $_POST['menu_list'] ) ) : array();
    33         $sub_menu_list = isset( $_POST['sub_menu_list'] ) ? sanitize_text_field( json_encode( $_POST['sub_menu_list'] ) ) : array();
     32        $menu_list = isset( $_POST['menu_list'] ) ? sanitize_text_field( wp_json_encode( $_POST['menu_list'] ) ) : array();
     33        $sub_menu_list = isset( $_POST['sub_menu_list'] ) ? sanitize_text_field( wp_json_encode( $_POST['sub_menu_list'] ) ) : array();
    3434
    3535        /**
     
    108108        $remove_side_array          = $new_menu_list;
    109109        $remove_sub_side_array      = $new_sub_menu_list;
    110         $json_remove_side_array     = json_encode( $remove_side_array );
    111         $json_remove_sub_side_array = json_encode( $remove_sub_side_array );
     110        $json_remove_side_array     = wp_json_encode( $remove_side_array );
     111        $json_remove_sub_side_array = wp_json_encode( $remove_sub_side_array );
    112112       
    113113        /**
    114114         * @var { $top_menu_list } Admin all top menu list.
    115115         */
    116         $top_menu_list = isset( $_POST['top_menu_list'] ) ? sanitize_text_field( json_encode( $_POST['top_menu_list'] ) ) : array();
     116        $top_menu_list = isset( $_POST['top_menu_list'] ) ? sanitize_text_field( wp_json_encode( $_POST['top_menu_list'] ) ) : array();
    117117       
    118118        /**
     
    148148
    149149        $remove_top_array      = $new_menu_list;
    150         $json_remove_top_array = json_encode( $remove_top_array );
     150        $json_remove_top_array = wp_json_encode( $remove_top_array );
    151151       
    152152        /**
     
    192192
    193193      if( $_GET['message'] == 'save' ) {
    194         echo $msg =  '<div id="message" class="updated notice notice-success is-dismissible"><p>'. esc_html( 'Your changes has been updated.' ) .'</p></div>';
     194        echo $msg =  '<div id="message" class="updated notice notice-success is-dismissible"><p>'. esc_html__( 'Your changes has been updated.', MWB_TEXTDOMAIN ) .'</p></div>';
    195195      }
    196196
    197197      if( $_GET['message'] == 'default' ) {
    198         echo $msg =  '<div id="message" class="updated notice notice-success is-dismissible"><p>'. esc_html( 'Your default setting has been setup.' ) .'</p></div>';
     198        echo $msg =  '<div id="message" class="updated notice notice-success is-dismissible"><p>'. esc_html__( 'Your default setting has been setup.', MWB_TEXTDOMAIN ) .'</p></div>';
    199199      }
    200200
     
    302302                <td class="primary_menu_seprator">
    303303                  <span class="dashicons-before  <?php echo esc_attr( $row['6'] ); ?>"></span>
    304                   <span><?php echo esc_attr( strip_tags( $row['0'] ) ); ?></span>
     304                  <span><?php echo esc_attr( wp_strip_all_tags( $row['0'] ) ); ?></span>
    305305                </td>
    306306
     
    333333                    <td>
    334334                      <span class="dashicons dashicons-arrow-right-alt sub-icon"></span>
    335                       <span><?php echo esc_attr( strip_tags( $rows['0'] ) ); ?></span>
     335                      <span><?php echo esc_attr( wp_strip_all_tags( $rows['0'] ) ); ?></span>
    336336                    </td>
    337337                    <?php foreach ( $roles as $role_key=>$role ) { ?>
     
    421421                  <td>
    422422                    <span id="wp-admin-bar-<?php echo esc_attr( $row->id ); ?>"></span>
    423                     <span># <?php echo esc_attr( strip_tags( $row->title ) ); ?></span>
     423                    <span># <?php echo esc_attr( wp_strip_all_tags( $row->title ) ); ?></span>
    424424                  </td>
    425425                  <?php foreach ( $roles as $role_key => $role ) { ?> 
     
    444444                            <span id="wp-admin-bar-<?php echo esc_attr( $child_menu->id ); ?>"></span>
    445445                            <span class="dashicons dashicons-arrow-right-alt sub-icon"></span>
    446                             <span> <?php echo esc_attr( strip_tags( $child_menu->title ) ); ?></span>
     446                            <span> <?php echo esc_attr( wp_strip_all_tags( $child_menu->title ) ); ?></span>
    447447                          </td>
    448448                          <?php foreach ( $roles as $role_key=>$role ) { ?>
     
    589589        //this is the patch for the wordpress 4 or may be latetest version for the customize menu only
    590590        if( $pare_child[0] == 'themes.php' ) {
    591           $parse_data = parse_url( $pare_child[1] );
     591          $parse_data = wp_parse_url( $pare_child[1] );
    592592          if( $parse_data['path'] == 'customize.php' ) {
    593593            unset( $submenu['themes.php'][6] );
  • my-wp-brand/trunk/mwb.php

    r3128281 r3151072  
    1212 * Plugin URI:  https://imw3.com/product/my-wp-brand
    1313 * Description: My Brand plugin is used to customize admin panel.
    14  * Version:     1.1.2
     14 * Version:     1.1.3
    1515 * Author:      imw3
    1616 * Author URI:  https://imw3.com/
     
    3636            /**
    3737             * Action hooks
     38             *
    3839             * @version 1.0.0
     40             * @version 1.1.3 Removed unnecessary wp_ajax_nopriv hooks
    3941             */
    4042            add_action( 'admin_menu' , array( $this , 'mwb_manage_admin_menu' ) );
     
    4446            add_action( 'wp_ajax_mwb_plugins_form' , array( $this , 'mwb_plugins_form' ) );
    4547            add_action( 'login_enqueue_scripts' , array( $this , 'mwb_manage_login_form' ) );
    46             add_action( 'wp_ajax_nopriv_mwb_style_ajax' , array( $this , 'mwb_style_ajax' ) );
    47             add_action( 'wp_ajax_nopriv_mwb_author_form' , array( $this , 'mwb_author_form' ) );
    48             add_action( 'wp_ajax_nopriv_mwb_plugins_form' , array( $this , 'mwb_plugins_form' ) );
    4948            add_action( 'admin_bar_menu' , array( $this , 'mwb_manage_admin_top_bar_menu' ) , 1 );
    5049            add_action( 'admin_enqueue_scripts' , array( $this , 'mwb_enqueue_scripts_and_styles' ) );
     
    107106            wp_enqueue_script('jquery');
    108107
    109             wp_localize_script( 'jquery', 'mwb_ajax', array( 'url' => admin_url( 'admin-ajax.php' ) ) );
     108            wp_localize_script( 'jquery', 'mwb_ajax', array(
     109                'url' => admin_url( 'admin-ajax.php' ),
     110                'nonce' => wp_create_nonce( 'ajax-nonce' )
     111            ));
    110112
    111113        }
     
    544546         * @ajax
    545547         *  -> mwb plugins form
     548         *
     549         * @since 1.0.0
     550         * @since 1.1.3 Added user capability verification and nonce verification.
    546551         */
    547552        public function mwb_plugins_form(){
    548            
     553
     554            if ( ! current_user_can( 'manage_options' ) ) {
     555                exit;
     556            }
     557
     558            if ( isset( $_POST['nonce'] ) && ! wp_verify_nonce( $_POST['nonce'] , 'ajax-nonce' ) ) {
     559                die('The token has expired!');
     560            }
     561
    549562            if ( empty( get_option( 'hide-plugins' ) ) ) {
    550563                add_option( 'hide-plugins' , array_map( 'sanitize_text_field', $_POST['plugins'] ) );
     
    562575         * @ajax
    563576         *  -> mwb style form
     577         *
     578         * @since 1.0.0
     579         * @since 1.1.3 Added user capability verification and nonce verification.
    564580         */
    565581        public function mwb_style_ajax() {
     582
     583            if ( ! current_user_can( 'manage_options' ) ) {
     584                exit;
     585            }
     586
     587            if ( isset( $_POST['nonce'] ) && ! wp_verify_nonce( $_POST['nonce'] , 'ajax-nonce' ) ) {
     588                die('The token has expired!');
     589            }
    566590
    567591            /**
     
    592616         * @ajax
    593617         *  -> mwb author form
     618         *
     619         * @since 1.0.0
     620         * @since 1.1.3 Added user capability verification and nonce verification.
    594621         */
    595622        public function mwb_author_form() {
     623
     624            if ( ! current_user_can( 'manage_options' ) ) {
     625                exit;
     626            }
     627
     628            if ( isset( $_POST['nonce'] ) && ! wp_verify_nonce( $_POST['nonce'] , 'ajax-nonce' ) ) {
     629                die('The token has expired!');
     630            }
    596631
    597632            /**
  • my-wp-brand/trunk/readme.txt

    r3128281 r3151072  
    11=== My Wp Brand – Hide menu & Hide Plugin ===
    2 Contributors: imw3, riyazuddin, mohammadazad
    3 Tags: hide menu, hide plugin, hide version, admin menu, change logo, menu,
     2Contributors: imw3, mohammadazad, riyazuddin
     3Tags: hide menu, hide plugin, hide version, admin menu, change logo,
    44Requires at least: 6.5
    5 Tested up to: 6.6
     5Tested up to: 6.6.2
    66Requires PHP: 7.4
    7 Stable tag: 1.1.2
     7Stable tag: 1.1.3
    88License: GPLv3
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    5454== Installation ==
    5555
    56 1. Install via the built-in WordPress plugin installer. Or download and unzip my-wp-brand.zip inside the plugins directory for your site (typically wp-content/plugins/)
    57 2. Activate the plugin through the ‘Plugins’ admin menu in WordPress.
    58 3. Go to “Setting” -> “Wp Brand” and check or tick mark those plugin / menus that you want to hide from admin. (You can also use the “Settings” link in the plugin’s entry on the admin “Plugins” page).
     561. Install via the built-in WordPress plugin installer. Or download and unzip my-wp-brand.zip inside the plugin’s directory for your site (typically wp-content/plugins/)
     572. Activate the plugin through the ‘Plugins’ admin menu in WordPress.
     583. Go to “Setting” -> “Wp Brand” and check or tick mark those plugin / menus that you want to hide from admin. (You can also use the “Settings” link in the plugin’s entry on the admin “Plugins” page).
    5959
    6060== Changelog ==
     
    7474* Fix Minor Bug.
    7575* Compatible with WordPress 6.6
     76
     77= 1.1.3 =
     78* Fixed broken access control vulnerability.
     79* Compatible with WordPress 6.6.2
Note: See TracChangeset for help on using the changeset viewer.