Skip to content

Commit 5f351ca

Browse files
authored
Merge pull request #307 from Kit/check-nonce-on-export
Export Configuration: Check nonce
2 parents a7b956d + 3d16508 commit 5f351ca

6 files changed

Lines changed: 139 additions & 94 deletions

File tree

includes/class-ckwc-integration.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,11 +282,24 @@ public function maybe_export_configuration() {
282282
return;
283283
}
284284

285+
// Bail if the user isn't permitted to manage WooCommerce settings.
286+
if ( ! current_user_can( 'manage_woocommerce' ) ) {
287+
return;
288+
}
289+
290+
// Bail if nonce verification fails.
291+
if ( ! isset( $_REQUEST['nonce'] ) ) {
292+
return;
293+
}
294+
if ( ! wp_verify_nonce( sanitize_key( $_REQUEST['nonce'] ), 'ckwc-nonce' ) ) {
295+
return;
296+
}
297+
285298
// Bail if the action isn't for exporting a configuration file.
286-
if ( ! array_key_exists( 'action', $_REQUEST ) ) { // phpcs:ignore WordPress.Security.NonceVerification
299+
if ( ! array_key_exists( 'action', $_REQUEST ) ) {
287300
return;
288301
}
289-
if ( $_REQUEST['action'] !== 'ckwc-export' ) { // phpcs:ignore WordPress.Security.NonceVerification
302+
if ( $_REQUEST['action'] !== 'ckwc-export' ) {
290303
return;
291304
}
292305

0 commit comments

Comments
 (0)