Skip to content

Commit dea594e

Browse files
authored
UR-4797 Fix - Email confirmation workflow bypassed on profile update (#1383)
* UR-4797 Fix - Email confirmation workflow bypassed on profile update * UR-4797 Fix - Derive is_admin_user server-side instead of trusting $_POST $_POST['is_admin_user'] is client-supplied and spoofable - adding it to a normal profile save request skips email confirmation entirely. current_user_can('edit_user', $user_id) a few lines above already proves whether the actor may manage $user_id, so deriving is_admin_user from that (user_id !== current user) closes the gap without changing any downstream logic.
1 parent e276131 commit dea594e

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

includes/class-ur-ajax.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,9 @@ public static function update_profile_details() {
288288
)
289289
);
290290
}
291-
292-
$is_admin_user = $_POST['is_admin_user'] ?? false;
291+
292+
// Server-derived, not client-supplied - avoids a spoofable $_POST flag.
293+
$is_admin_user = $user_id !== get_current_user_id();
293294
list( $profile, $single_field ) = urm_process_profile_fields( $profile, $single_field, $form_data, $form_id, $user_id, $is_admin_user );
294295
$user = get_userdata( $user_id );
295296

@@ -316,7 +317,7 @@ public static function update_profile_details() {
316317
'email' => ! empty( $single_field['user_registration_user_email'] ) ? $single_field['user_registration_user_email'] : '',
317318
);
318319

319-
if ( $email_updated && ! is_admin() ) {
320+
if ( $email_updated && ! $is_admin_user ) {
320321
UR_Form_Handler::send_confirmation_email( $user, $pending_email, $form_id );
321322
$response['oldUserEmail'] = $user->user_email;
322323
/* translators: %s : user email */
@@ -344,7 +345,7 @@ public static function update_profile_details() {
344345
);
345346
}
346347

347-
if ( is_admin() && ! empty( $pending_email ) ) {
348+
if ( $is_admin_user && ! empty( $pending_email ) ) {
348349
wp_update_user(
349350
array(
350351
'ID' => $user_id,

0 commit comments

Comments
 (0)