CVE-2026-42643

Image Widget <= 4.4.11 - Authenticated (Author+) Stored Cross-Site Scripting

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

Description

The Image Widget plugin for WordPress is vulnerable to Stored Cross-Site Scripting in versions up to, and including, 4.4.11 due to insufficient input sanitization and output escaping. This makes it possible for authenticated attackers, with author-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: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<=4.4.11
PublishedMarch 17, 2026
Last updatedMay 7, 2026
Affected pluginimage-widget

What Changed in the Fix

Changes introduced in v4.4.12

Loading patch diff...

Source Code

WordPress.org SVN
Research Plan
Unverified

This research plan targets a Stored Cross-Site Scripting (XSS) vulnerability in the **Image Widget** plugin (<= 4.4.11). The vulnerability allows an authenticated user with **Author** privileges to inject malicious scripts into the site via media metadata, which is subsequently rendered by the widge…

Show full research plan

This research plan targets a Stored Cross-Site Scripting (XSS) vulnerability in the Image Widget plugin (<= 4.4.11). The vulnerability allows an authenticated user with Author privileges to inject malicious scripts into the site via media metadata, which is subsequently rendered by the widget without proper escaping.


1. Vulnerability Summary

  • Vulnerability: Authenticated Stored XSS.
  • Location: Tribe_Image_Widget class (main file) and resources/js/image-widget.js.
  • Cause: The plugin fails to sanitize media metadata (Alt Text, Description) when importing it into a widget instance and fails to escape this data during output in both the Admin preview and the Frontend rendering.
  • Role Requirement: Author (or higher). Authors can upload and edit their own media, which serves as the injection vector.

2. Attack Vector Analysis

  • Injection Point: Media Library attachment metadata (Title, Alt Text, or Description).
  • Transport: The metadata is "pulled" into the widget settings via JavaScript (image-widget.js) when an administrator selects an image for the widget.
  • Sink (Admin): The imageWidget.imgHTML() function in image-widget.js appends the alt text directly to an HTML string which is then injected into the DOM using .html().
  • Sink (Frontend): The widget() method in image-widget.php processes the stored fields. If the template (views/widget.php) echoes these fields without escaping, the XSS executes on the frontend.

3. Code Flow

  1. Author Action: Uploads an image and updates its "Alternative Text" to include a breakout payload (e.g., "><img src=x onerror=alert(1)>).
  2. Admin Action: Navigates to wp-admin/widgets.php and adds an "Image Widget".
  3. Selection: Admin clicks "Select Image". The uploader function in image-widget.js opens the WP Media Manager.
  4. Import: Upon selecting the Author's image, render(widget_id, widget_id_string, attachment) is triggered.
  5. Admin Execution (Preview):
    • render calls imgHTML(attachment).
    • imgHTML constructs: img_html += 'alt="' + attachment.alt + '" '; (Vulnerable Sink).
    • $("#" + widget_id_string + 'preview').html(img_html); executes the payload immediately in the Admin's browser.
  6. Persistence: render also populates the widget form: imageWidget.updateInputIfEmpty(..., 'alt', attachment.alt).
  7. Storage: When the Admin clicks "Save", the payload is stored in the widget's instance data in the wp_options table.
  8. Frontend Execution: Tribe_Image_Widget::widget() retrieves the instance data and renders it.

4. Nonce Acquisition Strategy

To inject the payload as an Author, we must update a media attachment. This requires a nonce for the save-attachment AJAX action.

  1. Identify Attachment: Upload an image as an Author and get its ATTACHMENT_ID.
  2. Navigate to Edit Page: Use browser_navigate to wp-admin/post.php?post=ATTACHMENT_ID&action=edit.
  3. Extract Nonce:
    • Use browser_eval("document.querySelector('#_wpnonce').value") to get the nonce from the edit form.
    • Alternatively, look for the wp.media settings in the localized JS.

5. Exploitation Strategy

Step 1: Payload Preparation (As Author)

Upload an image and update its metadata with the payload.

  • Request Type: POST to /wp-admin/admin-ajax.php
  • Parameters:
    • action: save-attachment
    • id: ATTACHMENT_ID
    • nonce: [EXTRACTED_NONCE]
    • changes[image_alt]: "><img src=x onerror=alert(document.domain)>
    • changes[description]: <script>alert('Stored XSS')</script>

Step 2: Trigger Admin Execution

The agent must simulate an Admin selecting the image.

  1. Navigate to wp-admin/widgets.php as Admin.
  2. Add an "Image Widget".
  3. Use browser_click on the "Select Image" button.
  4. Select the Author's image in the Media Library.
  5. Observe: The imgHTML function will execute the alt payload in the widget's preview area.

Step 3: Persistence (Frontend)

  1. Complete the widget setup and click "Save".
  2. Navigate to the site's homepage (or wherever the sidebar is active).
  3. Observe: The payload executes for all visitors.

6. Test Data Setup

  1. User: Create an Author user.
    wp user create attacker attacker@example.com --role=author --user_pass=password
    
  2. Media: Upload an image as the Author.
    wp media import https://wordpress.org/screenshot.png --user=attacker
    
  3. Note ID: Capture the resulting Attachment ID (e.g., 123).

7. Expected Results

  • Admin Side: An alert box should trigger the moment the image is selected in the widget settings due to the alt attribute breakout in image-widget.js.
  • Frontend Side: The page source for the widget will contain the unescaped payload:
    <img ... alt=""><img src=x onerror=alert(document.domain)>" />

8. Verification Steps

  1. Check Database:
    wp option get widget_widget_sp_image
    
    Confirm the payload exists in the serialized widget settings.
  2. Check HTML Output:
    Use http_request to fetch the homepage and grep for the payload in the widget_sp_image container.

9.

Research Findings
Static analysis — not yet PoC-verified

Summary

The Image Widget plugin for WordPress is vulnerable to Authenticated Stored Cross-Site Scripting (XSS) in versions up to 4.4.11. This occurs because the plugin fails to sanitize and escape media metadata such as 'Alternative Text' when importing images into a widget, allowing authors to inject malicious scripts that execute in the context of an administrator or site visitor.

Vulnerable Code

// resources/js/image-widget.js
// Lines 84-93: String concatenation without escaping
		imgHTML : function( attachment ) {
			var img_html = '<img src="' + attachment.url + '" ';
			img_html += 'width="' + attachment.width + '" ';
			img_html += 'height="' + attachment.height + '" ';
			if ( attachment.alt != '' ) {
				img_html += 'alt="' + attachment.alt + '" ';
			}
			img_html += '/>';
			return img_html;
		},

---

// resources/js/image-widget.js
// Line 37: Injection into the DOM via .html()
			$("#" + widget_id_string + 'preview').html(imageWidget.imgHTML( attachment ));

Security Fix

diff -ru /home/deploy/wp-safety.org/data/plugin-versions/image-widget/4.4.11/resources/js/image-widget.js /home/deploy/wp-safety.org/data/plugin-versions/image-widget/4.4.12/resources/js/image-widget.js
--- /home/deploy/wp-safety.org/data/plugin-versions/image-widget/4.4.11/resources/js/image-widget.js	2024-11-20 20:44:02.000000000 +0000
+++ /home/deploy/wp-safety.org/data/plugin-versions/image-widget/4.4.12/resources/js/image-widget.js	2026-04-20 17:32:10.000000000 +0000
@@ -70,13 +70,20 @@
 			}
 		},
 
+		// Escape a string for safe use inside an HTML attribute.
+		escAttr : function( str ) {
+			var div = document.createElement( 'div' );
+			div.appendChild( document.createTextNode( str ) );
+			return div.innerHTML.replace( /"/g, '&quot;' ).replace( /'/g, '&#039;' );
+		},
+
 		// Render html for the image.
 		imgHTML : function( attachment ) {
-			var img_html = '<img src="' + attachment.url + '" ';
-			img_html += 'width="' + attachment.width + '" ';
-			img_html += 'height="' + attachment.height + '" ';
+			var img_html = '<img src="' + imageWidget.escAttr( attachment.url ) + '" ';
+			img_html += 'width="' + imageWidget.escAttr( String( attachment.width ) ) + '" ';
+			img_html += 'height="' + imageWidget.escAttr( String( attachment.height ) ) + '" ';
 			if ( attachment.alt != '' ) {
-				img_html += 'alt="' + attachment.alt + '" ';
+				img_html += 'alt="' + imageWidget.escAttr( attachment.alt ) + '" ';
 			}
 			img_html += '/>';
 			return img_html;

Exploit Outline

1. An authenticated attacker with Author privileges uploads an image to the WordPress Media Library. 2. The attacker modifies the image's 'Alternative Text' or 'Description' metadata to include an XSS payload (e.g., "><img src=x onerror=alert(1)>). 3. An administrator navigates to the 'Widgets' screen (wp-admin/widgets.php) and adds or edits an 'Image Widget'. 4. When the administrator clicks 'Select Image' and chooses the malicious image uploaded by the Author. 5. The plugin's JS function 'imgHTML' constructs an HTML string using the unescaped payload and injects it into the preview area via the jQuery .html() method, triggering the exploit in the admin's session. 6. Upon saving the widget, the payload is persisted and will execute in the browsers of all visitors who view the page containing the widget.

Check if your site is affected.

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