No fluff. Just the config that works.
Objective: find out whether a WordPress site was hit through WordPress CVE-2026-87902 before it was patched, and decide whether to clean it in place or rebuild it. Updating to 7.1.2 closed the hole. It did not remove anything an attacker left behind during the window.
Target audience: sysadmins, MSPs and security engineers who own or support self-hosted WordPress, plus anyone who got the auto-update email and moved on.
What you get: the exposure checks, the log and file hunts, a read-only hunt script that runs all of it in one pass, a clean-or-rebuild decision, hardening that breaks the RCE chain, and a FortiGate stopgap signature.
Why WordPress CVE-2026-87902 still matters
CVE-2026-87902 is an unauthenticated local file inclusion in WordPress Core page-template resolution. The GitHub security advisory scores it 9.2 Critical under CVSS 4.0 and lists every branch from 4.7.0 through 7.1.1 as affected, with fixes backported all the way to 4.7.37.
On its own the bug includes a local .php file. It becomes remote code execution when two more things line up: the active theme has a top-level folder whose name starts with page-, and the server has PEAR’s pearcmd.php on disk with register_argc_argv enabled. Patchstack reported attackers probing sites within hours of the September 22, 2026 release, then moving to file writes.
Sites with automatic background updates patched themselves, per Help Net Security. That is exactly why this post exists: the update happened quietly, so nobody looked at what happened between disclosure and patch. The checks below are the same ones Cybersecurity Insiders laid out, turned into commands and one script.
Figure 1: The CVE-2026-87902 chain and where each stage leaves evidence

Prerequisites and Architecture
- Shell access to the web server with sudo (or your host’s file manager plus raw access logs)
- WP-CLI installed (
wp --info). The script works without it, but skips checksum, admin and cron checks - Access logs that reach back to September 22, 2026. Shared hosts often keep only a few days
- Basic comfort with
find,grepand log formats
| Component | Role in the hunt | Lab example |
|---|---|---|
| WordPress root | Core, themes, plugins, wp-config.php | /var/www/html |
| Web server logs | Request evidence for each stage | /var/log/nginx or /var/log/apache2 |
| PHP runtime | Decides whether LFI becomes RCE | PHP-FPM pool config |
| /tmp and /var/tmp | Where current payloads write files | Local disk |
| FortiGate (optional) | Stopgap IPS signature in front of the site | WAN 198.18.10.1, DMZ 10.0.20.0/24 |
Step-by-Step: The Compromise Check
Step 1: Confirm the patch level
Goal: make sure the hole is actually closed on every site before you hunt.
Action: check the version against the fixed release for its branch.
wp core version --path=/var/www/html
wp core check-update --path=/var/www/html
| Branch | Vulnerable | Fixed |
|---|---|---|
| 7.1 | 7.1.0 to 7.1.1 | 7.1.2 |
| 7.0 | 7.0.0 to 7.0.5 | 7.0.6 |
| 6.9 | 6.9.0 to 6.9.8 | 6.9.9 |
| 6.8 | 6.8.0 to 6.8.9 | 6.8.10 |
| Older | Every branch back to 4.7.0 | Backports down to 4.7.37 |
GUI Verification: Dashboard, Updates. The page should show your branch’s fixed version, not an update offer.
Step 2: Decide whether you were exploitable
Goal: know whether the site could have reached code execution, not just been scanned.
Action: check the theme layout first, then the PHP side. Only the active theme and its parent matter.
cd /var/www/html
wp option get stylesheet; wp option get template
ls -d wp-content/themes/<active-theme>/page-*/ 2>/dev/null
ls /usr/local/lib/php/pearcmd.php /usr/share/php/pearcmd.php /usr/share/pear/pearcmd.php 2>/dev/null
grep -ri 'register_argc_argv' /etc/php/*/fpm/ 2>/dev/null
A page-* folder means the inclusion was reachable. A pearcmd.php file plus register_argc_argv = On in the web-facing PHP config means it could become RCE. If the theme has no page-* folder, you were likely only scanned, but run the file hunt anyway.
GUI Verification: Appearance, Themes shows the active theme. A temporary phpinfo() page shows the real register_argc_argv value for the web pool. Delete that page right after.
Step 3: Preserve evidence before you touch anything
Goal: keep the logs alive long enough to answer questions later.
sudo tar czf ~/wp-evidence-$(date +%F).tgz /var/log/nginx /var/log/apache2 \
/var/www/html/wp-config.php /var/www/html/.htaccess 2>/dev/null
GUI Verification: on shared hosting, download the raw access logs from the control panel now. Retention there can be days, not months.
Step 4: Hunt for dropped files
Goal: find the stage 3 output. Current payloads write PHP into /tmp and /var/tmp, and Patchstack lists wp-pear-rce-flag.php, poc87902.php, and names starting with luci_ or zeta_.
sudo find /tmp /var/tmp -xdev -type f \( -name '*.php' -o -name 'poc87902*' \
-o -name 'wp-pear-rce-flag*' -o -name 'luci_*' -o -name 'zeta_*' \) -ls
sudo grep -rlE 'CVE-2026-87902-POC-OK|LUCIFER-RCE-OK' /tmp /var/tmp
find /var/www/html/wp-content/uploads -type f -name '*.php'
Any hit here means the chain ran end to end. Treat the host as compromised, not merely scanned.
Step 5: Hunt the access logs
Goal: reconstruct who tried what, and whether stage 1 succeeded.
sudo zgrep -hiE 'pagename=[^ &]*(%2e%2e|%252e|templates%2f)|pearcmd|config-(create|show)' \
/var/log/nginx/access.log* | awk '{print $1, $4, $7, $9}' | head -50
sudo zgrep -hiE 'cve-2026-87902-poc|nuclei-cve-2026-87902' /var/log/nginx/access.log*
Look at the status and size columns. A normal page URL that returned a 200 with RSS or OPML content means stage 1 worked, so treat the window as confirmed. Requests that contain pearcmd or config-create mean someone tried for code execution.
Step 6: Check file integrity
Goal: catch anything modified or added outside normal updates.
wp core verify-checksums --path=/var/www/html
wp plugin verify-checksums --all --path=/var/www/html
Themes have no checksum command. Download a fresh copy of the same theme version and compare it with diff -rq. Do not rely on file dates: the update itself touched most core files after September 22.
Step 7: Look for footholds
Goal: find the persistence an attacker adds once they have code execution.
wp user list --role=administrator --fields=ID,user_login,user_registered
wp cron event list --fields=hook,next_run_relative
sudo crontab -l -u www-data
ls -la --time-style=long-iso /var/www/html/wp-config.php /var/www/html/.htaccess
GUI Verification: Users, filtered to Administrator. Any account you do not recognize, or one registered after September 22, is a finding.
Step 8: Run everything in one pass
Goal: repeatable, read-only check you can run across every site you manage. It changes nothing, prints findings, and exits 1 when something needs a look.
chmod +x wp-87902-hunt.sh
sudo ./wp-87902-hunt.sh /var/www/html /var/log/nginx
The full script:
#!/usr/bin/env bash
# wp-87902-hunt.sh - read-only compromise check for WordPress CVE-2026-87902
# InfoSecMonkey - No fluff. Just the config that works.
#
# Usage: sudo ./wp-87902-hunt.sh /var/www/html [/var/log/nginx]
# Changes nothing. Prints findings, exits 1 if anything needs a look.
WP="${1:?usage: $0 <wordpress-root> [log-dir]}"
LOGDIR="${2:-}"
SINCE="2026-09-22"
HITS=0
say() { printf '\n== %s\n' "$1"; }
flag() { printf ' [!] %s\n' "$1"; HITS=$((HITS + 1)); }
ok() { printf ' [ok] %s\n' "$1"; }
[ -f "$WP/wp-includes/version.php" ] || { echo "Not a WordPress root: $WP"; exit 2; }
WPCLI=""
if command -v wp >/dev/null 2>&1; then
WPCLI="wp --path=$WP --allow-root --skip-plugins --skip-themes"
fi
say "1. Core version"
VER=$(grep -oP "wp_version\s*=\s*'\K[^']+" "$WP/wp-includes/version.php")
echo " WordPress $VER (fixed: 7.1.2, 7.0.6, 6.9.9, 6.8.10 ... 4.7.37)"
say "2. Theme exposure (top-level page-* folders)"
if [ -n "$WPCLI" ]; then
THEMES="$($WPCLI option get stylesheet) $($WPCLI option get template)"
else
THEMES=$(ls "$WP/wp-content/themes")
echo " wp-cli not found, checking every installed theme"
fi
for t in $(echo "$THEMES" | tr ' ' '\n' | sort -u); do
for d in "$WP/wp-content/themes/$t"/page-*/; do
[ -d "$d" ] && flag "theme $t has $(basename "$d")/ (exploitable layout)"
done
done
say "3. RCE preconditions (pearcmd.php and register_argc_argv)"
for p in /usr/local/lib/php/pearcmd.php /usr/share/php/pearcmd.php /usr/share/pear/pearcmd.php; do
[ -f "$p" ] && flag "found $p"
done
grep -rhsiE '^\s*register_argc_argv\s*=\s*(on|1)' /etc/php* /usr/local/etc/php* 2>/dev/null \
| head -3 | while read -r l; do echo " [!] php.ini: $l"; done
echo " Note: also check the FPM or Apache pool value with phpinfo(), the CLI value can differ."
say "4. Dropped files in /tmp and /var/tmp"
FOUND=$(find /tmp /var/tmp -xdev -type f \( -name '*.php' -o -name 'wp-pear-rce-flag*' \
-o -name 'poc87902*' -o -name 'luci_*' -o -name 'zeta_*' \) 2>/dev/null)
if [ -n "$FOUND" ]; then
echo "$FOUND" | while read -r f; do echo " [!] $f"; done
HITS=$((HITS + 1))
else
ok "nothing suspicious"
fi
MARK=$(grep -rlsE 'CVE-2026-87902-POC-OK|LUCIFER-RCE-OK|chr\(' /tmp /var/tmp 2>/dev/null | head -10)
[ -n "$MARK" ] && flag "marker strings in: $(echo $MARK)"
say "5. PHP files in the web root changed since $SINCE"
NEW=$(find "$WP" -xdev -type f -name '*.php' -newermt "$SINCE" \
-not -path '*/wp-content/cache/*' 2>/dev/null | head -50)
if [ -n "$NEW" ]; then
echo "$NEW" | sed 's/^/ [?] /'
echo " Expected after updates. Anything outside core, theme or plugin updates is a lead."
else
ok "none"
fi
UP=$(find "$WP/wp-content/uploads" -type f -name '*.php' 2>/dev/null | head -20)
[ -n "$UP" ] && flag "PHP files in uploads: $(echo $UP)"
say "6. Access log hunt"
if [ -n "$LOGDIR" ]; then
PAT='pagename=[^ &]*(%2e%2e|%252e|templates%2f)|pearcmd|config-create|config-show|cve-2026-87902-poc|nuclei-cve-2026-87902'
LH=$(find "$LOGDIR" -type f -name '*access*' -exec zgrep -hiE "$PAT" {} + 2>/dev/null)
if [ -n "$LH" ]; then
flag "$(echo "$LH" | wc -l) matching requests, first 10:"
echo "$LH" | head -10 | cut -c1-220 | sed 's/^/ /'
echo " Top sources:"
echo "$LH" | awk '{print $1}' | sort | uniq -c | sort -rn | head -5 | sed 's/^/ /'
else
ok "no matches (POST bodies are not in access logs, so this is not proof)"
fi
else
echo " Skipped. Pass the log folder as the second argument."
fi
say "7. Integrity, accounts, persistence"
if [ -n "$WPCLI" ]; then
$WPCLI core verify-checksums 2>&1 | tail -5 | sed 's/^/ /'
$WPCLI plugin verify-checksums --all 2>&1 | tail -5 | sed 's/^/ /'
echo " Administrators (check user_registered after $SINCE):"
$WPCLI user list --role=administrator --fields=ID,user_login,user_registered 2>&1 | sed 's/^/ /'
echo " Scheduled WP-Cron hooks:"
$WPCLI cron event list --fields=hook,next_run_relative 2>&1 | head -25 | sed 's/^/ /'
else
echo " Install wp-cli for checksum, admin and cron checks."
fi
for f in "$WP/wp-config.php" "$WP/.htaccess"; do
[ -f "$f" ] && echo " $(stat -c '%y' "$f" | cut -d. -f1) $f"
done
WEBUSER=$(stat -c '%U' "$WP/wp-includes/version.php")
crontab -l -u "$WEBUSER" 2>/dev/null | grep -v '^#' | sed "s/^/ [?] cron ($WEBUSER): /"
say "Result"
if [ "$HITS" -gt 0 ]; then
echo " $HITS finding(s). Export logs now, then decide: clean in place or rebuild."
exit 1
fi
echo " No findings. Patch level and logs still deserve a human look."
exit 0
Step 9: Clean in place or rebuild
Goal: make the call with the evidence you have.
| What you found | Decision |
|---|---|
| Scans only, no page- folder, nothing on disk | Patch, harden, done |
| Dropped files in /tmp, no sign they were requested or ran | Clean in place, then rotate secrets |
| Successful stage 1, new admins, cron jobs, modified core, or logs you cannot answer | Rebuild from a known-good backup or fresh install |
Either way, rotate secrets, since wp-config.php is readable by anything that ran as the web user:
wp config shuffle-salts --path=/var/www/html
wp user update <admin-user> --user_pass='<new-strong-password>'
# change the DB password in MySQL, then update DB_PASSWORD in wp-config.php
Harden So the Next LFI Goes Nowhere
Break the RCE chain in PHP. Set register_argc_argv = Off in the web-facing pool, and remove PEAR from web servers that do not need it. Patchstack notes this does not fix the inclusion, but it kills the pearcmd.php route.
; /etc/php/8.3/fpm/conf.d/99-hardening.ini
register_argc_argv = Off
open_basedir = /var/www/html:/tmp/php-sessions
open_basedir limits which paths PHP can include, so a traversal to /usr/share/php fails. Test it in staging first: it breaks plugins that read outside the web root.
Stopgap at the web server. A real page slug never contains a traversal sequence. This catches query-string attempts on nginx:
if ($arg_pagename ~* "(\.\.|%2e|%25)") { return 403; }
It does not inspect POST bodies, so it supplements patching, never replaces it.
Fortinet layer: a FortiGate stopgap signature
If the site sits behind a FortiGate, first check the FortiGuard encyclopedia for a vendor IPS signature for CVE-2026-87902 and use it if present. Until then, a custom signature covers the query-string variant. HTTPS needs SSL deep inspection (or server certificate inspection on the inbound VIP) or the IPS engine never sees the URI.
config ips custom
edit "WP.CVE-2026-87902.Traversal"
set signature "F-SBID( --name \"WP.CVE-2026-87902.Traversal\"; --protocol tcp; --service HTTP; --flow from_client; --pattern \"pagename=\"; --context uri; --no_case; --pattern \"%2e\"; --context uri; --no_case; )"
next
edit "WP.CVE-2026-87902.Pearcmd"
set signature "F-SBID( --name \"WP.CVE-2026-87902.Pearcmd\"; --protocol tcp; --service HTTP; --flow from_client; --pattern \"pearcmd\"; --context uri; --no_case; )"
next
end
GUI Verification: Security Profiles, IPS Signatures shows both custom entries. Add them to the IPS sensor on the inbound VIP policy with the action set to Monitor for a day, confirm no false positives in Log and Report, Security Events, Intrusion Prevention, then switch to Block. FortiAnalyzer can search the same IPS logs by signature name across every FortiGate.
Verification and Validation
sudo ./wp-87902-hunt.sh /var/www/html /var/log/nginx; echo "exit=$?"
curl -s -o /dev/null -w '%{http_code}\n' \
'https://<site>/?page_id=2&pagename=templates%2f%2e%2e%2fwp-links-opml'
Expected success output:
== Result
No findings. Patch level and logs still deserve a human look.
exit=0
403
With the nginx rule or the FortiGate signature in Block, the test request returns 403. Without them, a patched site must not answer that URL with a 200 and OPML content.
Troubleshooting and Gotchas
1. The CLI says register_argc_argv is Off, but the site was still exploitable. php -i reads the CLI ini, not the FPM or Apache one. Check the web pool: grep -r register_argc_argv /etc/php/*/fpm/, or a temporary phpinfo() page.
2. The log grep is empty, so you assume you are clean. POST requests carry the payload in the body, and access logs do not record it. Weight the file hunt and integrity checks more heavily than an empty grep, and enable WAF or IPS logging going forward.
3. find -newermt flags half of core. The update touched those files. Use wp core verify-checksums and wp plugin verify-checksums --all for integrity, and keep the date filter for wp-content, uploads and the web root top level.
Related on InfoSecMonkey: PHP2Shell mitigation with Fortinet, nginx HTTP/2 RCE CVE-2026-123007, and how CVEs are created, scored and tracked.
Sources
- WordPress GitHub security advisory GHSA-7hp8-65ch-5whp for CVE-2026-87902
- Patchstack: CVE-2026-87902 attackers started probing WordPress sites hours after the patch
- Cybersecurity Insiders: Patched isn’t clean, what to check on WordPress sites hit before the CVE-2026-87902 fix
- Help Net Security: WordPress 7.1.2 fixes critical unauthenticated path traversal vulnerability