Automated Threat Modeling

Overview of CVE-2026-125812: Path Traversal to Reported RCE in WP Rocket Cache Path Generation

CVE-2026-125812 is a CWE-22 path traversal in WP Rocket before 3.24.2 that Patchstack classifies as unauthenticated remote code execution. This review covers the root cause in cache path generation and the validation changes shipped in 3.24.2.

CVE Analysis

10 min read

Gaurav Sarraf
Gaurav Sarraf

2026-11-25

Overview of CVE-2026-125812: Path Traversal to Reported RCE in WP Rocket Cache Path Generation

Introduction

A path traversal flaw in WP Rocket's cache layer let attacker-influenced URLs decide where on disk the plugin wrote fetched content, and Patchstack classifies the result as unauthenticated remote code execution. Because WP Rocket generates cached assets on disk for a large population of WordPress sites, CVE-2026-125812 (CVSS v3.1 9.8, CNA-supplied) is a good example of how a cache path helper can turn into a file-write primitive.

WP Rocket is a premium caching and web performance plugin for WordPress, launched in July 2013 and developed by WP Media, a company founded in France in January 2014 that also builds Imagify. The vendor advertises use by more than 5.6 million websites worldwide. That is a reach claim, not an independent measurement or a count of vulnerable installs. Since the plugin writes cached HTML, CSS and font files into the web root, a flaw in how it maps URLs to file paths matters well beyond performance tuning.

On exploitation status: Patchstack describes this vulnerability as expected to be exploited, but the reviewed sources do not confirm exploitation in the wild, name any threat actor, publish a working exploit, or provide vulnerability-specific indicators of compromise. Rapid7's entry lists the CVE as not present in the CISA KEV catalog. The issue was reported by researcher Vorelito.

Technical information

Classification

  • Weakness: CWE-22, Improper Limitation of a Pathname to a Restricted Directory (NVD)
  • Reported impact: Unauthenticated remote code execution (Patchstack)
  • CVSS v3.1 vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H, score 9.8, attributed to the CNA (NVD has not provided its own assessment)

NVD describes the input-handling weakness, and Patchstack describes the resulting outcome. The code changes in 3.24.2 fill in most of the gap between the two.

Root cause: URLs mapped straight to file paths

The "LazyLoad for CSS background images" feature downloads stylesheets and caches rewritten copies under wp-content/cache/background-css/<blog>/<host>/<path>. The on-disk location comes from FilesystemCache::generate_path(), which derives it directly from the stylesheet URL. Before 3.24.2, that function simply joined the parsed host and path onto the cache root:

- $root_path = $this->get_root_path(); - $root_path = rtrim( $root_path, '/' ); - $parsed_url = get_rocket_parse_url( $url ); - $parsed_url_path = trim( $parsed_url['path'], '/' ); ... - $host = '' === $parsed_url['host'] || null === $parsed_url['host'] ? $home_parsed_url['host'] : $parsed_url['host']; - $parsed_url_host = '/' . $host; - - return $root_path . $parsed_url_host . '/' . $parsed_url_path;

Three things were missing:

  1. Nothing resolved .. segments in the path.
  2. Nothing validated the host. A URL like http://../x placed .. directly into the resulting path, making the host the easiest way out of the cache directory.
  3. Nothing restricted the file extension or name.

So a URL such as http://example.org/a/../../../../file produced a path outside the cache root, with any file name, and set() then wrote the fetched content to that location.

The same pattern in Host Fonts Locally

The font self-hosting code had an equivalent bug. Fonts\Filesystem::write_font_css() took wp_parse_url( $font_url, PHP_URL_PATH ) from the remote CSS and appended it to the fonts directory without checks. A font URL path carrying traversal segments or a non-font file name would therefore control where the downloaded bytes landed.

Attack flow

Based on the patch and advisory, the exploitation logic looks like this. The public sources do not name a specific HTTP endpoint, request parameter or required feature setting, so the entry point below is described only at the level the sources support.

  1. An attacker-influenced URL reaches the cache layer. The 3.24.2 changes to Google Fonts URL detection, stylesheet tag extraction and beacon-reported preconnect origins (covered below) indicate these were routes by which untrusted URLs could reach the file-writing code. Patchstack lists the attack as unauthenticated.
  2. The URL is mapped to a path outside the cache. generate_path() concatenates the unvalidated host and path, so .. in either component escapes background-css/<blog>/, and the attacker picks the final file name and extension.
  3. Remote content is written to that path. set() (or, in the fonts code, write_font_css()) writes the fetched content, which the attacker can serve from a server they control, to the computed location.
  4. The written file is executed. Because the file can land outside the cache directory under an attacker-chosen name, Patchstack classifies the CWE-22 flaw as remote code execution. The patch's explicit blocking of PHP, CGI and similar extensions, and of .htaccess-style dot files, is consistent with this outcome.

Patch information

WP Media fixed CVE-2026-125812 in WP Rocket 3.24.2, released on 19 November 2026 (Git tag v3.24.2, release commit 981991c). Patchstack lists < 3.24.2 as vulnerable and 3.24.2 as patched. The official changelog describes the fix in one line: "Improve validation of cached CSS, font and preconnect files".

Neither source names a commit, but comparing v3.24.1...v3.24.2 turns up a single security-relevant change: commit 0b37477, titled "Merge commit from fork". GitHub uses that title when merging a fix developed in a private security advisory fork. Its constituent commits reference an internal ticket (wp-media/wp-rocket.me#6954), and their content matches the changelog line. The remaining commits in the release concern RUCSS duplicate rows, query string cache purging and PHPStan cleanup.

How generate_path() works now

The patched function validates at several stages and returns an empty string on any failure:

private const ALLOWED_FILE_PATTERN = '/\.css(?:\.json)?\z/i'; private const EXECUTABLE_EXTENSION_PATTERN = '/\.ph(?:p\d*|t|tml|ar|ps)(?![a-z])|\.(?:shtml?|f?cgi|pl|plx|ppl|perl|py|aspx?|jsp)(?:\.|\z)/i'; private const UNSAFE_NAME_PATTERN = '/^\.|[. ]\z/'; ... if ( ! $this->is_valid_host( $host ) ) { return ''; } $path = str_replace( '\\', '/', (string) ( $parsed_url['path'] ?? '' ) ); // Control characters break file functions, the others are Windows-reserved (stream separator, wildcards). if ( preg_match( '/[\x00-\x1f:<>"|?*]/', $path ) ) { return ''; } // The leading slash roots the normalization, so parent segments clamp at the host directory. $path = ltrim( rocket_realpath( '/' . $path ), '/' ); if ( ! $this->is_valid_path( $path ) ) { return ''; } $file_path = $root_path . '/' . $host . '/' . $path; if ( ! $this->is_inside_root( $file_path, $root_path . '/' . $host ) ) { return ''; }

There are five layers:

  1. Host validation. is_valid_host() rejects a host that is empty; contains /, \, :, <>"|?*, control characters or ..; or starts with a dot or ends with a dot or space. This closes the http://../ route.
  2. Separator and character checks. Backslashes become /, so Windows-style a\..\..\x.css gets the same treatment. NUL and other control bytes are rejected, as is :, which could otherwise enable PHP stream wrappers or Windows alternate data stream paths, along with Windows wildcard characters.
  3. Resolving .. segments. The path is prefixed with / before rocket_realpath() runs, so any upward traversal stops at the host directory. The new tests show http://example.org/a/../../../../x.css mapping to …/example.org/x.css.
  4. File name allow list. is_valid_path() only accepts names ending in .css or .css.json. It also rejects names with an executable extension in the middle, such as x.php.css, x.php5.css, x.phtml.css, x.cgi.css or x.pl.css, because Apache AddHandler setups can still execute them. Any segment that starts with a dot or ends with a dot or space is refused, blocking .htaccess and Windows trailing-dot tricks. A follow-up commit in the same merge narrowed the PHP pattern so legitimate names like style.phpbb.css are cached again.
  5. Final containment check. is_inside_root() runs rocket_realpath() on both the result and the root, and requires the result to start with <root>/<host>/, as a backstop if an earlier check is bypassed.

Every caller now handles the empty result: get(), set(), has(), delete() and generate_url() all return early, and set() returns false before rocket_mkdir_p() or put_contents() can run. The lazyload subscriber also computes the destination before fetching anything and skips unmappable URLs:

$destination = $this->cache->generate_path( $url ); if ( '' === $destination ) { $this->logger::debug( "Lazy CSS file $url can't be mapped to the cache", $this->generate_log_context() ); return []; }

The font path fix

Each font URL now passes through a new get_local_font_path() before any directory is created or download starts:

private const FONT_PATH_CHARS = '#^[A-Za-z0-9._/-]+\z#'; private const LOCAL_FONT_PATH = '#^(?:/[a-z0-9_-]+)*/[a-z0-9_-]+(?:\.[0-9]+)?\.(?:woff2|woff|ttf|otf|eot)\z#i'; ... // Rooting at "/" clamps leading ".." segments at the fonts directory, on POSIX and Windows alike. $path = '/' . ltrim( rocket_realpath( '/' . $path ), '/' ); if ( ! preg_match( self::LOCAL_FONT_PATH, $path ) ) { return ''; } if ( 0 !== strpos( rocket_realpath( $fonts_basepath . $path ), rocket_realpath( $fonts_basepath ) . '/' ) ) { return ''; }

If a path fails, the font is not stored locally and the CSS keeps the remote URL. This covers percent-encoded sequences, NUL, :, ;, dotted directory names such as /s/x.php/a.woff2, and file names without a font extension.

The patch also adds is_font_content(), which inspects the downloaded bytes. A file is saved only if it begins with a WOFF2, WOFF, TTF, OTF or TTC signature. EOT files, which lack a leading signature, must carry the LP marker at byte 34, a size header equal to the content length, and must not start like HTML. A remote server therefore cannot get a PHP or HTML payload saved even under an allowed name. rocket_mkdir_p now runs only after these checks pass.

Fewer untrusted URLs reach the file-writing code

  • Google Fonts detection. is_google_font_url() previously used a substring regex, (?:https?:)?\/\/fonts\.googleapis\.com\/css.+, so a Google Fonts URL embedded in another URL's query string or fragment also matched. It now parses the URL and requires the exact host fonts.googleapis.com; an http, https or protocol-relative scheme; no userinfo or port; the path /css or /css2; and a query that is not empty.
  • Stylesheet extraction. ExtractCSS\Subscriber used to accept any tag containing rel=stylesheet anywhere in its text, including inside an href. It now parses attributes (first occurrence wins) and checks the rel values, or rel=preload combined with as=style.
  • Preconnect hints. A new OriginTrait::get_origin() reduces each beacon-reported domain to a canonical scheme://host[:port], rejecting paths, queries, fragments, userinfo, schemes other than http(s), ports that are zero or not numeric, control characters and backslashes. It replaces the previous sanitize_url() call and runs at both storage and render time, so rows written by older versions are checked again.

Tests shipped with the fix

generatePath.php alone has dozens of cases, including .. segments clamped to the host directory, and rejection of http://../x.css, x.php.css, NUL bytes, c:/ and %2f. Integration tests run set(), get() and delete() against a virtual filesystem and assert that nothing outside background-css/1/example.org/ is created, read or deleted. Font tests check that traversal attempts, encoded paths and non-font content keep their remote URLs and create no files.

Applying the update

Patchstack recommends updating to 3.24.2 or later and states it has issued a mitigation rule that blocks attacks until the update is installed. The rule's contents are not published. The vendor documents these update routes:

  • Dashboard: on the Plugins page, use the update notification under WP Rocket and select update now. WP Rocket must be active.
  • Missing notification: go to Dashboard > Updates and select Check Again.
  • Manual: export settings from the WP Rocket Tools tab, download the plugin from your vendor account, deactivate and delete the old plugin, upload and activate the new ZIP, then import the settings.

WP Rocket disables unattended automatic updates because caching changes can affect the front end, and an expired license removes access to plugin updates. Both mean a fixed release existing does not imply it has been installed. Patched installs report WP_ROCKET_VERSION as 3.24.2 in wp-rocket.php.

If compromise is suspected, the vendor's general hacked-site guidance is to disable preloading, clear the cache, deactivate WP Rocket, clean the site, and reactivate only once it is clean. WP Rocket also notes that page caching can copy already infected content into cache files, so a malicious cached file alone does not prove this CVE was the entry point.

Affected systems and versions

  • Product: WP Rocket by WP Media, plugin slug wp-rocket
  • Affected: all versions before 3.24.2 (the CVE record does not specify the first vulnerable release)
  • Fixed: 3.24.2 and later
  • Code paths changed by the fix: LazyLoad for CSS background images (FilesystemCache::generate_path()), Host Fonts Locally (Fonts\Filesystem::write_font_css()), and preconnect origin handling

The public sources do not establish which feature configurations are required to reach the vulnerable code. We would not treat a particular feature being disabled as evidence that an older installation is safe. The version boundary is the reliable criterion.

Vendor security history

WP Rocket runs an active vulnerability disclosure program through Patchstack, with a scope that explicitly includes path traversal, arbitrary file operations and code execution. This CVE moved through that program on a short timeline:

  • 4 November 2026: reported by Vorelito
  • 19 November 2026: WP Rocket 3.24.2 released
  • 23 November 2026: Patchstack advisory published
  • 25 November 2026: NVD record published

The fix was available before either public advisory, and it was developed in a private security advisory fork. An earlier, unrelated record, CVE-2026-28044, describes stored cross-site scripting in WP Rocket through 3.19.4. It is a different weakness class and does not indicate recurrence of this mechanism.

References

Detect & fix
what others miss

Works with
  • GitHub
  • GitLab
  • Bitbucket
  • Azure DevOps Services
  • Gerrit
  • CVS
  • Jira
  • Linear
  • Slack
  • Security Compass
Explore integrations
Security magnifying glass visualization