Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/wallet-system-for-woocommerce/admin/class-wallet-system-for-woocommerce-admin.php
+++ b/wallet-system-for-woocommerce/admin/class-wallet-system-for-woocommerce-admin.php
@@ -64,6 +64,30 @@
}
/**
+ * Check whether the current user is allowed to manage wallet admin actions.
+ *
+ * @return bool
+ */
+ private function wps_wsfw_current_user_can_manage_wallet() {
+ return current_user_can( 'manage_woocommerce' ) || current_user_can( 'manage_options' );
+ }
+
+ /**
+ * Send an AJAX permission error and stop execution.
+ *
+ * @return void
+ */
+ private function wps_wsfw_send_ajax_permission_error() {
+ wp_send_json_error(
+ array(
+ 'msg' => esc_html__( 'Sorry, you are not allowed to do that.', 'wallet-system-for-woocommerce' ),
+ 'msgType' => 'error',
+ ),
+ 403
+ );
+ }
+
+ /**
* Register the stylesheets for the admin area.
*
* @since 1.0.0
@@ -126,7 +150,7 @@
$wps_wsfw_branner_notice = array(
'ajaxurl' => admin_url( 'admin-ajax.php' ),
- 'wps_wsfw_nonce' => wp_create_nonce( 'wp_rest' ),
+ 'wps_wsfw_nonce' => wp_create_nonce( 'wsfw_admin_nonce' ),
);
wp_register_script( $this->plugin_name . 'admin-notice', WALLET_SYSTEM_FOR_WOOCOMMERCE_DIR_URL . 'admin/js/wps-wsfw-wallet-card-notices.js', array( 'jquery' ), $this->version, false );
@@ -206,7 +230,7 @@
array(
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'wps_wsfw_user_count' => $this->wps_wsfw_user_count(),
- 'nonce' => wp_create_nonce( 'wp_rest' ),
+ 'nonce' => wp_create_nonce( 'wsfw_admin_nonce' ),
'reloadurl' => admin_url( 'admin.php?page=wallet_system_for_woocommerce_menu' ),
'wsfw_gen_tab_enable' => get_option( 'wps_wsfw_enable' ),
'datatable_pagination_text' => __( 'Rows per page _MENU_', 'wallet-system-for-woocommerce' ),
@@ -2190,7 +2214,11 @@
* @return void
*/
public function export_users_wallet() {
- check_ajax_referer( 'wp_rest', 'nonce' );
+ check_ajax_referer( 'wsfw_admin_nonce', 'nonce' );
+ if ( ! $this->wps_wsfw_current_user_can_manage_wallet() ) {
+ $this->wps_wsfw_send_ajax_permission_error();
+ }
+
$per_user = ! empty( $_POST['wps_wsfw_per_user'] ) ? sanitize_text_field( wp_unslash( $_POST['wps_wsfw_per_user'] ) ) : 0;
$current_page = ! empty( $_POST['wps_wsfw_current_page'] ) ? sanitize_text_field( wp_unslash( $_POST['wps_wsfw_current_page'] ) ) : 1;
$csv_data = ! empty( $_POST['csv_data'] ) ? map_deep( wp_unslash( $_POST['csv_data'] ), 'sanitize_text_field' ) : '';
@@ -2253,11 +2281,15 @@
*/
public function restrict_user_from_wallet_access() {
$update = true;
- check_ajax_referer( 'wp_rest', 'nonce' );
- $user_id = ( isset( $_POST['user_id'] ) ) ? sanitize_text_field( wp_unslash( $_POST['user_id'] ) ) : '';
+ check_ajax_referer( 'wsfw_admin_nonce', 'nonce' );
+ if ( ! $this->wps_wsfw_current_user_can_manage_wallet() ) {
+ $this->wps_wsfw_send_ajax_permission_error();
+ }
+
+ $user_id = ( isset( $_POST['user_id'] ) ) ? absint( wp_unslash( $_POST['user_id'] ) ) : 0;
$restriction_status = ( isset( $_POST['restriction_status'] ) ) ? sanitize_text_field( wp_unslash( $_POST['restriction_status'] ) ) : '';
- if ( ! empty( $user_id ) ) {
+ if ( $user_id > 0 ) {
if ( 'true' == $restriction_status ) {
update_user_meta( $user_id, 'user_restriction_for_wallet', 'restricted', true );
@@ -2512,7 +2544,11 @@
*/
public function change_wallet_withdrawan_status() {
$update = true;
- check_ajax_referer( 'wp_rest', 'nonce' );
+ check_ajax_referer( 'wsfw_admin_nonce', 'nonce' );
+ if ( ! $this->wps_wsfw_current_user_can_manage_wallet() ) {
+ $this->wps_wsfw_send_ajax_permission_error();
+ }
+
if ( empty( $_POST['withdrawal_id'] ) ) {
$wps_wsfw_error_text = esc_html__( 'Withdrawal Id is not given', 'wallet-system-for-woocommerce' );
$message = array(
@@ -2529,8 +2565,8 @@
);
$update = false;
}
- $withdrawal_id = ( isset( $_POST['withdrawal_id'] ) ) ? sanitize_text_field( wp_unslash( $_POST['withdrawal_id'] ) ) : '';
- $user_id = ( isset( $_POST['user_id'] ) ) ? sanitize_text_field( wp_unslash( $_POST['user_id'] ) ) : '';
+ $withdrawal_id = ( isset( $_POST['withdrawal_id'] ) ) ? absint( wp_unslash( $_POST['withdrawal_id'] ) ) : 0;
+ $user_id = ( isset( $_POST['user_id'] ) ) ? absint( wp_unslash( $_POST['user_id'] ) ) : 0;
$walletamount = get_user_meta( $user_id, 'wps_wallet', true );
$withdrawal_amount = get_post_meta( $withdrawal_id, 'wps_wallet_withdrawal_amount', true );
@@ -4249,9 +4285,21 @@
*/
public function wps_wallet_delete_user_tranasactions() {
$update = true;
- check_ajax_referer( 'wp_rest', 'nonce' );
+ check_ajax_referer( 'wsfw_admin_nonce', 'nonce' );
+ if ( ! $this->wps_wsfw_current_user_can_manage_wallet() ) {
+ $this->wps_wsfw_send_ajax_permission_error();
+ }
+
+ $transaction_id = ! empty( $_POST['transaction_id'] ) ? absint( wp_unslash( $_POST['transaction_id'] ) ) : 0;
+ if ( empty( $transaction_id ) ) {
+ wp_send_json_error(
+ array(
+ 'message' => esc_html__( 'Transaction ID is missing.', 'wallet-system-for-woocommerce' ),
+ ),
+ 400
+ );
+ }
- $transaction_id = ! empty( $_POST['transaction_id'] ) ? absint( sanitize_text_field( wp_unslash( $_POST['transaction_id'] ) ) ) : '';
global $wpdb;
$transaction_executed = $wpdb->delete( $wpdb->prefix . 'wps_wsfw_wallet_transaction', array( 'id' => $transaction_id ), array( '%d' ) );
@@ -4351,16 +4399,28 @@
* @return void
*/
public function wps_wsfw_dismiss_notice_banner_callback() {
- if ( isset( $_REQUEST['wps_wsfw_nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['wps_wsfw_nonce'] ) ), 'wp_rest' ) ) {
+ $nonce = '';
+ if ( isset( $_REQUEST['wps_wsfw_nonce'] ) ) {
+ $nonce = sanitize_text_field( wp_unslash( $_REQUEST['wps_wsfw_nonce'] ) );
+ } elseif ( isset( $_REQUEST['wps_nonce'] ) ) {
+ // Backward compatibility for older JS payloads.
+ $nonce = sanitize_text_field( wp_unslash( $_REQUEST['wps_nonce'] ) );
+ }
- $banner_id = get_option( 'wps_wgm_notify_new_banner_id', false );
+ if ( empty( $nonce ) || ! wp_verify_nonce( $nonce, 'wsfw_admin_nonce' ) ) {
+ $this->wps_wsfw_send_ajax_permission_error();
+ }
- if ( isset( $banner_id ) && '' != $banner_id ) {
- update_option( 'wps_wgm_notify_hide_baneer_notification', $banner_id );
- }
+ if ( ! $this->wps_wsfw_current_user_can_manage_wallet() ) {
+ $this->wps_wsfw_send_ajax_permission_error();
+ }
- wp_send_json_success();
+ $banner_id = get_option( 'wps_wgm_notify_new_banner_id', false );
+ if ( isset( $banner_id ) && '' != $banner_id ) {
+ update_option( 'wps_wgm_notify_hide_baneer_notification', $banner_id );
}
+
+ wp_send_json_success();
}
/**
@@ -4374,7 +4434,32 @@
$from_date = ! empty( $_POST['fromdate'] ) ? sanitize_text_field( wp_unslash( $_POST['fromdate'] ) ) : ' ';
$to_date = ! empty( $_POST['toDate'] ) ? sanitize_text_field( wp_unslash( $_POST['toDate'] ) ) : ' ';
- $user_id = ! empty( $_POST['user_id'] ) ? sanitize_text_field( wp_unslash( $_POST['user_id'] ) ) : '';
+ $user_id = ! empty( $_POST['user_id'] ) ? absint( wp_unslash( $_POST['user_id'] ) ) : 0;
+
+ if ( ! is_user_logged_in() ) {
+ wp_send_json_error(
+ array(
+ 'msg' => esc_html__( 'You must be logged in to do that.', 'wallet-system-for-woocommerce' ),
+ 'msgType' => 'error',
+ ),
+ 401
+ );
+ }
+
+ $current_user_id = get_current_user_id();
+ if ( empty( $user_id ) ) {
+ $user_id = $current_user_id;
+ }
+
+ if ( $user_id !== $current_user_id && ! $this->wps_wsfw_current_user_can_manage_wallet() ) {
+ wp_send_json_error(
+ array(
+ 'msg' => esc_html__( 'Unauthorized request.', 'wallet-system-for-woocommerce' ),
+ 'msgType' => 'error',
+ ),
+ 403
+ );
+ }
$user_data = $this->wps_wsfw_get_user_report( $user_id, $from_date, $to_date );
--- a/wallet-system-for-woocommerce/common/class-wallet-system-for-woocommerce-common.php
+++ b/wallet-system-for-woocommerce/common/class-wallet-system-for-woocommerce-common.php
@@ -68,13 +68,17 @@
* @since 1.0.0
*/
public function wsfw_common_enqueue_scripts() {
+ $enable = get_option( 'wps_wsfw_enable', '' );
+ if ( ! isset( $enable ) || 'on' !== $enable ) {
+ return;
+ }
+
wp_register_script( $this->plugin_name . 'common', WALLET_SYSTEM_FOR_WOOCOMMERCE_DIR_URL . 'common/src/js/wallet-system-for-woocommerce-common.js', array( 'jquery' ), $this->version, false );
wp_localize_script(
$this->plugin_name . 'common',
'wsfw_common_param',
array(
'ajaxurl' => admin_url( 'admin-ajax.php' ),
- 'nonce' => wp_create_nonce( 'wp_rest' ),
)
);
wp_enqueue_script( $this->plugin_name . 'common' );
--- a/wallet-system-for-woocommerce/includes/class-wallet-system-for-woocommerce.php
+++ b/wallet-system-for-woocommerce/includes/class-wallet-system-for-woocommerce.php
@@ -81,7 +81,7 @@
$this->version = WALLET_SYSTEM_FOR_WOOCOMMERCE_VERSION;
} else {
- $this->version = '2.7.5';
+ $this->version = '2.7.6';
}
$this->plugin_name = 'wallet-system-for-woocommerce';
@@ -278,7 +278,7 @@
$this->loader->add_action( 'woocommerce_shop_order_list_table_custom_column', $wsfw_plugin_admin, 'wps_wocuf_pro_populate_wallet_order_column', 10, 2 );
$this->loader->add_filter( 'woocommerce_shop_order_list_table_columns', $wsfw_plugin_admin, 'wps_wsfw_wallet_add_columns_to_admin_orders', 99 );
$this->loader->add_action( 'wp_ajax_wps_wsfw_filter_chart_data', $wsfw_plugin_admin, 'wps_wsfw_filter_chart_data' );
- $this->loader->add_action( 'wp_ajax_nopriv_wps_wsfw_filter_chart_data', $wsfw_plugin_admin, 'wps_wsfw_filter_chart_data' );
+ // Chart data contains user wallet details; never expose to guests.
// download Pdf.
$this->loader->add_action( 'init', $wsfw_plugin_admin, 'wps_wsfw_download_pdf_file_callback' );
--- a/wallet-system-for-woocommerce/wallet-system-for-woocommerce.php
+++ b/wallet-system-for-woocommerce/wallet-system-for-woocommerce.php
@@ -15,16 +15,16 @@
* Plugin Name: Wallet System For WooCommerce
* Plugin URI: https://wordpress.org/plugins/wallet-system-for-woocommerce
* Description: <code><strong>Wallet System for WooCommerce</strong></code> is a digital wallet plugin where users can add or delete balances in bulk, give refunds and earn cashback. <a href="https://wpswings.com/woocommerce-plugins/?utm_source=wpswings-wallet-shop&utm_medium=wallet-org-backend&utm_campaign=shop-page" target="_blank"> Elevate your e-commerce store by exploring more on <strong> WP Swings </strong></a>.
- * Version: 2.7.5
+ * Version: 2.7.6
* Author: WP Swings
* Author URI: https://wpswings.com/?utm_source=wpswings-wallet-official&utm_medium=wallet-org-backend&utm_campaign=official
* Text Domain: wallet-system-for-woocommerce
* Domain Path: /languages
* Requires Plugins: woocommerce
* WC Requires at least: 5.5.0
- * WC tested up to: 10.6.1
+ * WC tested up to: 10.7
* WP Requires at least: 6.7.0
- * WP tested up to: 6.9.4
+ * WP tested up to: 6.9
* Requires PHP: 7.4
*
* License: GNU General Public License v3.0
@@ -64,7 +64,7 @@
$wp_upload = wp_upload_dir();
wallet_system_for_woocommerce_constants( 'WALLET_SYSTEM_FOR_WOOCOMMERCE_UPLOAD_DIR', $wp_upload['basedir'] );
- wallet_system_for_woocommerce_constants( 'WALLET_SYSTEM_FOR_WOOCOMMERCE_VERSION', '2.7.5' );
+ wallet_system_for_woocommerce_constants( 'WALLET_SYSTEM_FOR_WOOCOMMERCE_VERSION', '2.7.6' );
wallet_system_for_woocommerce_constants( 'WALLET_SYSTEM_FOR_WOOCOMMERCE_DIR_PATH', plugin_dir_path( __FILE__ ) );
wallet_system_for_woocommerce_constants( 'WALLET_SYSTEM_FOR_WOOCOMMERCE_DIR_URL', plugin_dir_url( __FILE__ ) );
wallet_system_for_woocommerce_constants( 'WALLET_SYSTEM_FOR_WOOCOMMERCE_SERVER_URL', 'https://wpswings.com' );