The vulnerability is a request smuggling issue in swift-nio-http2 where the HTTP/2 to HTTP/1.1 codec fails to validate control characters (CR, LF, NUL) in HTTP/2 pseudo-headers like :path. An attacker can send a crafted HTTP/2 request with these characters in a pseudo-header. When the swift-nio-http2 server, acting as a reverse proxy, translates this to an HTTP/1.1 request, the control characters are not sanitized. This allows the attacker to inject new headers or even a new, "smuggled" HTTP/1.1 request into the backend server's request stream.
The analysis of the patch 61d1b44f6e4e118792be1cff88ee2bc0267c6f9a reveals the fix. The core of the fix is the introduction of the HPACKHeaders.isValidPseudoHeaderValue function, which checks for the forbidden characters.
This new validation is applied in two key places:
HPACKHeaders.validateRequestBlock(supportsExtendedConnect:): This function is responsible for validating incoming request headers. The patch adds a check to ensure pseudo-header values are validated. Before the patch, this validation was missing.
HPACKHeaders.validateAndExtractPseudoHeader(name:as:): This function extracts pseudo-header values. The patch adds a call to isValidPseudoHeaderValue to validate the value before returning it.
The main entry point for processing incoming data in the vulnerable component is the channelRead method of HTTP2FramePayloadToHTTP1ServerCodec. This function receives the HTTP/2 frames containing the malicious headers and would initiate the call chain leading to the vulnerable validation functions. Therefore, channelRead would appear in a runtime profile during exploitation.