CVE-2026-87902

WordPress Core <= 7.1.1 - Unauthenticated Local File Inclusion via locate_template() Path Traversal

2026-09-22 00:00
Robert Ressl

Strategic Overview

Status
Patched in 4.7.37
Affected Core
WordPress 7.1
Affected Version
4.7 – 7.1.1 · 25 branches
CVSS
8.1High
Weakness type
CWE-98 · Improper Control of Filename for Include/Require Statement in PHP Program ('PHP Remote File Inclusion')
CVE
CVE-2026-87902
View all WordPress 7.1 vulnerabilities

At a glance

CVE-2026-87902 is a high-severity Improper Control of Filename for Include/Require Statement in PHP Program ('PHP Remote File Inclusion') vulnerability in the WordPress 7.1 WordPress release line, affecting 4.7 – 7.1.1 · 25 branches. It carries a CVSS score of 8.1 (reachable over the network; high confidentiality, integrity, availability impact). Exploitation requires no authentication. The issue is fixed in version 4.7.37; sites on affected versions should update now. Disclosed September 2026, reported by Robert Ressl.

Vulnerability Overview

WordPress Core is vulnerable to Local File Inclusion via the locate_template() function in various versions up to, and including, 7.1.1. The function resolved a caller-supplied template name against the theme directories without verifying the result stayed within them, so a template name containing '..' could resolve to a readable PHP file outside the active theme and be included. The core-reachable vector is get_page_template(), which builds page-{$pagename}.php from the URL-derived, url-decoded 'pagename' query variable. This makes it possible for unauthenticated attackers to make page-template resolution include a chosen readable local .php file outside the theme directories, which under certain conditions can lead to remote code execution. Exploitation requires (1) the active parent or child theme to contain a top-level directory whose name begins with 'page-' (e.g. 'page-templates' in Twenty Twelve, Twenty Fourteen, Neve, Hestia, Sydney), and (2) a readable .php target on the server accessible to the web-server account (e.g. pearcmd.php with register_argc_argv=On, as in the official PHP Docker image and default cPanel setups on PHP < 8.5), which yields RCE.

Technical Analysis

The vector marks this flaw as remotely reachable over the network, and no privileges on the target site, and no interaction from a victim user. A successful exploit has high impact on confidentiality, integrity, availability — full site compromise territory.

CWE-98: Improper Control of Filename for Include/Require Statement in PHP Program ('PHP Remote File Inclusion')

WordPress 7.1 4.7 – 7.1.1 · 25 branches carries this weakness at pagename, and reaching it takes no account at all. PHP file inclusion means a path used by include or require is built from request data, so the file that gets executed is under the caller's influence.

Including an attacker-influenced file executes its contents, which is why this class is routinely chained with an upload or log-poisoning step to reach code execution. For WordPress 7.1 the fix is 4.7.37: builds 4.7 – 7.1.1 · 25 branches are affected, anything from 4.7.37 onward is not.

Remediation

Update to one of the following versions, or a newer patched version: 4.7.37, 4.8.32, 4.9.33, 5.0.29, 5.1.26, 5.2.28, 5.3.25, 5.4.23, 5.5.22, 5.6.21, 5.7.19, 5.8.17, 5.9.18, 6.0.16, 6.1.14, 6.2.13, 6.3.12, 6.4.12, 6.5.12, 6.6.9, 6.7.9, 6.8.10, 6.9.9, 7.0.6, 7.1.2

How does WordSec protect against this?

Requests carrying this pattern arrive without a session, so nothing upstream of the firewall gets a chance to reject them: WordSec's web application firewall inspects request payloads before WordPress loads them. Classes like this one can leave something behind, so the staged malware scanner is the second half: it looks for dropped files and modified code rather than for the request that created them. None of that substitutes for the fix: updating to 4.7.37 is the step that ends it.

  • Firewall
  • Scanner
  • Login Security

External References

Related records

Vulnerability data © Defiant, Inc., provided under the Wordfence Intelligence T&C