Summary
WP Statistics contains a stored cross-site scripting vulnerability in the utm_campaign parameter because input is not sufficiently sanitized and output is not safely escaped. An unauthenticated attacker may be able to store a script that executes when another user views an affected page, including users with elevated WordPress privileges.
Affected context
The vulnerability affects WordPress sites using the WP Statistics plugin where the public /wp-statistics/v2/hit REST endpoint accepts tracking data and stores campaign-related values. Risk increases when the endpoint's public signature and request handling allow attacker-controlled values to reach persistent storage without complete validation and when those values are later rendered without context-appropriate output encoding.
Exploit preconditions
- Attack surface: Public WordPress REST endpoint used for statistics tracking
- Required access: No authentication may be required when the endpoint and its public request signature are accessible
- Trigger point: A stored tracking value is rendered in a page viewed by a user
- Why exploitation is possible: Request processing permits attacker-controlled campaign data to bypass or evade sanitization, persist in the database, and later reach an HTML or script-capable output context without adequate escaping
Why this happens
The underlying bug is a failure to maintain a trustworthy input and output boundary for the utm_campaign value. Request data is insufficiently validated before storage, while later rendering does not consistently apply context-aware output encoding. This behavior maps to CWE-79: Improper Neutralization of Input During Web Page Generation, commonly called cross-site scripting, because attacker-controlled content is treated as page markup or executable script rather than inert data.
Potential impact
- An attacker could execute arbitrary script in a victim's browser context
- The vulnerability may enable theft of accessible session data or non-HttpOnly tokens
- An attacker could alter page content or perform actions on behalf of a victim
- Administrative users could be targeted, potentially increasing the consequences for the WordPress site
- The issue could undermine user trust and site integrity
General mitigation guidance
Mitigation generally focuses on treating all tracking parameters as untrusted data throughout their lifecycle.
Common defensive patterns include:
- Applying allowlist-based validation appropriate to campaign identifiers before persistence
- Using context-aware output escaping at every rendering location
- Avoiding trust in encoded or alternate request representations when enforcing validation
- Separating telemetry ingestion from page-generation logic where practical
- Restricting endpoint capabilities, rate, and data retention to the minimum required
- Applying least privilege to WordPress users, service accounts, and administrative sessions
- Using a restrictive Content Security Policy as a defense-in-depth control
How teams detect issues like this
Organizations can look for this class of issue through:
- Static analysis rules identifying unsanitized request values written to storage or rendered into HTML
- Code review checks covering REST parameter validation, decoding order, and output contexts
- Tests that submit unexpected markup through every accepted representation of a parameter and verify safe rendering
- Monitoring for unusual requests to public tracking endpoints and anomalous campaign values
- Policy enforcement requiring centralized validation and context-specific escaping for WordPress output
- Automated security review tools that flag source-to-sink paths involving request parameters

