Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/everest-forms/everest-forms.php
+++ b/everest-forms/everest-forms.php
@@ -3,7 +3,7 @@
* Plugin Name: Everest Forms
* Plugin URI: https://everestforms.net/
* Description: Easily create contact form, payment form, conversational form, calculator, multi-step form, registration form, quiz form, survey form etc.
- * Version: 3.6.4
+ * Version: 3.6.5
* Author: Everest Forms
* Author URI: https://everestforms.net/
* Text Domain: everest-forms
--- a/everest-forms/includes/RestApi/controllers/version1/class-evf-entry-submission.php
+++ b/everest-forms/includes/RestApi/controllers/version1/class-evf-entry-submission.php
@@ -176,7 +176,7 @@
}
if ( 'wysiwyg' === $field_type ) {
$form_fields[ $field_id ]['value'] = wp_strip_all_tags( $field_value );
- $form_fields[ $field_id ]['value_raw'] = $field_value;
+ $form_fields[ $field_id ]['value_raw'] = evf_sanitize_wysiwyg( $field_value );
}
--- a/everest-forms/includes/RestApi/controllers/version1/class-evf-plugin-status.php
+++ b/everest-forms/includes/RestApi/controllers/version1/class-evf-plugin-status.php
@@ -52,7 +52,7 @@
array(
'methods' => 'POST',
'callback' => array( $this, 'plugin_activate' ),
- 'permission_callback' => array( $this, 'check_admin_permissions' ),
+ 'permission_callback' => array( $this, 'check_plugin_management_permissions' ),
)
);
register_rest_route(
@@ -285,9 +285,20 @@
* @global WP_Filesystem_Base $wp_filesystem Subclass
*/
public static function install_individual_addon( $slug, $plugin, $name, $status ) {
+ // Restrict activation to genuine Everest Forms addons so this endpoint
+ // cannot be used to install or activate arbitrary plugins. Checked first
+ // so rejected slugs return without loading the admin upgrader includes.
+ if ( ! in_array( $slug, EVF_Modules::get_allowed_addon_slugs(), true ) ) {
+ $status['success'] = false;
+ $status['errorCode'] = 'invalid_addon_slug';
+ $status['errorMessage'] = esc_html__( 'The requested module is not a valid Everest Forms addon.', 'everest-forms' );
+ return $status;
+ }
+
require_once ABSPATH . '/wp-admin/includes/file.php';
include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
+
if ( file_exists( WP_PLUGIN_DIR . '/' . $plugin ) ) {
$plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin );
$status['plugin'] = $plugin;
@@ -463,6 +474,33 @@
return new WP_Error(
'rest_forbidden',
esc_html__( 'You are not allowed to access this resource.', 'everest-forms' ),
+ array( 'status' => 403 )
+ );
+ }
+
+ return true;
+ }
+
+ /**
+ * Check whether the request may install or activate addon plugins.
+ *
+ * Installing and activating plugins is an administrator-level action, so the
+ * form-building capabilities are not enough here: the user must be able to
+ * activate plugins, matching the Modules controller. The REST nonce is not
+ * checked explicitly, so that non-cookie authentication (Application
+ * Passwords, OAuth) keeps working; core already enforces the nonce for
+ * cookie-authenticated requests, so CSRF is still covered.
+ *
+ * @since 3.6.5
+ *
+ * @param WP_REST_Request $request Full data about the request.
+ * @return WP_Error|bool
+ */
+ public function check_plugin_management_permissions( $request ) {
+ if ( ! current_user_can( 'activate_plugins' ) ) {
+ return new WP_Error(
+ 'rest_forbidden',
+ esc_html__( 'You are not allowed to access this resource.', 'everest-forms' ),
array( 'status' => 403 )
);
}
--- a/everest-forms/includes/admin/class-evf-admin-menus.php
+++ b/everest-forms/includes/admin/class-evf-admin-menus.php
@@ -339,13 +339,13 @@
EVF_Admin_Settings::save();
}
- // Add any posted messages.
+ // Add any posted messages. These come from the URL, so they are plain text only — never markup.
if ( ! empty( $_GET['evf_error'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
- EVF_Admin_Settings::add_error( wp_kses_post( wp_unslash( $_GET['evf_error'] ) ) ); // phpcs:ignore WordPress.Security.NonceVerification
+ EVF_Admin_Settings::add_error( sanitize_text_field( wp_unslash( $_GET['evf_error'] ) ) ); // phpcs:ignore WordPress.Security.NonceVerification
}
if ( ! empty( $_GET['evf_message'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
- EVF_Admin_Settings::add_message( wp_kses_post( wp_unslash( $_GET['evf_message'] ) ) ); // phpcs:ignore WordPress.Security.NonceVerification
+ EVF_Admin_Settings::add_message( sanitize_text_field( wp_unslash( $_GET['evf_message'] ) ) ); // phpcs:ignore WordPress.Security.NonceVerification
}
do_action( 'everest_forms_settings_page_init' );
--- a/everest-forms/includes/admin/class-evf-admin-settings.php
+++ b/everest-forms/includes/admin/class-evf-admin-settings.php
@@ -186,7 +186,7 @@
public static function show_messages() {
if ( count( self::$errors ) > 0 ) {
foreach ( self::$errors as $error ) {
- echo '<div id="message" class="error inline"><p><strong>' . wp_kses_post( $error ) . '</strong></p></div>';
+ echo '<div id="message" class="error inline"><p><strong>' . esc_html( $error ) . '</strong></p></div>';
}
} elseif ( count( self::$messages ) > 0 ) {
foreach ( self::$messages as $message ) {
--- a/everest-forms/includes/admin/views/html-admin-page-entries-view.php
+++ b/everest-forms/includes/admin/views/html-admin-page-entries-view.php
@@ -228,7 +228,10 @@
);
$meta_field_type = isset( $field_type_by_meta_key[ $meta_key ] ) ? $field_type_by_meta_key[ $meta_key ] : '';
if ( is_string( $field_value ) && in_array( $meta_field_type, $allow_html_types, true ) ) {
- echo wp_kses_post( $field_value );
+ // WYSIWYG is raw visitor markup, so it takes the restricted allowlist that drops
+ // class/id/data-*. Other HTML types here (repeater) build their own trusted markup
+ // with their submitted values already escaped inside, so they keep wp_kses_post().
+ echo 'wysiwyg' === $meta_field_type ? evf_sanitize_wysiwyg( $field_value ) : wp_kses_post( $field_value ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Both branches escape through wp_kses().
} elseif ( in_array( $meta_field_type, array( 'file-upload', 'image-upload', 'signature', 'color', 'rating', 'country', 'likert', 'checkbox', 'radio', 'payment-checkbox' ), true ) ) {
echo nl2br( make_clickable( $field_value ) );
} else {
--- a/everest-forms/includes/class-everest-forms.php
+++ b/everest-forms/includes/class-everest-forms.php
@@ -23,7 +23,7 @@
*
* @var string
*/
- public $version = '3.6.4';
+ public $version = '3.6.5';
/**
* The single instance of the class.
--- a/everest-forms/includes/class-evf-form-task.php
+++ b/everest-forms/includes/class-evf-form-task.php
@@ -779,12 +779,20 @@
if ( is_array( $decoded_coupons ) ) {
foreach ( $decoded_coupons as $coupon ) {
$field_id = isset( $coupon['field_id'] ) ? $coupon['field_id'] : '';
- if ( ! empty( $field_id ) && isset( $this->form_fields[ $field_id ] ) ) {
- if ( ! is_array( $this->form_fields[ $field_id ]['value'] ) ) {
- $this->form_fields[ $field_id ]['value'] = array();
- }
- $this->form_fields[ $field_id ]['value'][] = $coupon;
+
+ if (
+ empty( $field_id )
+ || ! isset( $this->form_fields[ $field_id ] )
+ || ! isset( $this->form_data['form_fields'][ $field_id ]['type'] )
+ || 'payment-coupon' !== $this->form_data['form_fields'][ $field_id ]['type']
+ ) {
+ continue;
}
+
+ if ( ! is_array( $this->form_fields[ $field_id ]['value'] ) ) {
+ $this->form_fields[ $field_id ]['value'] = array();
+ }
+ $this->form_fields[ $field_id ]['value'][] = $coupon;
}
}
}
@@ -2291,7 +2299,18 @@
$uploads = wp_upload_dir();
$base_dir = realpath( $uploads['basedir'] );
- $everest_forms_dir = $base_dir ? realpath( $base_dir . '/everest_forms_uploads' ) : false;
+ $everest_forms_dir = $base_dir ? $base_dir . '/everest_forms_uploads' : false;
+
+ if ( ! $everest_forms_dir ) {
+ return;
+ }
+
+ // This form's own upload and signature directories. Deletions are confined to
+ // these, so a stored value can never reach another form's files or the shared
+ // everest_forms_uploads root (for example its .htaccess).
+ $form_post = get_post( $form_id );
+ $form_folder = $form_post ? $everest_forms_dir . '/' . absint( $form_id ) . '-' . wp_hash( $form_id . $form_post->post_date ) : false;
+ $signature_dir = $everest_forms_dir . '/' . absint( $form_id ) . '/signature';
foreach ( $get_entry->meta as $meta_key => $meta_value ) {
if ( empty( $meta_value ) ) {
@@ -2300,9 +2319,11 @@
$field_type = isset( $field_types[ $meta_key ] ) ? $field_types[ $meta_key ] : '';
- if ( preg_match( '/signature_/', $meta_key ) || $field_type === 'signature' ) {
- $this->safe_delete_file( $meta_value, $base_dir );
- } elseif ( 'file-upload' === $field_type || 'image-upload' === $field_type ) {
+ // Only a field actually configured as a signature holds a stored file path; the
+ // meta key alone is not trusted, because a text field value is attacker-controlled.
+ if ( 'signature' === $field_type ) {
+ $this->safe_delete_file( $meta_value, $signature_dir );
+ } elseif ( $form_folder && ( 'file-upload' === $field_type || 'image-upload' === $field_type ) ) {
$files = explode( "n", $meta_value );
foreach ( $files as $file ) {
$path_from_url = wp_parse_url( $file, PHP_URL_PATH );
@@ -2316,7 +2337,7 @@
$path_from_url
);
- $this->safe_delete_file( $uploaded_file, $base_dir );
+ $this->safe_delete_file( $uploaded_file, $form_folder );
}
}
}
@@ -2352,22 +2373,38 @@
}
/**
- * Securely delete a file with path validation
+ * Securely delete a file, confined to a specific directory.
*
- * @param string $path File path to delete
- * @param string $allowed_base Base directory path (must be realpath result)
+ * The resolved file must be a regular file located inside $allowed_dir; anything
+ * resolving outside of it (via traversal, symlink or a sibling "uploads-*" folder)
+ * is ignored rather than deleted.
+ *
+ * @param string $path File path to delete.
+ * @param string $allowed_dir Directory the file must be inside of.
*/
- private function safe_delete_file( $path, $allowed_base ) {
- if ( ! $allowed_base || empty( $path ) ) {
+ private function safe_delete_file( $path, $allowed_dir ) {
+ if ( empty( $path ) || ! is_string( $path ) || empty( $allowed_dir ) ) {
return;
}
- $normalized_path = wp_normalize_path( $path );
- $resolved_path = realpath( $normalized_path );
- // Validate path is within allowed directory
- if ( $resolved_path && strpos( $resolved_path, $allowed_base ) === 0 ) {
- if ( is_file( $resolved_path ) ) {
- wp_delete_file( $resolved_path );
- }
+
+ // Reject null-byte poisoning before touching the filesystem.
+ if ( false !== strpos( $path, "