From e6070bfcc5d741c8498f814519eb888a0fea50a0 Mon Sep 17 00:00:00 2001 From: Ashley Gibson Date: Fri, 30 Oct 2026 10:41:16 +0000 Subject: [PATCH 1/4] Add nonce checks to notice dismissal --- .../class-sv-wc-admin-notice-handler.php | 44 +++++++++++++++---- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/woocommerce/class-sv-wc-admin-notice-handler.php b/woocommerce/class-sv-wc-admin-notice-handler.php index 938fa098f..6a08c83bf 100644 --- a/woocommerce/class-sv-wc-admin-notice-handler.php +++ b/woocommerce/class-sv-wc-admin-notice-handler.php @@ -230,16 +230,30 @@ public function render_admin_notice( $message, $message_id, $params = array() ) } echo sprintf( - '

%5$s

', + '

%5$s

', esc_attr( implode( ' ', $classes ) ), esc_attr( $this->get_plugin()->get_id() ), esc_attr( $message_id ), ( ! $params['is_visible'] ) ? 'style="display:none;"' : '', - wp_kses_post( $message ) + wp_kses_post( $message ), + esc_attr( wp_create_nonce( $this->get_dismiss_notice_nonce_action() ) ) ); } + /** + * Gets the nonce action used to authorize dismissing notices for this plugin. + * + * @since 6.2.6 + * + * @return string + */ + protected function get_dismiss_notice_nonce_action() : string { + + return 'wc_plugin_framework_' . $this->get_plugin()->get_id() . '_dismiss_notice'; + } + + /** * Render the javascript to handle the notice "dismiss" functionality * @@ -273,7 +287,8 @@ public function render_admin_notice_js() { log_dismissed_notice( $( $notice ).data( 'plugin-id' ), - $( $notice ).data( 'message-id' ) + $( $notice ).data( 'message-id' ), + $( $notice ).data( 'nonce' ) ); } ); @@ -287,20 +302,22 @@ public function render_admin_notice_js() { log_dismissed_notice( $( $notice ).data( 'plugin-id' ), - $( $notice ).data( 'message-id' ) + $( $notice ).data( 'message-id' ), + $( $notice ).data( 'nonce' ) ); $( $notice ).fadeOut(); } ); - function log_dismissed_notice( pluginID, messageID ) { + function log_dismissed_notice( pluginID, messageID, nonce ) { - $.get( + $.post( ajaxurl, { action: 'wc_plugin_framework_' + pluginID + '_dismiss_notice', - messageid: messageID + messageid: messageID, + nonce: nonce } ); } @@ -419,8 +436,19 @@ public function get_dismissed_notices( $user_id = null ) { */ public function handle_dismiss_notice() { - $this->dismiss_notice( $_REQUEST['messageid'] ); + check_ajax_referer( $this->get_dismiss_notice_nonce_action(), 'nonce' ); + + if ( ! current_user_can( 'manage_woocommerce' ) ) { + wp_send_json_error( null, 403 ); + } + + if ( empty( $_REQUEST['messageid'] ) || ! is_string( $_REQUEST['messageid'] ) ) { + wp_send_json_error( null, 400 ); + } + + $this->dismiss_notice( sanitize_text_field( wp_unslash( $_REQUEST['messageid'] ) ) ); + wp_send_json_success(); } From 8ff8c36258aeb0ecfacdb4165a2d7f4184273ecf Mon Sep 17 00:00:00 2001 From: Ashley Gibson Date: Fri, 30 Oct 2026 10:45:21 +0000 Subject: [PATCH 2/4] Add capaiblity check to batch handling --- .../class-sv-wp-job-batch-handler.php | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/woocommerce/utilities/class-sv-wp-job-batch-handler.php b/woocommerce/utilities/class-sv-wp-job-batch-handler.php index 2dc89060e..fb50998b9 100644 --- a/woocommerce/utilities/class-sv-wp-job-batch-handler.php +++ b/woocommerce/utilities/class-sv-wp-job-batch-handler.php @@ -87,6 +87,21 @@ protected function add_hooks() { add_action( 'wp_ajax_' . $this->get_job_handler()->get_identifier() . '_cancel_job', array( $this, 'ajax_cancel_job' ) ); } + /** + * Gets the capability required to process or cancel jobs via AJAX. + * + * Child classes can override this to require a different capability. + * + * @since 6.2.6 + * + * @return string + */ + protected function get_required_capability() : string { + + return 'manage_woocommerce'; + } + + /** * Gets the name of the script handle. * @@ -185,6 +200,10 @@ public function ajax_process_batch() { check_ajax_referer( $this->get_job_handler()->get_identifier() . '_process_batch', 'security' ); + if ( ! current_user_can( $this->get_required_capability() ) ) { + wp_send_json_error( null, 403 ); + } + if ( empty( $_POST['job_id'] ) ) { return; } @@ -219,6 +238,10 @@ public function ajax_cancel_job() { check_ajax_referer( $this->get_job_handler()->get_identifier() . '_cancel_job', 'security' ); + if ( ! current_user_can( $this->get_required_capability() ) ) { + wp_send_json_error( null, 403 ); + } + if ( empty( $_POST['job_id'] ) ) { return; } From ed1fcfa3e7b6551ccdb6c186557c1981e5311ea2 Mon Sep 17 00:00:00 2001 From: Ashley Gibson Date: Fri, 30 Oct 2026 10:56:56 +0000 Subject: [PATCH 3/4] Add changelog entry --- woocommerce/changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/woocommerce/changelog.txt b/woocommerce/changelog.txt index cf756e266..832828778 100644 --- a/woocommerce/changelog.txt +++ b/woocommerce/changelog.txt @@ -2,6 +2,7 @@ 2026.nn.nn - version 6.2.5 * Fix - "event is not a function" error on My Payment Methods page +* Fix - Add additional nonce and permission checks 2026.08.19 - version 6.2.4 * Security - Hardened capability checks around the payment token editor's admin functionality From 0789fb43b2296cbef3befddf5090e9fd6c4656ad Mon Sep 17 00:00:00 2001 From: Ashley Gibson Date: Fri, 30 Oct 2026 10:59:37 +0000 Subject: [PATCH 4/4] Change since version --- woocommerce/class-sv-wc-admin-notice-handler.php | 2 +- woocommerce/utilities/class-sv-wp-job-batch-handler.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/woocommerce/class-sv-wc-admin-notice-handler.php b/woocommerce/class-sv-wc-admin-notice-handler.php index 6a08c83bf..aa8dc6077 100644 --- a/woocommerce/class-sv-wc-admin-notice-handler.php +++ b/woocommerce/class-sv-wc-admin-notice-handler.php @@ -244,7 +244,7 @@ public function render_admin_notice( $message, $message_id, $params = array() ) /** * Gets the nonce action used to authorize dismissing notices for this plugin. * - * @since 6.2.6 + * @since 6.2.5 * * @return string */ diff --git a/woocommerce/utilities/class-sv-wp-job-batch-handler.php b/woocommerce/utilities/class-sv-wp-job-batch-handler.php index fb50998b9..8e75622a3 100644 --- a/woocommerce/utilities/class-sv-wp-job-batch-handler.php +++ b/woocommerce/utilities/class-sv-wp-job-batch-handler.php @@ -92,7 +92,7 @@ protected function add_hooks() { * * Child classes can override this to require a different capability. * - * @since 6.2.6 + * @since 6.2.5 * * @return string */