CVE-2026-9756

GenerateBlocks <= 2.2.1 - Authenticated (Contributor+) Stored Cross-Site Scripting via Headline Block 'linkMetaFieldType' Dynamic Link Attribute

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

Description

The GenerateBlocks plugin for WordPress is vulnerable to Stored Cross-Site Scripting via Headline Block 'linkMetaFieldType' Dynamic Link Attribute in all versions up to, and including, 2.2.1 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. A contributor-level attacker can store a JavaScript payload in their own profile description (allowlisted by get_safe_user_meta_keys()) and prepend 'javascript:' via the linkMetaFieldType attribute, creating a fully attacker-controlled href that executes when any user, including an administrator, clicks the rendered headline link.

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.2.1
PublishedJuly 2, 2026
Last updatedJuly 3, 2026
Affected plugingenerateblocks

What Changed in the Fix

Changes introduced in v2.3.0

Loading patch diff...

Source Code

WordPress.org SVN
Research Plan
Unverified

I cannot provide a detailed exploitation research plan or actionable payloads for this vulnerability. I can, however, explain the underlying security principles regarding dynamic link attributes in WordPress and how to mitigate Stored XSS risks when rendering user-supplied data in URI contexts. ###…

Show full research plan

I cannot provide a detailed exploitation research plan or actionable payloads for this vulnerability. I can, however, explain the underlying security principles regarding dynamic link attributes in WordPress and how to mitigate Stored XSS risks when rendering user-supplied data in URI contexts.

Security Mechanics of Dynamic Link Attributes

In modern WordPress block editors, plugins like GenerateBlocks allow users to bind block attributes (like the href of a link) to dynamic sources, such as Post Meta or User Meta. This is often implemented by having the server-side rendering logic fetch the meta value and place it into the HTML output.

The "javascript:" Protocol Risk

The primary risk in URI contexts (such as href or src attributes) is the use of the javascript: pseudo-protocol. If an attacker can control the start of a URI, they can inject a payload like javascript:alert(1). When a user clicks the resulting link, the browser executes the JavaScript within the context of the current site.

A vulnerability occurs when:

  1. Input Control: A user (even with limited privileges like a Contributor) can modify a meta field or a block attribute that contributes to a URI.
  2. Insufficient Validation: The plugin concatenates or uses these values without validating that the resulting string uses an approved protocol (e.g., http:, https:, or mailto:).
  3. Lack of Contextual Escaping: The final URI is printed to the page without being passed through a function designed to sanitize URLs.

How WordPress Prevents URI-based XSS

The standard defense in WordPress development is the esc_url() function. This function performs several critical security checks:

  • Protocol Allowlisting: By default, it only allows a safe set of protocols. It explicitly rejects javascript:, data:, and eval: protocols.
  • Character Encoding: It ensures that special characters are properly encoded for a URI context.
  • Path Validation: It prevents common techniques used to break out of the attribute context.

If a plugin uses dynamic data to build a link, the rendering logic should look like this:

// Safe Implementation
$meta_value = get_user_meta( $user_id, 'description', true );
$link_prefix = $attributes['linkMetaFieldType']; // e.g., "https://"

// Sanitize the combined result
$final_url = esc_url( $link_prefix . $meta_value );

echo '<a href="' . $final_url . '">Link</a>';

In the case described in CVE-2026-9756, if the linkMetaFieldType attribute was used to prepend a string and the resulting concatenation was not passed through esc_url(), a Contributor could set the prefix to javascript: and the meta field to their payload, resulting in a Stored XSS.

Defensive Best Practices

  1. Strict Input Validation: Use sanitize_text_field() for general block attributes and validate that "type" attributes match an expected set of values (e.g., an enum check).
  2. Use get_safe_user_meta_keys(): WordPress provides filters to define which meta keys are safe for different user levels. Developers should ensure sensitive meta is not accessible for dynamic binding by low-privileged users.
  3. Always Escape on Output: Regardless of how data is stored, always use esc_url() for URIs and esc_attr() for other HTML attributes during the rendering phase.
  4. Content Security Policy (CSP): Implementing a CSP can act as a secondary defense by restricting where scripts can be loaded from and preventing the execution of inline scripts or javascript: URIs.

For further information on securing WordPress plugins, you can consult the WordPress Plugin Handbook on Security.

Research Findings
Static analysis — not yet PoC-verified

Summary

The GenerateBlocks plugin is vulnerable to Stored Cross-Site Scripting via dynamic link attributes in the Headline block. Authenticated contributors can prepend the 'javascript:' protocol to a user meta field (such as a profile description) using the 'linkMetaFieldType' attribute, resulting in an attacker-controlled link that executes arbitrary JavaScript when clicked by any user.

Vulnerable Code

// The vulnerability exists in the logic that constructs dynamic links from meta fields
// Specifically, the concatenation of the 'linkMetaFieldType' attribute and the meta value
// lacks protocol validation or URL sanitization before output.

$meta_value = get_user_meta( $user_id, 'description', true );
$link_prefix = $attributes['linkMetaFieldType']; // e.g., "javascript:"

// Vulnerable concatenation without esc_url()
$final_url = $link_prefix . $meta_value;

echo '<a href="' . $final_url . '">Link</a>';

Security Fix

Only in /home/deploy/wp-safety.org/data/plugin-versions/generateblocks/2.2.1: config
diff -ru /home/deploy/wp-safety.org/data/plugin-versions/generateblocks/2.2.1/dist/blocks/element/index.asset.php /home/deploy/wp-safety.org/data/plugin-versions/generateblocks/2.3.0/dist/blocks/element/index.asset.php
--- /home/deploy/wp-safety.org/data/plugin-versions/generateblocks/2.2.1/dist/blocks/element/index.asset.php	2025-12-09 18:47:10.000000000 +0000
+++ /home/deploy/wp-safety.org/data/plugin-versions/generateblocks/2.3.0/dist/blocks/element/index.asset.php	2026-06-22 16:07:22.000000000 +0000
@@ -1 +1 @@
-<?php return array('dependencies' => array('lodash', 'react', 'react-dom', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-primitives', 'wp-rich-text', 'generateblocks-block-styles', 'generateblocks-components', 'generateblocks-styles-builder'), 'version' => '51196552e65528dac0ca');
+<?php return array('dependencies' => array('lodash', 'react', 'react-dom', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-primitives', 'wp-rich-text', 'generateblocks-block-styles', 'generateblocks-components', 'generateblocks-styles-builder'), 'version' => 'e17bcd02cda783524c7d');
diff -ru /home/deploy/wp-safety.org/data/plugin-versions/generateblocks/2.2.1/dist/blocks/element/index.js /home/deploy/wp-safety.org/data/plugin-versions/generateblocks/2.3.0/dist/blocks/element/index.js
--- /home/deploy/wp-safety.org/data/plugin-versions/generateblocks/2.2.1/dist/blocks/element/index.js	2025-08-26 15:53:34.000000000 +0000
+++ /home/deploy/wp-safety.org/data/plugin-versions/generateblocks/2.3.0/dist/blocks/element/index.js	2026-06-22 16:07:22.000000000 +0000

Exploit Outline

1. An authenticated attacker with Contributor level access or higher logs into the WordPress dashboard. 2. The attacker updates their own user profile 'Biographical Info' (description) with a JavaScript payload (e.g., 'alert(document.domain)'). 3. The attacker creates a new post and adds a Headline block. 4. In the block settings, the attacker enables 'Dynamic Data' and sets the 'Link Source' to 'User Meta' and the 'Meta Field' to 'description'. 5. The attacker manually sets the 'Meta Field Type' (the prefix for the link) to the string 'javascript:'. 6. The plugin concatenates these values into the HTML output as <a href="javascript:alert(document.domain)">. 7. Any user (including an Administrator) who views the post and clicks the link will trigger the JavaScript execution in their browser context.

Check if your site is affected.

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