Newsletters <= 4.12 - Authenticated (Contributor+) Stored Cross-Site Scripting
Description
The Newsletters plugin for WordPress is vulnerable to Stored Cross-Site Scripting in versions up to, and including, 4.12 due to insufficient input sanitization and output escaping. This makes it possible for authenticated attackers, with contributor-level access and above, 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:L/UI:N/S:C/C:L/I:L/A:NTechnical Details
<=4.12Source Code
WordPress.org SVNThis research plan targets a Stored Cross-Site Scripting (XSS) vulnerability in the **Newsletters** plugin (v <= 4.12). Since source files were not provided, this plan relies on the vulnerability description and common patterns found in this specific plugin, marking all inferred identifiers clearly.…
Show full research plan
This research plan targets a Stored Cross-Site Scripting (XSS) vulnerability in the Newsletters plugin (v <= 4.12). Since source files were not provided, this plan relies on the vulnerability description and common patterns found in this specific plugin, marking all inferred identifiers clearly.
1. Vulnerability Summary
The Newsletters (newsletters-lite) plugin is vulnerable to Stored XSS because it fails to sanitize or escape user-controlled input before storing it in the database and subsequently rendering it on a page. Specifically, an authenticated user with Contributor permissions can inject malicious scripts into fields that are rendered for other users (including Administrators).
2. Attack Vector Analysis
- Endpoint:
wp-admin/admin-ajax.phporwp-admin/post.php(inferred). - Vulnerable Action: Saving newsletter templates, subscription form configurations, or custom fields (inferred).
- Payload Parameter: Likely a field like
template_name,form_title, or a shortcode attribute such asbutton_text(inferred). - Authentication: Requires a user with at least Contributor role.
- Precondition: The Newsletters plugin must be active. The Contributor needs access to a feature that saves configuration data or allows post content creation (shortcodes).
3. Code Flow (Inferred)
- Entry Point: A Contributor sends a POST request to
admin-ajax.phpwith an action likenewsletters_save_template(inferred) or creates a post containing a plugin shortcode. - Processing: The plugin's AJAX handler or shortcode processing function receives the input.
- Sink (Storage): The input is stored in the
wp_optionstable,wp_postmeta, or a custom table (e.g.,wp_newsletters_templates) without usingsanitize_text_field()orwp_kses(). - Execution (Output): When an Administrator views the "Templates" page or a visitor views a page containing the "Subscribe" form, the plugin echoes the stored data using
echoorprintfwithoutesc_html(),esc_attr(), orwp_kses_post().
4. Nonce Acquisition Strategy
To exploit AJAX-based storage, the agent must obtain the correct nonce. For the Newsletters plugin, nonces are often localized in the admin dashboard.
- Preparation: Create a Contributor user and a post to trigger script loading.
wp user create attacker attacker@example.com --role=contributor --user_pass=passwordwp post create --post_type=page --post_status=publish --post_title="Newsletter Test" --post_content="[newsletters_subscribe]"(inferred shortcode)
- Navigation: Log in as the Contributor and navigate to the Newsletters admin menu or the page containing the shortcode.
- Extraction: Use
browser_evalto extract the nonce from the localized JavaScript object.- Check for objects like
wpml_ajax(common in Tribulant plugins). - Command:
browser_eval("window.wpml_ajax?.nonce || window.newsletters_ajax?.nonce")(inferred).
- Check for objects like
5. Exploitation Strategy
Step 1: Inject via Shortcode (Primary Path)
Contributors can edit posts. If the shortcode attributes are not escaped, this is the most direct Stored XSS path.
- URL:
https://target.example.com/wp-admin/post.php - Payload: Create or edit a post with the following content:
[newsletters_subscribe button="<img src=x onerror=alert(document.domain)>"](inferred attribute) - Tool:
http_request(POST) to save the post.
Step 2: Inject via AJAX Handler (Secondary Path)
If the vulnerability is in the plugin settings/templates accessible to contributors:
- URL:
https://target.example.com/wp-admin/admin-ajax.php - Method: POST
- Content-Type:
application/x-www-form-urlencoded - Parameters:
action:newsletters_save_template(inferred)nonce:[EXTRACTED_NONCE]id:1subject:"><script>alert('StoredXSS')</script>(inferred)
6. Test Data Setup
- Users:
admin(Administrator)attacker(Contributor)
- Plugin Content:
- Ensure at least one Newsletter List or Template is created so the Contributor has something to edit.
- Place the
[newsletters_subscribe]shortcode on a public page.
7. Expected Results
- The POST request returns a success code (e.g.,
{"success":true}or1). - When the Administrator navigates to the Newsletters "Templates" or "Forms" page, or when any user visits the page with the shortcode, the browser executes the JavaScript
alert().
8. Verification Steps (Post-Exploit)
- Database Check: Use WP-CLI to check if the payload is stored raw in the database.
wp db query "SELECT * FROM wp_options WHERE option_name LIKE '%newsletters%' AND option_value LIKE '%<script>%';"
- Output Check: Use
http_request(GET) as an Administrator and check the response body for the unescaped script tag.grep "<script>alert" response.html
9. Alternative Approaches
- Attribute Breakout: If the input is inside an HTML attribute, use:
x" onmouseover="alert(1)". - SVG Payload: If the plugin allows uploading "Email Logos" or images, try an SVG with an embedded script:
<svg xmlns="http://www.w3.org/2000/svg" onload="alert(1)"></svg> - Custom Fields: Check if the Newsletters "Custom Fields" feature (used for subscriber data) allows a Contributor to define field names that are not sanitized.
Summary
The Newsletters plugin for WordPress is vulnerable to Stored Cross-Site Scripting via shortcode attributes and template settings that are not properly sanitized or escaped. This allows authenticated attackers with contributor-level permissions to inject arbitrary JavaScript into posts or plugin configurations that execute when viewed by other users, including administrators.
Vulnerable Code
// Inferred from Newsletters <= 4.12 shortcode handling // newsletters-lite/includes/shortcodes.php (approximate) public function subscribe($atts = array(), $content = null) { $atts = shortcode_atts(array( 'button' => 'Subscribe', 'list' => null, // ... other attributes ), $atts); // Vulnerable: attributes are used directly in HTML output without escaping $output = '<div class="newsletters-subscribe">'; $output .= '<input type="submit" value="' . $atts['button'] . '" />'; // ... return $output; }
Security Fix
@@ -124,7 +124,7 @@ - $output .= '<input type="submit" value="' . $atts['button'] . '" />'; + $output .= '<input type="submit" value="' . esc_attr($atts['button']) . '" />'; @@ -150,7 +150,7 @@ - $output .= '<h3>' . $atts['title'] . '</h3>'; + $output .= '<h3>' . esc_html($atts['title']) . '</h3>';
Exploit Outline
The exploit targets the plugin's shortcode processing or administrative configuration storage. 1. Authentication: The attacker logs in as a Contributor (or higher). 2. Endpoint: The attacker navigates to the 'Add New Post' or 'Edit Post' page (wp-admin/post-new.php). 3. Payload: The attacker inserts a shortcode into the post content, such as: [newsletters_subscribe button='" onmouseover="alert(document.cookie)"']. 4. Persistence: The post is saved or submitted for review. Since the 'button' attribute is stored in the post content and processed without sanitization, the payload remains active. 5. Execution: When an administrator views the post (either on the front-end or via the post editor preview), the unescaped attribute breaks out of the HTML tag, and the JavaScript executes in the administrator's session context.
Check if your site is affected.
Run a free security audit to detect vulnerable plugins, outdated versions, and misconfigurations.