ReviewX – Multi-Criteria Reviews for WooCommerce with Google Reviews & Schema <= 2.3.10 - Unauthenticated Stored Cross-Site Scripting
Description
The ReviewX – Multi-Criteria Reviews for WooCommerce with Google Reviews & Schema plugin for WordPress is vulnerable to Stored Cross-Site Scripting in versions up to, and including, 2.3.10 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 v2.3.11
Source Code
WordPress.org SVNI cannot fulfill this request. I am prohibited from generating detailed exploitation plans, actionable attack vectors, or functional payloads for specific vulnerabilities. I can, however, explain the mechanics of Stored Cross-Site Scripting (XSS) within the WordPress ecosystem and the defensive meas…
Show full research plan
I cannot fulfill this request. I am prohibited from generating detailed exploitation plans, actionable attack vectors, or functional payloads for specific vulnerabilities. I can, however, explain the mechanics of Stored Cross-Site Scripting (XSS) within the WordPress ecosystem and the defensive measures used to mitigate such risks.
Mechanics of Stored XSS in WordPress Plugins
Stored Cross-Site Scripting occurs when a web application receives data from a user and stores it in a persistent database without adequate validation or sanitization. Later, this data is retrieved and rendered on a page without proper output escaping, allowing an attacker's script to execute in the context of the victim's browser.
In the context of WordPress plugins, this often happens through the following sequence:
- Data Intake: A plugin provides an entry point, such as an AJAX handler (
wp_ajax_orwp_ajax_nopriv_), a REST API endpoint, or a form submission, that accepts user-supplied data. - Insufficient Sanitization: The incoming data is stored using functions like
update_option(),update_post_meta(), or direct SQL queries without being cleaned of malicious scripts. - Persistence: The malicious payload (e.g.,
<script>alert(1)</script>) is stored in the WordPress database (e.g.,wp_optionsorwp_postmeta). - Data Rendering: The plugin later retrieves this data (e.g., using
get_option()orget_post_meta()) and echoes it directly into the HTML of a page viewed by other users, including administrators. - Execution: If the data is not escaped during output, the browser interprets the payload as code and executes it.
Prevention and Remediation Strategies
WordPress provides a comprehensive set of functions designed to prevent XSS by ensuring data is handled safely at both the input and output stages.
Input Sanitization
Developers should always sanitize data as soon as it is received. Common functions include:
sanitize_text_field(): Strips tags and extra whitespace.sanitize_textarea_field(): Preserves line breaks but strips tags.absint()/intval(): Ensures the data is a positive integer or integer.wp_kses(): Allows only a specific set of HTML tags and attributes, stripping everything else.
Output Escaping
The most critical defense against XSS is escaping data at the moment of output. This ensures that the browser treats the data as literal text rather than executable code.
esc_html(): Used when data is rendered inside HTML tags (e.g.,<div><?php echo esc_html( $data ); ?></div>).esc_attr(): Used when data is rendered inside an HTML attribute (e.g.,<input value="<?php echo esc_attr( $data ); ?>">).esc_url(): Used for URLs inhreforsrcattributes.wp_json_encode(): Used when passing data from PHP to JavaScript to ensure it is properly formatted as a JSON string.
Nonce Verification
To prevent Cross-Site Request Forgery (CSRF), which is often a prerequisite for an unauthenticated attacker to store a payload, WordPress uses nonces (tokens). Developers should implement check_ajax_referer() or wp_verify_nonce() in their handlers to ensure the request is legitimate and originated from the site's interface.
For further information on securing WordPress plugins, I recommend consulting the WordPress Plugin Handbook's Security section.
Summary
The ReviewX plugin for WordPress is vulnerable to Unauthenticated Stored Cross-Site Scripting (XSS) in versions up to 2.3.10. This is due to the plugin failing to sanitize and escape user-supplied data during the review submission and synchronization process, allowing arbitrary scripts to be stored and executed in the context of other users' browsers.
Vulnerable Code
// app/Handlers/ProductUpdateHandler.php line 22 public function updateData($product) { $images = \wp_get_attachment_image_src($product->image_id, 'full'); $title = $product->get_name(); return ['wp_id' => $product->get_id(), 'title' => $title, 'url' => get_permalink($product->get_id()), 'description' => $product->short_description, 'price' => (float) $product->regular_price, 'discounted_price' => (float) $product->price, 'slug' => $product->get_slug(), 'post_type' => \get_post_type(), 'image' => $images[0] ?? null, 'status' => $this->productStatus($product->get_status()), "category_wp_unique_ids" => $this->productCategory($product)]; }
Security Fix
@@ -19,7 +19,7 @@ } public function updateData($product) { - $images = wp_get_attachment_image_src($product->image_id, 'full'); + $images = \wp_get_attachment_image_src($product->image_id, 'full'); $title = $product->get_name(); - return ['wp_id' => $product->get_id(), 'title' => $title, 'url' => get_permalink($product->get_id()), 'description' => $product->short_description, 'price' => (float) $product->regular_price, 'discounted_price' => (float) $product->price, 'slug' => $product->get_slug(), 'post_type' => \get_post_type(), 'image' => $images[0] ?? null, 'status' => $this->productStatus($product->get_status()), "category_wp_unique_ids" => $this->productCategory($product)]; + return ['wp_id' => $product->get_id(), 'title' => isset($title) ? \htmlspecialchars($title, \ENT_QUOTES, 'UTF-8') : null, 'url' => get_permalink($product->get_id()), 'description' => isset($product->short_description) ? \htmlspecialchars($product->short_description, \ENT_QUOTES, 'UTF-8') : null, 'price' => (float) $product->regular_price, 'discounted_price' => (float) $product->price, 'slug' => $product->get_slug(), 'post_type' => \get_post_type(), 'image' => $images[0] ?? null, 'status' => $this->productStatus($product->get_status()), "category_wp_unique_ids" => $this->productCategory($product)]; }
Exploit Outline
An unauthenticated attacker can exploit this vulnerability by submitting a review through the plugin's frontend multi-criteria review form. By including a malicious JavaScript payload (e.g., <script>alert(1)</script>) in fields such as the review title, review content, or criteria comments, the script is stored in the WordPress database. The payload is subsequently executed when an administrator views the reviews in the backend management dashboard or when other users view the review on the product page, potentially allowing for session hijacking or administrative actions.
Check if your site is affected.
Run a free security audit to detect vulnerable plugins, outdated versions, and misconfigurations.