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)
Technical Report
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.
References
Researcher: Umut SEVİNÇ (VulnSVNC)
