WPAdverts – Classifieds Plugin <= 2.3.1 - Unauthenticated Stored Cross-Site Scripting
Description
The WPAdverts – Classifieds Plugin plugin for WordPress is vulnerable to Stored Cross-Site Scripting in versions up to, and including, 2.3.1 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.2
Source Code
WordPress.org SVN# Exploitation Research Plan: CVE-2026-57366 (WPAdverts Stored XSS) ## 1. Vulnerability Summary The **WPAdverts – Classifieds Plugin** (versions <= 2.3.1) is vulnerable to **unauthenticated stored cross-site scripting (XSS)**. The vulnerability exists within the "Contact Form" add-on, specifically …
Show full research plan
Exploitation Research Plan: CVE-2026-57366 (WPAdverts Stored XSS)
1. Vulnerability Summary
The WPAdverts – Classifieds Plugin (versions <= 2.3.1) is vulnerable to unauthenticated stored cross-site scripting (XSS). The vulnerability exists within the "Contact Form" add-on, specifically in how it renders an advertiser's phone number when the "Reveal phone number on click" setting is enabled.
In addons/contact-form/contact-form.php, the function adext_contact_form() retrieves the adverts_phone meta-value and splits it into two parts. The second part ($ph2) is echoed directly into the data-partial attribute of an <a> tag without any sanitization or escaping (e.g., esc_attr()). An unauthenticated attacker can submit a new advertisement with a malicious phone number containing a script payload, which will execute in the context of any user (including administrators) viewing the advertisement.
2. Attack Vector Analysis
- Entry Point: The advertisement submission form, typically rendered via the
[adverts_add]shortcode. - Vulnerable Parameter:
adverts_phone(submitted viaPOST). - Sink:
addons/contact-form/contact-form.php, line 78 (in version 2.3.1). - Authentication: Unauthenticated (if anonymous posting is enabled, which is a common configuration).
- Preconditions:
- The "Contact Form" add-on must be active.
- The "Reveal phone number on click" setting must be enabled.
- The
[adverts_add]shortcode must be accessible to the attacker.
3. Code Flow
- Submission:
- Attacker navigates to the page containing the
[adverts_add]shortcode. - Attacker submits the form. The
Adverts_Formclass binds the$_POSTdata (processed viaadverts_request(), which only appliesstripslashes_deep). - The data is saved to the database via
update_post_meta( $post_id, 'adverts_phone', $payload ).
- Attacker navigates to the page containing the
- Rendering:
- A user visits the newly created advertisement page.
adext_contact_form( $post_id )is triggered by theadverts_tpl_single_bottomaction hook.$phone = get_post_meta( $post_id, "adverts_phone", true );$ph2 = substr( $phone, 3 );(Extracts everything after the first 3 characters).- Sink:
echo $ph2inside thedata-partialattribute:<a href="#" class="wpadverts-reveal-final" data-partial="<?php echo $ph2 ?>" style="display: none"></a>
4. Nonce Acquisition Strategy
The [adverts_add] form uses a "checksum" system for integrity rather than standard WordPress nonces for the initial form render. These values are required for successful form submission.
- Shortcode: The plugin uses
[adverts_add]. - Setup: Use
wp post createto ensure a page with this shortcode exists. - Extraction:
- Use
browser_navigateto visit the[adverts_add]page. - Use
browser_evalto extract the values from the hidden inputs:_wpadverts_checksum_wpadverts_checksum_nonce_post_id_nonce
- Alternatively, standard browser-based form filling (
browser_type) will handle these automatically.
- Use
5. Exploitation Strategy
- Prepare Environment: Enable the Contact Form add-on and configure the "reveal" setting.
- Submit Payload:
- Navigate to the
[adverts_add]page. - Fill out the required fields:
post_title: "Vulnerable Ad"post_content: "This is a test ad."adverts_person: "Attacker"adverts_email: "attacker@example.com"adverts_phone:555"><script>alert(document.domain)</script>
- Click "Preview" and then "Finish" (or submit the form directly if steps are concatenated).
- Navigate to the
- Trigger XSS:
- Identify the URL of the created Ad (usually returned in the final step or found via
wp post list). - Navigate to the Ad URL.
- The script will execute immediately on page load because the
<a>tag with the payload is rendered in the HTML.
- Identify the URL of the created Ad (usually returned in the final step or found via
6. Test Data Setup
# 1. Enable the Contact Form add-on (usually enabled by adding to active_modules)
# This assumes the plugin handles module loading via this option
wp option update adverts_active_modules '["contact-form"]' --format=json
# 2. Configure Contact Form to reveal phone on click
wp option update adext_contact_form_config '{"show_phone":"1","reveal_on_click":"1","from_name":"","from_email":""}' --format=json
# 3. Ensure anonymous posting is allowed in main config
# (Value depends on plugin version, typically ads_list_default__allow_anonymous)
wp option get adverts_config --format=json > config.json
# Modify config.json to ensure anonymous posting is enabled, then:
# wp option update adverts_config --format=json < config.json
# 4. Create a page for the
Summary
The WPAdverts plugin is vulnerable to unauthenticated stored Cross-Site Scripting via the advertisement submission form. An attacker can inject malicious scripts into the phone number field which are then executed in the browser of any user viewing the advertisement when the 'Reveal phone number on click' feature is enabled.
Vulnerable Code
// addons/contact-form/contact-form.php line 52 $phone = get_post_meta( $post_id, "adverts_phone", true ); if( $phone ) { $ph1 = substr( $phone, 0, 3 ); $ph2 = substr( $phone, 3 ); } // ... lines 73-78 <a href="#" class="wpadverts-reveal-button" style="font-weight: normal; font-size:0.9rem"><?php esc_html_e( "show phone", "wpadverts" ) ?></a> </strong> <a href="#" class="wpadverts-reveal-final" data-partial="<?php echo $ph2 ?>" style="display: none"></a>
Security Fix
@@ -75,7 +75,7 @@ ... <a href="#" class="wpadverts-reveal-button" style="font-weight: normal; font-size:0.9rem"><?php esc_html_e( "show phone", "wpadverts" ) ?></a> </strong> - <a href="#" class="wpadverts-reveal-final" data-partial="<?php echo $ph2 ?>" style="display: none"></a> + <a href="#" class="wpadverts-reveal-final" data-partial="<?php echo esc_attr( $ph2 ) ?>" style="display: none"></a> <span class="adverts-icon-phone"></span> </span> <?php else: ?>
Exploit Outline
1. Identify the public advertisement submission page containing the [adverts_add] shortcode. 2. Extract the necessary integrity tokens (_wpadverts_checksum and _wpadverts_checksum_nonce) from the hidden form fields. 3. Submit a new advertisement via a POST request, placing the XSS payload in the 'adverts_phone' parameter (e.g., 555\"><script>alert(document.domain)</script>). 4. Ensure the plugin is configured with the 'Contact Form' add-on active and the 'Reveal phone number on click' setting enabled. 5. Navigate to the permalink of the newly created advertisement. The script will execute automatically because the second part of the phone number payload is rendered directly into a data-attribute without proper attribute escaping.
Check if your site is affected.
Run a free security audit to detect vulnerable plugins, outdated versions, and misconfigurations.