
Proof-of-concept exploit for a WordPress core update TOCTOU race (CWE-367) that writes a rogue wp-config.php, enabling database takeover, admin login, and RCE.
| Field | Value |
|---|---|
| CVE | CVE-2026-119977 |
| CVSS | 8.1 (High) |
| CWE | CWE-367 (Time-of-Check Time-of-Use) |
| Attack Vector | Network (fully remote, HTTP only) |
| Affected | WordPress 4.7.0 – 7.1.3 |
| Fixed in | WordPress 7.1.4 |
AUTHORIZED SECURITY TESTING ONLY. This PoC is for validating the vulnerability on systems you own or have explicit written permission to test. Unauthorized access to computer systems is illegal under CFAA (US), Computer Misuse Act (UK), and similar laws worldwide.
During a WordPress core update, the updater:
wp-content/upgrade/.wp-content/upgrade/wordpress-<version>-no-content/wordpress/
/wp-admin/setup-config.php — the WordPress
installation wizard. This endpoint is unauthenticated when no
wp-config.php exists in its working ABSPATH (the staging directory).
It also has error_reporting(0) which masks PHP fatal errors during
partial extraction, and sets WP_INSTALLING = true which bypasses
maintenance mode.copy_dir() promotes the entire staging tree into the live root with
$overwrite = true. The $skip array in 7.1.3 is:
$skip = array( 'wp-content', 'wp-includes/version.php' );
wp-config.php is NOT in $skip — so an attacker-written config
in the staging directory gets promoted to the live root.Timeline
──────────────────────────────────────────────────────────────────────
unpack_package() copy_dir()
extracts ZIP ──────────────── snapshots staging dir ──── promotes files
│ │
│ ◄── RACE WINDOW ──► │
│ │
setup-config.php becomes copy_dir() sees the new wp-config.php
accessible in staging dir and copies it to ABSPATH (live root)
│ │
Attacker POSTs to it Target now connects to attacker's
with rogue DB credentials MySQL database
──────────────────────────────────────────────────────────────────────
Result: The live site's wp-config.php now points to the attacker's
MySQL server, which contains a pre-seeded administrator account.
Phase 0 ─► Prepare attacker MySQL with pre-seeded WordPress tables
(admin user: attacker/pwned2026, blogname: "PWNED by CVE-2026-119977")
Phase 1 ─► Fingerprint target WordPress version via HTTP
(RSS feed, meta tag, or version.php source leak)
Phase 2 ─► Compute predictable staging URL:
{target}/wp-content/upgrade/wordpress-{next_ver}-no-content/wordpress/
Phase 3 ─► Aggressive POST-as-detection loop:
Continuously POST setup-config.php?step=2 with attacker DB creds
├── 404 → staging not up yet (keep polling)
├── 200 + 0 bytes → extraction incomplete (retry fast)
└── 200 + HTML → SUCCESS: wp-config.php written!
Phase 4 ─► Verify DB takeover: GET target homepage, check for attacker markers
Phase 5 ─► Login as attacker admin (attacker / pwned2026)
Phase 6 ─► Deploy webshell via theme editor (functions.php injection)
Phase 7 ─► Interactive remote command execution
┌─────────────────────────────────────┐
│ ATTACKER VPS │
│ (e.g. 203.0.113.50) │
│ │
│ ┌──────────────────────────────┐ │
│ │ exploit.py │ │
│ │ Python 3.8+ (stdlib only) │ │
│ │ │ │
│ │ Sends HTTP POST to target's │ │
│ │ staging setup-config.php │ │
│ │ with DB creds pointing to │ │
│ │ THIS server's MySQL │ │
│ └──────────┬───────────────────┘ │
│ │ │
│ ┌──────────▼───────────────────┐ │
│ │ MySQL 8.0 │ │
│ │ Port 3306 (open to target) │ │
│ │ │ │
│ │ Database: attacker_db │ │
│ │ ├── wp_users (attacker admin)│ │
│ │ ├── wp_options (PWNED title) │ │
│ │ ├── wp_posts │ │
│ │ └── ... (12 tables total) │ │
│ └──────────────────────────────┘ │
└────────────┬────────────────────────┘
│
HTTP POST (port 443/80) │ MySQL (port 3306)
─────────────────────► │ ◄─────────────────
│
┌────────────▼────────────────────────┐
│ TARGET SERVER │
│ (WordPress 7.1.3) │
│ │
│ During update, staging dir appears:│
│ wp-content/upgrade/ │
│ wordpress-7.1.4-no-content/ │
│ wordpress/ │
│ wp-admin/ │
│ setup-config.php ◄── POST │
│ wp-config.php ◄── WRITTEN │
│ │
│ copy_dir() promotes wp-config.php │
│ to ABSPATH (live root) │
│ │
│ Site now connects to attacker DB │
└─────────────────────────────────────┘
The --atk-host parameter is NOT the attacker's local address.
It is the MySQL hostname/IP as the TARGET server sees it: