
// curl_http2_tunnel_mixup.c - Simulated libcurl handling CONNECT over HTTP/2
#include <stdio.h>
void handle_http2_stream(int stream_id) {
// Vulnerability: after CONNECT, the proxy mixes streams with the tunneled data
if (stream_id == 0) {
printf("CONNECT to target\n");
} else {
// Data from another stream may leak into the tunnel
printf("Stream %d data crosses tunnel boundary\n", stream_id);
}
}
int main() {
handle_http2_stream(0);
handle_http2_stream(1); // should be isolated
return 0;
}
A vulnerability in libcurl’s HTTP/2 proxy CONNECT implementation fails to properly isolate streams after the tunnel is established. An attacker with control over one HTTP/2 stream can inject data into a separate tunnel, leading to response smuggling or credential interception.
Compile and run the simulation:
gcc -o curl_http2_tunnel curl_http2_tunnel_mixup.c
./curl_http2_tunnel
Output shows stream crossing the tunnel boundary.