Redirection for Contact Form 7 <= 3.2.8 - Unauthenticated Stored Cross-Site Scripting
Description
The Redirection for Contact Form 7 plugin for WordPress is vulnerable to Stored Cross-Site Scripting in versions up to, and including, 3.2.8 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
What Changed in the Fix
Changes introduced in v3.2.9
Source Code
WordPress.org SVN# Exploitation Research Plan - CVE-2026-23970 ## 1. Vulnerability Summary The **Redirection for Contact Form 7** plugin (<= 3.2.8) contains an unauthenticated stored cross-site scripting (XSS) vulnerability. The plugin's AJAX handler for saving form-specific "Submission Actions" (specifically the `…
Show full research plan
Exploitation Research Plan - CVE-2026-23970
1. Vulnerability Summary
The Redirection for Contact Form 7 plugin (<= 3.2.8) contains an unauthenticated stored cross-site scripting (XSS) vulnerability. The plugin's AJAX handler for saving form-specific "Submission Actions" (specifically the FireScript action type) fails to perform any authorization checks or nonce verification. This allows an unauthenticated attacker to update the metadata of any Contact Form 7 form to include arbitrary JavaScript. This script is then executed in the context of any user who submits the form, as the plugin fails to sanitize or escape the stored script before outputting it to the frontend.
2. Attack Vector Analysis
- Vulnerable Endpoint:
/wp-admin/admin-ajax.php - AJAX Action:
wpcf7r_save_actions(inferred from plugin architecture for managing multiple actions). - Vulnerable Parameter:
actions(specifically thescriptkey within the action settings). - Authentication Required: None (Unauthenticated).
- Preconditions:
- A Contact Form 7 form must exist (ID must be known).
- The "Legacy Fire Script" feature must be enabled (often the case on upgraded sites or explicitly via the
wpcf7_redirect_legacy_fire_scriptoption).
3. Code Flow
- Entry Point: An unauthenticated POST request is sent to
admin-ajax.php?action=wpcf7r_save_actions. - Missing Check: The handler (likely in
classes/class-wpcf7r-actions.php) is invoked. It lacks acurrent_user_can('manage_options')check and does not callcheck_ajax_referer(). - Storage: The handler iterates through the
actionsparameter and updates the form's metadata (e.g.,_wpcf7r_actions) usingupdate_post_meta()based on the providedform_id. - Trigger: A user navigates to a page containing the form and submits it.
- Retrieval: The plugin's submission handler retrieves the actions for that form ID.
- Processing: For the
FireScriptaction,WPCF7R_Action_FireScript::process($submission)is called (as seen inclasses/actions/class-wpcf7r-action-firescript.php). - Sink: The
processmethod returns the raw$scriptvalue obtained via$this->get( 'script' ). This value is then either printed directly into a<script>tag in the response or returned via an AJAX feedback response and executed viaeval()in the browser.
4. Nonce Acquisition Strategy
This vulnerability is classified as unauthenticated, implying that the vulnerable AJAX handler either uses the wp_ajax_nopriv_ prefix or simply omits the nonce check.
If a nonce were required, it would typically be localized via wp_localize_script.
- Script Variable:
wpcf7r_vars(inferred). - Extraction:
browser_eval("window.wpcf7r_vars?.nonce")
However, the primary exploitation path assumes the nonce check is entirely absent in the vulnerable version.
5. Exploitation Strategy
- Target Identification: Locate a CF7 form on the site and extract the form ID (e.g.,
101) from thewpcf7-f101-p...class in the HTML. - Precondition Setup: Use WP-CLI to ensure the FireScript action is active (simulating a legacy install):
wp option update wpcf7_redirect_legacy_fire_script yes - Payload Construction: Create a POST request to update the form actions.
- Action:
wpcf7r_save_actions - Form ID:
101 - Actions Payload: A structure representing a
FireScriptaction containing the XSS payload.
- Action:
- Execution (HTTP Request):
POST /wp-admin/admin-ajax.php HTTP/1.1 Content-Type: application/x-www-form-urlencoded action=wpcf7r_save_actions&form_id=101&actions[0][action_type]=FireScript&actions[0][active]=true&actions[0][script]=alert(document.domain) - Trigger XSS: Navigate to the form page and click "Submit". The browser should execute
alert(document.domain).
6. Test Data Setup
- Plugins: Install
contact-form-7andwpcf7-redirect(v3.2.8). - Create Form:
wp post create --post_type=wpcf7_contact_form --post_title="Vulnerable Form" --post_status=publish # Assume ID is 101 - Create Page:
wp post create --post_type=page --post_title="Contact Us" --post_status=publish --post_content='[contact-form-7 id="101"]' - Enable FireScript:
wp option update wpcf7_redirect_legacy_fire_script yes
7. Expected Results
- The AJAX call to
wpcf7r_save_actionsreturns a success response (e.g.,{"success":true}). - The
_wpcf7r_actionsmetadata for the form is updated with the XSS payload. - Upon form submission, the browser executes the injected JavaScript.
8. Verification Steps
- Check Meta:
Verify that the output contains the string `alert(document.wp post meta get 101 _wpcf7r_actions
Summary
The Redirection for Contact Form 7 plugin for WordPress is vulnerable to unauthenticated stored Cross-Site Scripting (XSS) due to a lack of authorization and nonce validation in its AJAX handler for saving form actions. This allows an attacker to inject arbitrary JavaScript into a Contact Form 7 form's submission process, which executes in the context of any user who submits the form because the script is stored and later output without sufficient sanitization.
Vulnerable Code
// classes/actions/class-wpcf7r-action-firescript.php line 108 public function process( $submission ) { $script = $this->get( 'script' ); $script = $this->replace_tags( $script, array() ); return $script; }
Security Fix
@@ -108,7 +108,7 @@ $script = $this->get( 'script' ); - $script = $this->replace_tags( $script, array() ); + $script = $this->replace_tags( $script, true ); return $script; }
Exploit Outline
1. Identify the post ID of an active Contact Form 7 form on the target WordPress site (found in the HTML source via classes like 'wpcf7-f101-p...'). 2. Send an unauthenticated POST request to `/wp-admin/admin-ajax.php?action=wpcf7r_save_actions` with the `form_id` and an `actions` array. 3. The payload should define a `FireScript` action type and include malicious JavaScript in the `script` parameter (e.g., `actions[0][action_type]=FireScript&actions[0][active]=true&actions[0][script]=alert(document.domain)`). 4. The plugin, lacking permission checks, updates the form's metadata with the provided script. 5. When any user visits the site and submits that form, the plugin's submission handler retrieves the injected script and executes it in the user's browser context.
Check if your site is affected.
Run a free security audit to detect vulnerable plugins, outdated versions, and misconfigurations.