Summary
WP Rocket contains a stored cross-site scripting vulnerability caused by insufficient sanitization and output escaping of data submitted through the rocket_beacon AJAX endpoint. An unauthenticated attacker may store malicious script content that executes in the browser whenever a user visits an affected page.
Affected context
The issue affects WordPress sites using WP Rocket versions up to and including 3.21.0.1 when data accepted through the rocket_beacon AJAX endpoint is later rendered in a page without sufficient output encoding. Risk depends on whether the endpoint is reachable without authentication and whether submitted data is persisted and displayed to other users.
Exploit preconditions
- Attack surface: The WP Rocket
rocket_beaconAJAX endpoint - Required access: Typically no authentication, subject to site-specific endpoint controls
- Trigger point: A victim loads a page containing attacker-controlled stored content
- Why exploitation is possible: User-supplied data is insufficiently sanitized before storage or output and is not safely escaped for its rendering context
Why this happens
The underlying bug is a failure to treat externally supplied data as untrusted at both input and output boundaries. Data submitted through the AJAX endpoint can be retained and later inserted into web pages without context-appropriate sanitization and escaping. This behavior maps to CWE-79, which covers improper neutralization of user-controlled input in web output, allowing browser-interpreted script content to execute.
Potential impact
- Arbitrary JavaScript may execute in a victim's browser
- An attacker could perform actions through the victim's authenticated session
- Sensitive page data may be exposed to attacker-controlled code
- Site administrators could be targeted for account or content compromise
- Users may be redirected, deceived, or subjected to malicious page behavior
General mitigation guidance
Mitigation generally focuses on applying context-aware output escaping and strict allowlist-based sanitization to all data received through the AJAX endpoint. Secure-by-default designs should keep untrusted values inert and encode them for their exact HTML, attribute, URL, or script context rather than relying on generic filtering. Input trust should be minimized through capability checks, request validation, and appropriate authorization where functionality permits. Sensitive administrative operations should also use least privilege, nonce or equivalent request-integrity controls, and restrictive browser security policies where practical.
How teams detect issues like this
Detection can include static analysis for unsanitized values flowing from AJAX handlers into HTML responses, templates, DOM updates, or stored content. Code reviews should examine endpoint registration, persistence paths, output contexts, escaping functions, authorization checks, and request-integrity protections. Dynamic testing can submit harmless marker values and verify that rendered output is safely encoded. Content Security Policy reports, web application firewall telemetry, and automated security review tools may help identify suspicious script-bearing submissions or unsafe data flows.

