WP Rocket Path Traversal RCE, Fixed in 3.24.2 (CVE-2026-125812)
WP Rocket before 3.24.2 turns stylesheet URLs into cache paths without containment, so a crafted path can escape the cache root; fixed in 3.24.2.
TL;DR
- WP Rocket builds cache and font file paths by appending a URL path to a fixed directory, with no check that the result stays inside it. A path with parent-directory segments can escape.
- Every WP Rocket release before 3.24.2 is affected. The plugin is installed on more than 5.6 million websites, according to WP Media.
- Patchstack rates the flaw CVSS v3.1 9.8 Critical and classifies it as unauthenticated remote code execution. No public proof of concept or in-the-wild exploitation is published, and the CVE is not in CISA KEV as of 2026-11-26.
- Update to 3.24.2 or later. See "How do I fix it?" for the features to disable while you stage the update.
Am I affected?
You are exposed when a site runs WP Rocket before 3.24.2 and one of its URL-to-path features processes a URL that an attacker can influence. All of these conditions must hold:
- WordPress runs WP Rocket 3.24.1 or earlier.
- At least one of these features is enabled: LazyLoad for CSS background images, which fetches stylesheets and writes cached copies under
wp-content/cache/background-css/, or Self-Host Google Fonts, which downloads fonts and writes them underwp-content/cache/fonts/. - A page or stylesheet the plugin processes contains a stylesheet or font URL whose path the attacker controls.
- The web server can execute PHP files in a directory the traversal can reach, which is the normal setup for Apache and nginx with PHP-FPM.
Patchstack rates the attack unauthenticated, with CVSS vector CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H. The attacker does not need an account.
The practical trigger depends on the site. The attacker must get a stylesheet or font URL into content that WP Rocket processes. The way the URL reaches the page depends on the site's themes and plugins.
| Product | Affected versions | Fixed version |
|---|---|---|
| WP Rocket | 3.24.1 and earlier | 3.24.2 |
WP Rocket is a commercial plugin, so the version is not in the WordPress.org directory. Check it from the command line with the WordPress CLI:
wp plugin get wp-rocket --field=version
wp plugin list --name=wp-rocket --fields=name,status,version
The first command prints the installed version and exits non-zero when the plugin is not installed. The second shows whether the plugin is active. On a multisite network, add --url=https://example.com for the site you are checking.
Also inspect what the background CSS cache has written:
find wp-content/cache/background-css -type f | head -20
find wp-content/cache -type f -name '*.php' -print
The first command should list .css files and their .json mapping files. The second should print nothing on a clean site.
How do I fix it?
Update WP Rocket to 3.24.2 or later, then purge its cache. The release is dated 2026-11-19 on GitHub and is described in the WP Rocket changelog as a security release that improves validation of cached CSS, font and preconnect files.
- Back up the site and the database.
- In WordPress, open Plugins and update WP Rocket to 3.24.2 or later. WP Rocket is a premium plugin, so the update appears when the licence is active and the site can reach the vendor's update server.
- From the command line, run the update and confirm the version:
wp plugin update wp-rocket
wp plugin get wp-rocket --field=version
- Purge the WP Rocket cache, then run the two
findcommands from "Am I affected?" again.
If you manage the plugin with Composer, update the wp-media/wp-rocket dependency to 3.24.2 or later and redeploy. Pulling the package without redeploying the plugin directory leaves the old code in place.
If you cannot update at once, disable the two features that build paths from remote URLs:
- Open WP Rocket, then Settings.
- Under Media, turn off LazyLoad for CSS background images.
- Under Media, turn off Self-Host Google Fonts.
- Save the settings and purge the cache.
The two features are not the only code the release hardened, but they are the paths that write attacker-influenced content to disk. Disabling them removes the write path this post describes. The cost is the performance gain those features provide.
A web application firewall rule that rejects stylesheet and font URLs containing .., %2e%2e or a PHP extension adds a second barrier. It does not replace the update, and it does not cover requests that bypass the firewall.
What is the root cause?
FilesystemCache::generate_path() builds an absolute path from a URL with string concatenation. It trims the leading and trailing slashes from the URL path and appends the result to a fixed cache root and a host directory. It never resolves dot segments and never checks the final path.
This is the function in WP Rocket 3.24.1, at inc/Engine/Common/Cache/FilesystemCache.php lines 225 to 238:
public function generate_path( string $url ): string {
$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'], '/' );
$home_url = home_url();
$home_parsed_url = get_rocket_parse_url( $home_url );
$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;
}
trim( $parsed_url['path'], '/' ) removes only slashes at the two ends. A path such as ../../wp-content/uploads/shell.php keeps its dot segments, because they are not at the ends. The concatenation then produces cache/background-css/<host>/../../wp-content/uploads/shell.php, which the filesystem resolves outside the cache root.
The function also accepts any file name. Nothing requires the final segment to end in .css or .css.json, and nothing rejects a .php, .phtml or .phar suffix. When WP Rocket fetches a stylesheet, Subscriber::generate_css_file() builds the cache destination with generate_path(). ContentFetcher::fetch() uses that destination to rewrite relative URLs, and FilesystemCache::set() writes the processed stylesheet to the same path.
The Self-Host Google Fonts code has the same shape. At inc/Engine/Media/Fonts/Filesystem.php lines 97 to 114 in 3.24.1, the font URL path is appended to the fonts directory. The downloaded body is written to the result:
$local_path = $fonts_basepath . $font_path;
$local_dir = dirname( $local_path );
if ( ! rocket_mkdir_p( $local_dir ) ) {
continue;
}
if ( ! $this->filesystem->exists( $local_path ) ) {
$font_content = $this->get_remote_content( $font_url );
if ( ! $font_content ) {
continue;
}
$this->write_file( $local_path, $font_content );
}
wp_parse_url( $font_url, PHP_URL_PATH ) returns the raw path. The code does not normalize it, does not check its extension and does not compare the result with the fonts base path. A font URL whose path walks up the tree therefore writes wherever the process can write.
The flaw is a missing containment check, not a single bad regular expression. The code trusted that a URL path is a relative path under a directory. A URL path is attacker input, and a path that contains .. is not relative to anything once the operating system resolves it.
How is it exploited?
An attacker gets a crafted stylesheet URL processed, so WP Rocket writes the fetched content to a path outside its cache directory. The attacker then requests the written file at its public URL.
- The attacker prepares a stylesheet on a server they control. The stylesheet body contains the code they want on the target.
- The attacker gets the target to render a
<link rel="stylesheet" href="https://attacker.example/...">whose path contains parent-directory segments and ends in.php. - WP Rocket extracts the link, fetches it and calls
generate_path()with the URL. generate_path()appends the raw path to the cache root, so the resolved destination is outsidewp-content/cache/background-css/.- WP Rocket writes the processed stylesheet to that destination, including the
.phpsuffix. - The attacker requests the written file at its public URL. The web server executes the PHP code.
The same chain works through the fonts directory when Self-Host Google Fonts is on. The font download writes the remote body to the path taken from the font URL.
No public proof of concept is published as of 2026-11-26. Patchstack says it has issued a mitigation rule for the flaw, and it does not publish a request sequence. This post therefore describes the mechanism from the patch and does not include a working payload.
How does the attack flow?
A stylesheet URL the attacker influences reaches a path builder that appends it to a fixed root. The write lands outside the cache directory, and the web server later executes it.
What can an attacker do?
A successful attack writes a file anywhere the PHP process can write, inside or outside the web root. If the destination is under a directory the web server serves and the suffix is executable, the attacker runs code as the web server user. That is the impact Patchstack describes as remote code execution.
The impact needs these conditions:
- The plugin processes a stylesheet or font URL whose path the attacker controls.
- The PHP process has write permission on the resolved destination.
- The destination is reachable by the web server, or another path turns the write into execution.
- The site has not applied a rule that blocks traversal in those URLs.
Without the write permission or the executable destination, the flaw is still a path traversal, but it is not code execution. A failed attempt can still overwrite an existing file the process can write, which may break the site.
An attacker who reaches code execution can read wp-config.php, reuse the database credentials, create an administrator account and modify plugin or theme files. The impact is the same as any PHP file upload on the server, and it includes the customer data the site stores.
Why does the fix work?
The 3.24.2 release replaces the concatenation with normalization, validation and a containment check. This is the core of the new generate_path():
$path = str_replace( '\\', '/', (string) ( $parsed_url['path'] ?? '' ) );
if ( preg_match( '/[\x00-\x1f:<>"|?*]/', $path ) ) {
return '';
}
$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 '';
}
return $file_path;
The leading '/' before rocket_realpath() roots the normalization. A .. segment then clamps at the root instead of climbing out of it. is_valid_path() requires the final file name to match \.css(?:\.json)? and rejects executable inner extensions. is_inside_root() compares the resolved path with the resolved host directory, so a symlink or a path that survived normalization cannot leave the root.
The same release adds get_local_font_path() to the fonts code. It allows only [A-Za-z0-9._/-], normalizes at /, requires a font extension and checks the resolved path against the fonts directory. It also checks the downloaded body against WOFF2, WOFF, TrueType, OpenType and EOT signatures, so an HTML or PHP body is not stored as a font.
The fix is complete for the cache and font path builders this post covers. The release also tightens preconnect entries, and the changelog calls all three changes one security fix.
How do I check if I was compromised?
WP Rocket has published no indicators of compromise, so these checks look for the effect of the write, not for a known attacker string.
Look for PHP files in the cache tree:
find wp-content/cache -type f \( -name '*.php' -o -name '*.phtml' -o -name '*.phar' \) -print
find wp-content/cache/background-css -type f ! -name '*.css' ! -name '*.css.json' ! -name '*.gz' -print
The first command should print nothing. The second lists files that are not part of the cache format, and a PHP file among them is a strong lead.
Check the web server log for stylesheet requests with traversal or a PHP suffix:
grep -Ei '\.(php|phtml|phar)([?" ]|$)' access.log | grep -Ei '(\.\.|%2e%2e)' | head -50
A hit means a request reached the web server with both a traversal sequence and an executable suffix. That is a lead, not proof: a request can contain both and still be blocked. The absence of hits does not prove a clean site, because an attempt that failed or a request that never reached this log leaves no trace.
If you find an unexpected PHP file, keep a copy for analysis and remove it. Then rotate the database and authentication secrets in wp-config.php, and review the administrator accounts and scheduled tasks. A file write that succeeded may have been used to change other files.
Timeline
- 2026-11-04: reported to Patchstack by Vorelito.
- 2026-11-19: WP Rocket 3.24.2 released with the validation changes.
- 2026-11-23: Patchstack publishes the vulnerability entry.
- 2026-11-25: the CVE record is published.
FAQ
Does every WP Rocket site expose the flaw?
No. The plugin must process a stylesheet or font URL whose path the attacker controls. A site with no such path into the cache pipeline is not remotely exploitable through this chain, even though it runs an affected version.
Does the attack need a WordPress account?
Patchstack rates the attack unauthenticated. The attacker needs a way to put a stylesheet or font URL into content WP Rocket processes, and that way depends on the site's themes and plugins.
Is the flaw in WordPress core?
No. It is in the WP Rocket plugin's path builders. WordPress core does not use the plugin's cache directory.
Is there a public exploit?
No public proof of concept is published as of 2026-11-26. Patchstack says it has issued a mitigation rule for the flaw.
Does updating fix files already written?
No. The update stops new writes through these path builders. Purge the cache and run the checks in "How do I check if I was compromised?" on any site that ran an affected version.
Which versions are fixed?
3.24.2 and later. The release is dated 2026-11-19, and the current tag is v3.24.3, released 2026-11-26.
References
- Patchstack, "WordPress WP Rocket Plugin < 3.24.2 is vulnerable to a high priority Remote Code Execution (RCE)", published November 23, 2026 (checked November 26, 2026): https://patchstack.com/database/wordpress/plugin/wp-rocket/vulnerability/wordpress-wp-rocket-plugin-3-24-2-remote-code-execution-rce-vulnerability
- CVE record, CVE-2026-125812, published November 25, 2026 (checked November 26, 2026): https://www.cve.org/CVERecord?id=CVE-2026-125812
- WP Rocket, plugin changelog, entry 3.24.2 dated November 19, 2026 (checked November 26, 2026): https://wp-rocket.me/changelog/
- WP Rocket, release v3.24.2, November 19, 2026 (checked November 26, 2026): https://github.com/wp-media/wp-rocket/releases/tag/v3.24.2
- WP Rocket source at v3.24.1,
inc/Engine/Common/Cache/FilesystemCache.php(checked November 26, 2026): https://github.com/wp-media/wp-rocket/blob/v3.24.1/inc/Engine/Common/Cache/FilesystemCache.php - WP Rocket source at v3.24.2,
inc/Engine/Common/Cache/FilesystemCache.php(checked November 26, 2026): https://github.com/wp-media/wp-rocket/blob/v3.24.2/inc/Engine/Common/Cache/FilesystemCache.php - WP Rocket source at v3.24.1,
inc/Engine/Media/Fonts/Filesystem.php(checked November 26, 2026): https://github.com/wp-media/wp-rocket/blob/v3.24.1/inc/Engine/Media/Fonts/Filesystem.php - WP Rocket, "Trusted by top brands, experts, and 5.6M+ websites worldwide" (checked November 26, 2026): https://wp-rocket.me/
- CISA, Known Exploited Vulnerabilities Catalog, catalog version 2026.11.25 (checked November 26, 2026): https://www.cisa.gov/known-exploited-vulnerabilities-catalog
Keep reading
