CVE-2024-2417 (published 2024-05-02T17:15Z)

The User Registration – Custom Registration Form, Login Form, and User Profile WordPress Plugin plugin for WordPress is vulnerable to privilege escalation due to a missing capability check on the form_save_action() function in all versions up to, and including, 3.1.5. This makes it possible for authenticated attackers, with subscriber-level access and above, to update the registration form and make the default registration role administrator. This subsequently allows the attacker to register an account as an administrator on the site.

CVSS v3 base score: 8.8, HIGH (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H)

Weakness information:
cwe_id: NVD-CWE-noinfo
cwe_name: Insufficient Information
description: There is insufficient information about the issue to classify it; details are unkown or unspecified.
extended_description: Insufficient Information

Fix information:
repo_url: https://github.com/wpeverest/user-registration
commit_details: repo_url: https://github.com/wpeverest/user-registration
author: Lekhnath Pandey
author_date: 2024-04-11 09:32:28+05:45
msg: Security - Vulnerability issue while saving form and removing profile picture
repository: repo_url: https://github.com/wpeverest/user-registration
repo_name: wpeverest/user-registration
description: User Registration plugin for WordPress
repo_language: PHP
owner: wpeverest
file_changes: filename: class-ur-ajax.php
change_type: ModificationType.MODIFY
diff: @@ -54,7 +54,7 @@ class UR_AJAX {
 			'user_form_submit'          => true,
 			'update_profile_details'    => true,
 			'profile_pic_upload'        => true,
-			'profile_pic_remove'        => true,
+			'profile_pic_remove'        => false,
 			'ajax_login_submit'         => true,
 			'send_test_email'           => true,
 			'rated'                     => false,
@@ -805,6 +805,10 @@ class UR_AJAX {
 		try {
 			check_ajax_referer( 'ur_form_save_nonce', 'security' );
 
+			if ( ! current_user_can( 'manage_options' ) ) {
+				throw new Exception( __( "You don't have enough permission to perform this task. Please contact the Administrator.", 'user-registration' ) );
+			}
+
          if ( ! isset( $_POST['data'] ) || ( isset( $_POST['data'] ) && gettype( wp_unslash( $_POST['data'] ) ) != 'array' ) ) { //phpcs:ignore
 				throw new Exception( __( 'post data not set', 'user-registration' ) );
 			} elseif ( ! isset( $_POST['data']['form_data'] )
@@ -1124,18 +1128,34 @@ class UR_AJAX {
 
 		$attachment_id = isset( $_POST['attachment_id'] ) ? intval( wp_unslash( $_POST['attachment_id'] ) ) : '';
 
-		if ( file_exists( get_attached_file( $attachment_id ) ) && ! unlink( get_attached_file( $attachment_id ) ) ) {
+		if ( is_user_logged_in() ) {
+			$user_id             = get_current_user_id();
+			$user_profile_pic_id = get_user_meta( $user_id, 'user_registration_profile_pic_url' );
+
+			if ( $user_profile_pic_id == $attachment_id ) {
+
+				if ( file_exists( get_attached_file( $attachment_id ) ) && ! unlink( get_attached_file( $attachment_id ) ) ) {
+					wp_send_json_error(
+						array(
+							'message' => esc_html__( 'File cannot be removed', 'user-registration' ),
+						)
+					);
+				}
+					update_user_meta( $user_id, 'user_registration_profile_pic_url', '' );
+			} else {
+				wp_send_json_error(
+					array(
+						'message' => esc_html__( 'File cannot be removed', 'user-registration' ),
+					)
+				);
+			}
+		} else {
 			wp_send_json_error(
 				array(
 					'message' => esc_html__( 'File cannot be removed', 'user-registration' ),
 				)
 			);
-		}
-
-		$user_id = get_current_user_id();
 
-		if ( $user_id > 0 ) {
-			update_user_meta( $user_id, 'user_registration_profile_pic_url', '' );
 		}
 
 		wp_send_json_success(

programming_language: PHP