Skip to content

Commit ea20bdb

Browse files
authored
Merge pull request #651 from ProgressPlanner/filip/add-permission-check
v1.8.1
2 parents 784f827 + c6ea46f commit ea20bdb

12 files changed

Lines changed: 73 additions & 2 deletions

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 vulnerability with arbitrary option update.
6+
17
= 1.8.0 =
28

39
Enhancements:

classes/actions/class-content-scan.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ public function register_hooks() {
4545
* @return void
4646
*/
4747
public function ajax_scan() {
48+
49+
if ( ! \current_user_can( 'manage_options' ) ) {
50+
\wp_send_json_error( [ 'message' => \esc_html__( 'You do not have permission to scan posts.', 'progress-planner' ) ] );
51+
}
52+
4853
// Check the nonce.
4954
if ( ! \check_ajax_referer( 'progress_planner', 'nonce', false ) ) {
5055
\wp_send_json_error( [ 'message' => \esc_html__( 'Invalid nonce.', 'progress-planner' ) ] );
@@ -71,6 +76,11 @@ public function ajax_scan() {
7176
* @return void
7277
*/
7378
public function ajax_reset_posts_data() {
79+
80+
if ( ! \current_user_can( 'manage_options' ) ) {
81+
\wp_send_json_error( [ 'message' => \esc_html__( 'You do not have permission to reset posts data.', 'progress-planner' ) ] );
82+
}
83+
7484
// Check the nonce.
7585
if ( ! \check_ajax_referer( 'progress_planner', 'nonce', false ) ) {
7686
\wp_send_json_error( [ 'message' => \esc_html__( 'Invalid nonce.', 'progress-planner' ) ] );

classes/admin/class-page-settings.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,11 @@ public function should_show_setting( $page_type ) {
128128
* @return void
129129
*/
130130
public function store_settings_form_options() {
131+
132+
if ( ! \current_user_can( 'manage_options' ) ) {
133+
\wp_send_json_error( [ 'message' => \esc_html__( 'You do not have permission to update settings.', 'progress-planner' ) ] );
134+
}
135+
131136
// Check the nonce.
132137
\check_admin_referer( 'progress_planner' );
133138

classes/class-suggested-tasks.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,16 @@ public function suggested_task_action() {
232232
\wp_send_json_error( [ 'message' => \esc_html__( 'Task not found.', 'progress-planner' ) ] );
233233
}
234234

235+
$provider = \progress_planner()->get_suggested_tasks()->get_tasks_manager()->get_task_provider( $task->get_provider_id() );
236+
237+
if ( ! $provider ) {
238+
\wp_send_json_error( [ 'message' => \esc_html__( 'Provider not found.', 'progress-planner' ) ] );
239+
}
240+
241+
if ( ! $provider->capability_required() ) {
242+
\wp_send_json_error( [ 'message' => \esc_html__( 'You do not have permission to complete this task.', 'progress-planner' ) ] );
243+
}
244+
235245
$updated = false;
236246

237247
switch ( $action ) {

classes/suggested-tasks/providers/class-email-sending.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,11 @@ protected function is_there_sending_email_override() {
255255
* @return void
256256
*/
257257
public function ajax_test_email_sending() {
258+
259+
if ( ! $this->capability_required() ) {
260+
\wp_send_json_error( [ 'message' => \esc_html__( 'You do not have permission to test email sending.', 'progress-planner' ) ] );
261+
}
262+
258263
// Check the nonce.
259264
\check_admin_referer( 'progress_planner' );
260265

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' ) ] );

classes/utils/class-onboard.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ public function on_activate_plugin( $plugin ) {
5858
* @return void
5959
*/
6060
public function save_onboard_response() {
61+
62+
if ( ! \current_user_can( 'manage_options' ) ) {
63+
\wp_send_json_error( [ 'message' => \esc_html__( 'You do not have permission to update settings.', 'progress-planner' ) ] );
64+
}
65+
6166
// Check the nonce.
6267
if ( ! \check_ajax_referer( 'progress_planner', 'nonce', false ) ) {
6368
\wp_send_json_error( [ 'message' => \esc_html__( 'Invalid nonce.', 'progress-planner' ) ] );

0 commit comments

Comments
 (0)