Plugin Directory

Changeset 3203679


Ignore:
Timestamp:
12/06/2024 02:20:25 PM (15 months ago)
Author:
hookandhook
Message:

3.2.22 | Fix vulnerability (user meta)

Location:
wp-courses
Files:
230 added
3 edited

Legend:

Unmodified
Added
Removed
  • wp-courses/trunk/README.md

    r3187948 r3203679  
    55Requires at least: 5.0
    66Tested up to: 6.7
    7 Stable tag: 3.2.21
     7Stable tag: 3.2.22
    88License: GPLv2 or later license
    99
     
    124124== Changelog ===
    125125
     1263.2.22: Fix vulnerability (user meta)
    1261273.2.21: Tested up to 6.7
    1271283.2.20: Tested up to 6.6
  • wp-courses/trunk/ajax/ajax-user-meta.php

    r3011178 r3203679  
    11<?php
    2     add_action( 'wp_footer', 'wpc_action_update_user_option_js' );
     2add_action('wp_footer', 'wpc_action_update_user_option_js');
    33
    4     function wpc_action_update_user_option_js() { ?>
    5         <?php $ajax_nonce = wp_create_nonce( "wpc-user-meta-ajax" ); ?>
    6         <script type="text/javascript" >
    7 
     4function wpc_action_update_user_option_js()
     5{ ?>
     6    <?php $ajax_nonce = wp_create_nonce("wpc-user-meta-ajax"); ?>
     7    <script type="text/javascript">
    88        jQuery(document).ready(function($) {
    99
    10             jQuery(document).on('click', '.wpc-ajax-user-meta-option', function(){
     10            jQuery(document).on('click', '.wpc-ajax-user-meta-option', function() {
    1111
    1212                var data = {
    13                     'security'      : "<?php echo esc_js( $ajax_nonce ); ?>",
    14                     'action'        : 'wpc_update_user_meta',
    15                     'user_id'       : $(this).data('user-id'),
    16                     'meta_key'      : $(this).data('key'),
    17                     'meta_value'    : $(this).prop('checked') === true ? 'true' : 'false',
     13                    'security': "<?php echo esc_js($ajax_nonce); ?>",
     14                    'action': 'wpc_update_user_meta',
     15                    'user_id': $(this).data('user-id'),
     16                    'meta_key': $(this).data('key'),
     17                    'meta_value': $(this).prop('checked') === true ? 'true' : 'false',
    1818                };
    1919
     
    2626
    2727        });
    28         </script> <?php
     28    </script>
     29<?php
     30}
     31
     32add_action('wp_ajax_wpc_update_user_meta', 'wpc_update_user_meta_option');
     33
     34function wpc_update_user_meta_option()
     35{
     36    check_ajax_referer('wpc-user-meta-ajax', 'security');
     37
     38    $user_id    = isset($_POST['user_id']) ? absint($_POST['user_id']) : 0;
     39    $meta_key   = isset($_POST['meta_key']) ? sanitize_key($_POST['meta_key']) : '';
     40    $meta_value = isset($_POST['meta_value']) ? sanitize_text_field($_POST['meta_value']) : '';
     41
     42    // Authorization check: Only allow changes for own user
     43    if ($user_id !== get_current_user_id()) {
     44        wp_die();
    2945    }
    3046
    31     add_action( 'wp_ajax_wpc_update_user_meta', 'wpc_update_user_meta_option' );
    32     function wpc_update_user_meta_option(){
    33         check_ajax_referer( 'wpc-user-meta-ajax', 'security' );
     47    // Allow-list of meta keys
     48    $allowed_meta_keys = ['wpc-email-status'];
    3449
    35         $user_id    = isset( $_POST['user_id'] ) ? absint( $_POST['user_id'] ) : 0;
    36         $meta_key   = isset( $_POST['meta_key'] ) ? sanitize_key( $_POST['meta_key'] ) : '';
    37         $meta_value = isset( $_POST['meta_value'] ) ? sanitize_text_field( $_POST['meta_value'] ) : '';
     50    if ($user_id && in_array($meta_key, $allowed_meta_keys, true)) {
     51        update_user_meta($user_id, $meta_key, $meta_value);
     52    }
    3853
    39         if ( $user_id && $meta_key !== '' ) {
    40             update_user_meta( $user_id, $meta_key, $meta_value );
    41         }
    42 
    43         wp_die(); // required
    44     }
     54    wp_die();
     55}
    4556?>
  • wp-courses/trunk/wp-courses.php

    r3187948 r3203679  
    44 * Plugin Name: WP Courses LMS
    55 * Description: Create unlimited online courses on your WordPress website with WP Courses LMS.
    6  * Version: 3.2.21
     6 * Version: 3.2.22
    77 * Author: WP Courses
    88 * Plugin URI: https://wpcoursesplugin.com
     
    591591
    592592        if (!empty($plugin_data['Version'])) {
    593             if (version_compare('3.2.7', $plugin_data['Version'], '>')) {
     593            if (version_compare('3.2.8', $plugin_data['Version'], '>')) {
    594594                $output = 'You are using an outdated version of WP Courses LMS Premium. Please update to the latest version to ensure compatibility and security.';
    595595
Note: See TracChangeset for help on using the changeset viewer.