CVE-2026-133274
THC-Hydra Stack Buffer Overflow via hydra-http-form.c Cookie Handling
Out-of-Bounds Write in analyze_server_response() via crafted Set-Cookie headers (CWE-787/CWE-191, DoS)
Teknik Rapor
CVE-2026-133274 — Stack-Buffer Overflow Write PoC & Write-up (THC-Hydra)
| Ürün | THC-Hydra (vanhauser-thc/thc-hydra) |
| Test Edilen Versiyon | v9.8dev |
| Zafiyet Sınıfı | CWE-787: Out-of-bounds Write / CWE-191: Integer Underflow |
| Etkilenen Bileşen | hydra-http-form.c — HTTP form response handler / Set-Cookie parsing loop |
| Saldırı Vektörü | Network (HTTP/HTTPS) |
| Yetki Gereksinimi | None |
| Kullanıcı Etkileşimi | Hydra operatörünün HTTP form kontrolünü başlatması |
| Etkilenen Varlık | Hydra client process |
| CVSS 4.0 | 7.1 (High) |
| CVE | CVE-2026-133274 |
| Keşif Tarihi | 6 Kasım 2026 |
| Vendor Bildirim Tarihi | 7 Kasım 2026 |
1. Özet
THC-Hydra'nın HTTP form modülünde, HTTP sunucularından gelen Set-Cookie başlıklarının işlenmesi sırasında bellek bozulmasına neden olan bir zafiyet tespit ettim.
Zafiyet, hydra-http-form.c dosyasında bulunan HTTP form response handler içerisindeki cookie parsing mekanizmasından kaynaklanmaktadır.
Set-Cookie başlığında iki nokta üst üste karakterinden sonra gelen boşlukların hatalı işlenmesi, cookie verisinin başında beklenmeyen bir boşluk karakterinin korunmasına neden olmaktadır. Daha sonraki HTTP yanıtında aynı cookie normal biçimde güncellendiğinde, cookie parser içerisindeki ptr - cookie - 2 hesaplaması negatif değer üretebilmektedir.
Bu negatif değer, strncpy() fonksiyonunun uzunluk parametresine aktarılmaktadır. Fonksiyonun uzunluk parametresi size_t türünde olduğundan, negatif değer çok büyük bir unsigned değere dönüşmektedir. Bunun sonucunda hedef buffer sınırlarının dışında yazma işlemi gerçekleşmektedir.
Fortify korumalarının etkin olduğu derlemelerde Hydra süreci:
*** buffer overflow detected ***: terminated
hatasıyla sonlanmaktadır. Daha az korumalı derlemelerde ise aynı hatalı uzunluk hesabı out-of-bounds write davranışına neden olmaktadır.
2. Zafiyet Detayları
2.1 Sınıflandırma
- CWE-787 — Out-of-bounds Write: Hedef buffer sınırlarının dışında bellek yazımı.
- CWE-191 — Integer Underflow: Negatif pointer farkının unsigned uzunluk parametresine aktarılması.
- Etkilenen fonksiyon:
strncpy() - Etkilenen dosya:
hydra-http-form.c - Etkilenen işlem: HTTP
Set-Cookiebaşlıklarının parse edilmesi ve mevcut cookie değerlerinin güncellenmesi.
2.2 CVSS v4.0 Değerlendirmesi
CVSS 4.0 Base Score: 7.1 (High)
Zafiyet, ağ üzerinden Hydra'ya iletilen özel hazırlanmış HTTP yanıtları aracılığıyla tetiklenebilmektedir. Başarılı tetikleme sonucunda Hydra istemci süreci bellek bozulması nedeniyle sonlanabilmektedir.
2.3 Kök Neden — Zafiyetli Kod
Dosya: hydra-http-form.c
Zafiyetli kod:
if (ptr != cookie && *(ptr - 1) == ' ') {
strncpy(tmpcookie, cookie, ptr - cookie - 2);
tmpcookie[ptr - cookie - 2] = 0;
}
Kod içerisinde ptr - cookie - 2 ifadesinin negatif değer üretip üretmediği kontrol edilmeden sonuç doğrudan strncpy() fonksiyonunun uzunluk parametresi olarak kullanılmaktadır.
strncpy() fonksiyonunun üçüncü parametresi size_t türündedir. Pointer farkı sonucunda -1 elde edildiğinde bu değer unsigned dönüşüm nedeniyle çok büyük bir kopyalama uzunluğuna dönüşmektedir.
Bu durum, cookie verisinin tmpcookie buffer'ına kopyalanması sırasında buffer sınırlarının aşılmasına neden olmaktadır.
Aynı negatif değer aşağıdaki null terminator atamasında da kullanılmaktadır:
tmpcookie[ptr - cookie - 2] = 0;
Dolayısıyla sorun yalnızca kopyalama uzunluğuyla sınırlı değildir; indeks hesabı da geçersiz hale gelmektedir.
2.4 Tetiklenme Mekanizması
Zafiyet iki ardışık HTTP yanıtı kullanılarak tetiklenmektedir.
İlk HTTP yanıtı:
HTTP/1.1 200 OK
Set-Cookie: a=orig; Path=/
Content-Length: 0
Bu yanıtta Set-Cookie: sonrasında iki boşluk bulunmaktadır.
Cookie parsing işlemi sırasında fazladan boşluk cookie verisinin başında korunmaktadır. Böylece cookie jar içerisinde beklenmeyen bir başlangıç karakteri oluşmaktadır.
İkinci HTTP yanıtı:
HTTP/1.1 200 OK
Set-Cookie: a=newvalue; Path=/
Content-Length: 0
İkinci yanıtta aynı cookie normal biçimde güncellenmektedir.
Cookie güncelleme mekanizması çalıştığında aşağıdaki hesaplama negatif sonuç üretebilmektedir:
ptr - cookie - 2
Hesaplama sonucunun -1 olması durumunda değer strncpy() fonksiyonuna aktarılmakta ve çok büyük bir kopyalama uzunluğu oluşmaktadır.
Bu işlem Hydra sürecinde out-of-bounds write ile sonuçlanmaktadır.
2.5 PoC Payload
İlk yanıtın payload değeri:
Set-Cookie: a=orig; Path=/
İkinci yanıtın payload değeri:
Set-Cookie: a=newvalue; Path=/
İki yanıt arasındaki boşluk farklılığı, cookie parsing ve güncelleme mekanizmasını hatalı uzunluk hesabına yönlendirmektedir.
2.6 PoC Çalıştırılması
PoC HTTP sunucusu yerel test ortamında 127.0.0.1:8899 adresinde çalışmaktadır.
Önce PoC sunucusu başlatılır:
python3 CVE-2026-133274_THC-Hydra_PoC.py
Ardından Hydra aşağıdaki komutla çalıştırılır:
./hydra -l test -p test 127.0.0.1 -s 8899 \
http-get-form "/:user=^USER^&pass=^PASS^:F=incorrect" \
-t 1 -d
PoC sunucusu iki HTTP isteğini karşılayarak sırasıyla hatalı boşluk içeren cookie başlığını ve aynı cookie'nin normal biçimde güncellendiği ikinci yanıtı gönderir.
3. Tetiklenme Yolu ve Saldırı Akışı
- Hydra, hedef HTTP sunucusuna HTTP form isteği gönderir.
- HTTP sunucusu ilk yanıtta iki boşluk içeren
Set-Cookiebaşlığını döndürür. - Hydra cookie değerini işler ve başlangıçtaki fazladan boşluk cookie verisinde korunur.
- Sunucu sonraki HTTP yanıtında aynı cookie'yi normal biçimde günceller.
- Hydra cookie parser içerisindeki güncelleme kod yoluna girer.
ptr - cookie - 2hesabı negatif değer üretir.- Negatif değer
strncpy()fonksiyonununsize_tuzunluk parametresine aktarılır. - Buffer sınırlarının dışında yazma gerçekleşir ve Hydra süreci sonlanır.
4. Lab Doğrulama Kanıtı
Test sırasında Fortify kontrollerinin etkin olduğu Hydra derlemesinde aşağıdaki hata gözlemlenmektedir:
*** buffer overflow detected ***: terminated
Bu çıktı, cookie parsing işlemi sırasında oluşan hatalı bellek erişiminin çalışma zamanı koruması tarafından yakalandığını ve Hydra sürecinin abort edildiğini göstermektedir.
Daha az korumalı derlemelerde aynı tetikleme akışı out-of-bounds write davranışına neden olmaktadır.
5. Etki
Bu zafiyetin başarılı şekilde tetiklenmesi aşağıdaki sonuçlara neden olabilmektedir:
- Hydra istemci sürecinin beklenmedik şekilde sonlanması.
- HTTP form kontrollerinin kesintiye uğraması.
- Hydra'nın kullanılamaz hale gelmesi.
- Bellek korumalarının yapılandırmasına bağlı olarak stack üzerinde out-of-bounds write meydana gelmesi.
Gösterilen PoC ile doğrulanan temel etki, Hydra sürecinin çökmesi ve hizmet reddidir.
6. Önerilen Çözüm
ptr - cookie - 2 hesaplamasının negatif değer üretmesi engellenmelidir.
Pointer farkı, size_t türüne dönüştürülmeden önce signed bir türde hesaplanmalı ve negatif sonuçlar kontrol edilmelidir. Ayrıca kopyalama uzunluğu hedef buffer kapasitesiyle sınırlandırılmalıdır.
Örnek kontrol yaklaşımı:
ptrdiff_t off = ptr - cookie - 2;
if (off >= 0 && (size_t)off < sizeof(tmpcookie)) {
size_t n = (size_t)off;
memcpy(tmpcookie, cookie, n);
tmpcookie[n] = '\0';
}
Bu kontrol ile negatif uzunluk değerinin strncpy() veya benzeri bellek işlemlerine aktarılması engellenebilir.
CVE-2026-133274 — Out-of-Bounds Write in THC-Hydra HTTP Form Cookie Parser
| Product | THC-Hydra (vanhauser-thc/thc-hydra) |
| Version Tested | v9.8dev |
| Vulnerability Class | CWE-787: Out-of-bounds Write / CWE-191: Integer Underflow |
| Affected Component | hydra-http-form.c — HTTP form response handler / Set-Cookie parsing loop |
| Attack Vector | Network (HTTP/HTTPS) |
| Privileges Required | None |
| User Interaction | The Hydra operator initiates the HTTP form check |
| Affected Asset | Hydra client process |
| CVSS 4.0 | 7.1 (High) |
| CVE | CVE-2026-133274 |
| Discovery Date | November 6, 2026 |
| Vendor Notification Date | November 7, 2026 |
1. Summary
I identified a memory corruption vulnerability in THC-Hydra's HTTP form module while processing Set-Cookie headers received from HTTP servers.
The vulnerability originates from the cookie parsing mechanism in the HTTP form response handler in hydra-http-form.c.
Improper handling of whitespace following the colon in a Set-Cookie header allows an unexpected leading whitespace character to be preserved in the cookie data. When the same cookie is updated normally in a subsequent HTTP response, the expression ptr - cookie - 2 in the cookie parser can produce a negative value.
This negative value is passed as the length argument to strncpy(). Since the function expects a size_t length, the negative value is converted into a very large unsigned integer. As a result, the copy operation exceeds the destination buffer boundary and causes an out-of-bounds write.
On builds with Fortify protections enabled, the Hydra process terminates with:
*** buffer overflow detected ***: terminated
On less-protected builds, the same invalid length calculation results in an out-of-bounds write.
2. Vulnerability Details
2.1 Classification
- CWE-787 — Out-of-bounds Write: Memory write beyond the destination buffer boundary.
- CWE-191 — Integer Underflow: A negative pointer difference is passed to an unsigned length parameter.
- Affected function:
strncpy() - Affected file:
hydra-http-form.c - Affected operation: Parsing and updating HTTP
Set-Cookieheaders.
2.2 CVSS v4.0 Assessment
CVSS 4.0 Base Score: 7.1 (High)
The vulnerability can be triggered through specially crafted HTTP responses delivered to Hydra over the network. Successful exploitation can cause memory corruption and terminate the Hydra client process.
2.3 Root Cause — Vulnerable Code
File: hydra-http-form.c
Vulnerable code:
if (ptr != cookie && *(ptr - 1) == ' ') {
strncpy(tmpcookie, cookie, ptr - cookie - 2);
tmpcookie[ptr - cookie - 2] = 0;
}
The expression ptr - cookie - 2 is used as the length argument to strncpy() without checking whether the result is negative.
The third argument of strncpy() is a size_t. If the pointer difference evaluates to -1, the value is converted to a very large unsigned integer. Consequently, the copy operation exceeds the intended buffer boundary and causes memory corruption.
The same invalid value is also used in the following null-terminator assignment:
tmpcookie[ptr - cookie - 2] = 0;
Therefore, the issue affects both the copy length and the resulting array index.
2.4 Trigger Mechanism
The vulnerability is triggered using two consecutive HTTP responses.
First HTTP response:
HTTP/1.1 200 OK
Set-Cookie: a=orig; Path=/
Content-Length: 0
There are two spaces after Set-Cookie:.
During cookie parsing, the additional whitespace is preserved at the beginning of the cookie data, leaving an unexpected leading character in the cookie jar.
Second HTTP response:
HTTP/1.1 200 OK
Set-Cookie: a=newvalue; Path=/
Content-Length: 0
The second response updates the same cookie using normal formatting.
When the cookie update mechanism processes the new value, the following expression can produce a negative result:
ptr - cookie - 2
If the result is -1, it is passed to strncpy(), resulting in an excessively large copy length and an out-of-bounds write.
2.5 PoC Payload
First response payload:
Set-Cookie: a=orig; Path=/
Second response payload:
Set-Cookie: a=newvalue; Path=/
The whitespace difference between the two responses causes the cookie parsing and update logic to reach the invalid length calculation.
2.6 Running the PoC
The PoC server listens on 127.0.0.1:8899.
Start the PoC server:
python3 CVE-2026-133274_THC-Hydra_PoC.py
Run Hydra in a separate terminal:
./hydra -l test -p test 127.0.0.1 -s 8899 \
http-get-form "/:user=^USER^&pass=^PASS^:F=incorrect" \
-t 1 -d
The PoC server handles two HTTP requests and sends the malformed whitespace cookie header followed by the response that updates the same cookie normally.
3. Trigger Path and Attack Flow
- Hydra sends an HTTP form request to the target HTTP server.
- The server returns a
Set-Cookieheader containing two spaces after the colon. - Hydra processes the cookie and preserves the additional leading whitespace in the cookie data.
- The server updates the same cookie normally in the next HTTP response.
- Hydra enters the cookie update code path.
- The
ptr - cookie - 2expression produces a negative value. - The negative value is passed to the
size_tlength parameter ofstrncpy(). - An out-of-bounds write occurs and the Hydra process terminates.
4. Lab Verification
On a Hydra build with Fortify checks enabled, the following error is observed:
*** buffer overflow detected ***: terminated
This output indicates that the invalid memory operation during cookie parsing is detected by the runtime protection and the Hydra process is aborted.
On less-protected builds, the same trigger sequence results in out-of-bounds write behavior.
5. Impact
Successful triggering of this vulnerability can result in:
- Unexpected termination of the Hydra client process.
- Interruption of HTTP form checks.
- Denial of service affecting Hydra.
- Stack-based out-of-bounds write behavior, depending on the build's memory protection configuration.
The primary impact demonstrated by the PoC is process termination and denial of service.
6. Recommended Fix
The ptr - cookie - 2 calculation must not be allowed to produce a negative length.
The pointer difference should be calculated using a signed type before conversion to size_t, and negative results must be rejected. The copy length should also be limited by the destination buffer capacity.
Example defensive approach:
ptrdiff_t off = ptr - cookie - 2;
if (off >= 0 && (size_t)off < sizeof(tmpcookie)) {
size_t n = (size_t)off;
memcpy(tmpcookie, cookie, n);
tmpcookie[n] = '\0';
}
This prevents a negative length from being passed to strncpy() or other memory-handling operations.
Referanslar / References
Araştırmacı: Umut SEVİNÇ (VulnSVNC)