CVE-2021-24892 (published 2021-11-23T20:15Z)

Insecure Direct Object Reference in edit function of Advanced Forms (Free & Pro) before 1.6.9 allows authenticated remote attacker to change arbitrary user's email address and request for reset password, which could lead to take over of WordPress's administrator account. To exploit this vulnerability, an attacker must register to obtain a valid WordPress's user and use such user to authenticate with WordPress in order to exploit the vulnerable edit function.

Severity: MEDIUM
CVSS v2 base score: 6.5 (AV:N/AC:L/Au:S/C:P/I:P/A:P)
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: CWE-639
cwe_name: Authorization Bypass Through User-Controlled Key
description: The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.
extended_description: 
            Retrieval of a user record occurs in the system based on some key value that is under user control. The key would typically identify a user-related record stored in the system and would be used to lookup that record for presentation to the user. It is likely that an attacker would have to be an authenticated user in the system. However, the authorization process would not properly check the data access operation to ensure that the authenticated user performing the operation has sufficient entitlements to perform the requested data access, hence bypassing any other authorization checks present in the system.
            For example, attackers can look at places where user specific data is retrieved (e.g. search screens) and determine whether the key for the item being looked up is controllable externally. The key may be a hidden field in the HTML form field, might be passed as a URL parameter or as an unencrypted cookie variable, then in each of these cases it will be possible to tamper with the key value.
            One manifestation of this weakness is when a system uses sequential or otherwise easily-guessable session IDs that would allow one user to easily switch to another user's session and read/modify their data.
         
         

Fix information:
repo_url: https://github.com/advancedforms/advanced-forms
commit_details: repo_url: https://github.com/advancedforms/advanced-forms
author: fabianlindfors
author_date: 2020-06-27 01:10:50+02:00
msg: Added form nonce with arguments

This fixes a security issue where arguments could be edited client-side.
repository: repo_url: https://github.com/advancedforms/advanced-forms
repo_name: advancedforms/advanced-forms
description: WordPress plugin to create forms using Advanced Custom Fields
repo_language: PHP
owner: advancedforms
file_changes: filename: forms-rendering.php
change_type: ModificationType.MODIFY
diff: @@ -298,13 +298,20 @@ class AF_Core_Forms_Rendering {
     // Hidden fields to identify form
     echo '<div class="acf-hidden">';
 
-      $nonce = wp_create_nonce( 'acf_nonce' );
-      echo sprintf( '<input type="hidden" name="_acfnonce" value="%s">', $nonce );
-      echo sprintf( '<input type="hidden" name="nonce" value="%s">', $nonce );
+      $acf_nonce = wp_create_nonce( 'acf_nonce' );
+      echo sprintf( '<input type="hidden" name="_acfnonce" value="%s">', $acf_nonce );
+      echo sprintf( '<input type="hidden" name="nonce" value="%s">', $acf_nonce );
     
       echo sprintf( '<input type="hidden" name="af_form" value="%s">', $form['key'] );
-      echo sprintf( '<input type="hidden" name="af_form_args" value="%s">', base64_encode( json_encode( $args ) ) );
-      echo sprintf( '<input type="hidden" name="_acf_form" value="%s">', base64_encode( json_encode( $args ) ) );
+
+      $encoded_args = base64_encode( json_encode( $args ) );
+      echo sprintf( '<input type="hidden" name="af_form_args" value="%s">', $encoded_args );
+      echo sprintf( '<input type="hidden" name="_acf_form" value="%s">', $encoded_args );
+
+      // Add nonce to ensure arguments can't be altered.
+      $hashed_args = hash( 'sha256', $encoded_args );
+      $nonce = wp_create_nonce( sprintf( 'af_submission_%s_%s', $form['key'], $hashed_args ) );
+      echo sprintf( '<input type="hidden" name="af_form_nonce" value="%s">', $nonce );
 
       // Add honeypot field that is not visible to users.
       // Bots should hopefully fill this in allowing them to be detected.

programming_language: PHP
filename: forms-submissions.php
change_type: ModificationType.MODIFY
diff: @@ -173,7 +173,17 @@ class AF_Core_Forms_Submissions {
     }
 
     // Retrieve the args used to display the form
-    $args = json_decode( base64_decode( $_POST['af_form_args'] ), true );
+    $encoded_args = $_POST['af_form_args'];
+    $args = json_decode( base64_decode( $encoded_args ), true );
+
+    // Verify nonce
+    $nonce = $_POST['af_form_nonce'];
+    $hashed_args = hash( 'sha256', $encoded_args );
+    $nonce_value = sprintf( 'af_submission_%s_%s', $form['key'], $hashed_args );
+    if ( ! wp_verify_nonce( $nonce, $nonce_value ) ) {
+      wp_die( 'Invalid form nonce' );
+      exit;
+    }
 
     // Retrieve all form fields and their values
     $fields = array();

programming_language: PHP