
Exploit proof-of-concept per una race condition TOCTOU nell'aggiornamento del core di WordPress (CWE-367) che scrive un wp-config.php malevolo, consentendo la compromissione del database, l'accesso come amministratore e l'esecuzione remota di codice (RCE).
| Campo | Valore |
|---|---|
| CVE | CVE-2026-119977 |
| CVSS | 8.1 (Alto) |
| CWE | CWE-367 (Time-of-Check Time-of-Use) |
| Vettore di attacco | Rete (completamente remoto, solo HTTP) |
| Affetto | WordPress 4.7.0 – 7.1.3 |
| Corretto in | WordPress 7.1.4 |
SOLO TEST DI SICUREZZA AUTORIZZATI. Questo PoC serve a validare la vulnerabilità su sistemi di tua proprietà o per i quali disponi di esplicita autorizzazione scritta ai test. L'accesso non autorizzato a sistemi informatici è illegale ai sensi del CFAA (USA), del Computer Misuse Act (Regno Unito) e di leggi simili in tutto il mondo.
Durante un aggiornamento del core di WordPress, l'updater:
wp-content/upgrade/.wp-content/upgrade/wordpress-<version>-no-content/wordpress/
/wp-admin/setup-config.php — la procedura guidata di installazione di WordPress. Questo endpoint è non autenticato quando non esiste alcun wp-config.php nel suo ABSPATH di lavoro (la directory di staging). Presenta inoltre error_reporting(0) che maschera gli errori fatali di PHP durante l'estrazione parziale, e imposta WP_INSTALLING = true che aggira la modalità di manutenzione.copy_dir() promuove l'intero albero di staging nella root attiva con
$overwrite = true. L'array $skip nella 7.1.3 è:
$skip = array( 'wp-content', 'wp-includes/version.php' );
wp-config.php NON è in $skip — quindi un config scritto dall'attaccante
nella directory di staging viene promosso alla root live.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
──────────────────────────────────────────────────────────────────────
Risultato: il wp-config.php del sito live ora punta al server
MySQL dell'attaccante, che contiene un account amministratore pre-caricato.
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 │
└─────────────────────────────────────┘