Skip to content

Commit 8a7453b

Browse files
committed
add current_user_can() check
1 parent 784f827 commit 8a7453b

5 files changed

Lines changed: 30 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
= 1.8.1 =
2+
3+
Bugs we fixed:
4+
5+
* Fix vulnerbility with arbitrary option update.
6+
17
= 1.8.0 =
28

39
Enhancements:

classes/suggested-tasks/providers/class-select-locale.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,12 @@ public function print_popover_form_contents() {
243243
* @return void
244244
*/
245245
public function handle_interactive_task_specific_submit() {
246+
247+
// Check if the user has the necessary capabilities.
248+
if ( ! \current_user_can( 'manage_options' ) ) {
249+
\wp_send_json_error( [ 'message' => \esc_html__( 'You do not have permission to update settings.', 'progress-planner' ) ] );
250+
}
251+
246252
// Check the nonce.
247253
if ( ! \check_ajax_referer( 'progress_planner', 'nonce', false ) ) {
248254
\wp_send_json_error( [ 'message' => \esc_html__( 'Invalid nonce.', 'progress-planner' ) ] );

classes/suggested-tasks/providers/class-select-timezone.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,12 @@ public function print_popover_form_contents() {
158158
* @return void
159159
*/
160160
public function handle_interactive_task_specific_submit() {
161+
162+
// Check if the user has the necessary capabilities.
163+
if ( ! \current_user_can( 'manage_options' ) ) {
164+
\wp_send_json_error( [ 'message' => \esc_html__( 'You do not have permission to update settings.', 'progress-planner' ) ] );
165+
}
166+
161167
// Check the nonce.
162168
if ( ! \check_ajax_referer( 'progress_planner', 'nonce', false ) ) {
163169
\wp_send_json_error( [ 'message' => \esc_html__( 'Invalid nonce.', 'progress-planner' ) ] );

classes/suggested-tasks/providers/class-set-date-format.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,12 @@ public function print_popover_form_contents() {
253253
* @return void
254254
*/
255255
public function handle_interactive_task_specific_submit() {
256+
257+
// Check if the user has the necessary capabilities.
258+
if ( ! \current_user_can( 'manage_options' ) ) {
259+
\wp_send_json_error( [ 'message' => \esc_html__( 'You do not have permission to update settings.', 'progress-planner' ) ] );
260+
}
261+
256262
// Check the nonce.
257263
if ( ! \check_ajax_referer( 'progress_planner', 'nonce', false ) ) {
258264
\wp_send_json_error( [ 'message' => \esc_html__( 'Invalid nonce.', 'progress-planner' ) ] );

classes/suggested-tasks/providers/class-tasks-interactive.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ public function get_task_details( $task_data = [] ) {
6161
* @return void
6262
*/
6363
public function handle_interactive_task_submit() {
64+
65+
// Check if the user has the necessary capabilities.
66+
if ( ! \current_user_can( 'manage_options' ) ) {
67+
\wp_send_json_error( [ 'message' => \esc_html__( 'You do not have permission to update settings.', 'progress-planner' ) ] );
68+
}
69+
6470
// Check the nonce.
6571
if ( ! \check_ajax_referer( 'progress_planner', 'nonce', false ) ) {
6672
\wp_send_json_error( [ 'message' => \esc_html__( 'Invalid nonce.', 'progress-planner' ) ] );

0 commit comments

Comments
 (0)