WordPress Core - Unauthenticated Page Template Path Traversal to RCE
Run this lab
Lab not starting or behaving wrong? Report a problem with this lab
Summary
WordPress Core versions prior to 7.1.2 (and the unpatched maintenance releases of older branches) contain an unauthenticated path traversal in page-template resolution. get_page_template() builds the candidate "page-{pagename}.php" from a urldecoded pagename query variable without validating it, so a double-encoded traversal sequence makes locate_template() include a chosen readable local .php file outside the active theme. When the active theme has a top-level page-* directory (e.g. Twenty Twelve, Twenty Fourteen, Neve, Hestia, Sydney) and the server ships pearcmd.php with register_argc_argv enabled (official php Docker image), this leads to remote code execution.
Technical detail
Impact
An unauthenticated attacker can include local PHP files outside the active theme, disclosing sensitive data. Where pearcmd.php is reachable and register_argc_argv is on, the inclusion is escalated to unauthenticated remote code execution running as the web-server account, leading to full site compromise.
Exploitation & proof of concept
Local PHP file inclusion via pagename traversal
A double-encoded traversal in the pagename query variable escapes the theme's page-templates/ directory and reaches the WordPress root, so wp-links-opml.php is included and returns its OPML document instead of the normal page body.
POST /?page_id=4&pagename=templates%252F%252E%252E%252F%252E%252E%252F%252E%252E%252F%252E%252E%252Fwp-links-opml HTTP/1.1 Host: {{Hostname}} Content-Length: 0
HTTP/1.1 200 OK Content-Type: text/xml; charset=UTF-8
Nuclei detection: vt-2026-87902.nuclei.yaml
Remediation
- Update WordPress to 7.1.2 or the patched maintenance release for the installed branch
- Apply fix commit fdeab470f4b4062462cf8ccdc788f258683c2d6f (validate_file guard in get_page_template)
- Disable register_argc_argv and remove pearcmd.php from production PHP installs
Lab setup notes
- Wait for vt-2026-87902-init to report INSTALL_OK (core install + Twenty Twelve + a published page)
- Access the application at http://localhost:8787
- Run: nuclei -t vt-2026-87902.nuclei.yaml -u http://localhost:8787
References
- https://vulnerabletarget.com/VT-2026-87902
- https://nvd.nist.gov/vuln/detail/CVE-2026-87902
- https://github.com/WordPress/wordpress-develop/security/advisories/GHSA-7hp8-65ch-5whp
- https://github.com/WordPress/WordPress/commit/fdeab470f4b4062462cf8ccdc788f258683c2d6f
- https://hadrian.io/vulnerability-alerts/cve-2026-87902-working-poc-wordpress-critical-path-traversal
- https://github.com/projectdiscovery/nuclei-templates/pull/17300