Skip to content

Commit e4f5208

Browse files
committed
Check nonce while profile image and cover image crop
1 parent ef5e2f3 commit e4f5208

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

includes/class-profile.php

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,8 +1509,17 @@ public function add_uwp_plupload_param( $params ) {
15091509
* @return void
15101510
*/
15111511
public function ajax_avatar_banner_upload() {
1512-
// Image upload handler
1513-
// todo: security checks
1512+
1513+
if ( ! isset( $_POST['security'] ) || ! wp_verify_nonce( $_POST['security'], 'uwp_avatar_banner_upload_nonce' ) ) {
1514+
$result['error'] = aui()->alert( array(
1515+
'type' => 'danger',
1516+
'content' => __( "Security check failed.", "userswp" )
1517+
) );
1518+
$return = json_encode( $result );
1519+
echo $return; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1520+
die();
1521+
}
1522+
15141523
$type = strip_tags( esc_sql( $_POST['uwp_popup_type'] ) );
15151524
$result = array();
15161525

@@ -1764,6 +1773,8 @@ public function crop_submit_form( $type = 'avatar' ) {
17641773

17651774
$content_wrap = $design_style == 'bootstrap' ? '.uwp-profile-image-change-modal .modal-content' : '#uwp-popup-modal-wrap';
17661775
$bg_color = apply_filters('uwp_crop_image_bg_color', '', $type);
1776+
1777+
$ajax_nonce = wp_create_nonce( 'uwp_avatar_banner_upload_nonce' );
17671778
?>
17681779

17691780
<script type="text/javascript">
@@ -1805,6 +1816,8 @@ public function crop_submit_form( $type = 'avatar' ) {
18051816
// our AJAX identifier
18061817
fd.append('action', 'uwp_avatar_banner_upload');
18071818
fd.append('uwp_popup_type', '<?php echo esc_attr( $type ); ?>');
1819+
// Add nonce for security
1820+
fd.append('security', '<?php echo esc_js( $ajax_nonce ); ?>');
18081821

18091822
$("#progressBar").show().removeClass('d-none');
18101823

@@ -1853,7 +1866,8 @@ public function crop_submit_form( $type = 'avatar' ) {
18531866
minSize: [uwp_full_width, uwp_full_height]
18541867
});
18551868
}
1856-
}
1869+
},
1870+
18571871
});
18581872
});
18591873

readme.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,9 @@ Yes, you can customize it with Elementor, but also with Gutenberg, Divi, Beaver
152152

153153
== Changelog ==
154154

155-
= 1.2.54 - 2026-TBD =
155+
= 1.2.54 - 2026-01-TBD =
156156
* Max entries per csv file option in Import/Export setting not showing options - FIXED
157+
* Check nonce while profile image and cover image crop - FIXED/SECURITY
157158

158159
= 1.2.53 - 2026-01-08 =
159160
* Prevent duplicate event handlers in registration form switcher causing multiple AJAX requests - FIXED

0 commit comments

Comments
 (0)