The vulnerability, identified as GHSA-847f-9342-265h, is a classic case of HTTP Request Smuggling due to improper handling of special characters (CRLF) in HTTP headers. The h2 library, when used by a server that downgrades HTTP/2 requests to HTTP/1.1, failed to properly sanitize header fields. This allowed a malicious client to inject CRLF sequences into headers, which could be interpreted by a backend server as the boundary for a new request.
The analysis of the fixing commit 035e9899f95e3709af098f578bfc3cd302298e3a points to two key functions in src/h2/utilities.py.
-
_reject_unpermitted_characters: This was the function with the flawed logic. It only checked for \r, \n, and \x00, which was an incomplete implementation of the checks required by the relevant RFCs. An attacker could use other control characters to bypass this check. The entire function was removed as part of the fix.
-
validate_headers: This function acts as the entry point for header validation. It was vulnerable because it relied on the inadequate _reject_unpermitted_characters function. The patch retargets this function to call a new, more secure function, _reject_illegal_characters, which implements the stricter validation rules defined in RFC 9113.
During a potential exploit, a profiler would show validate_headers being called, which in turn would execute the vulnerable character validation logic within _reject_unpermitted_characters in unpatched versions. Therefore, both functions are critical runtime indicators for this vulnerability.