// 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;
}
libcurl 的 HTTP/2 代理 CONNECT 实现在隧道建立后未能正确隔离流。攻击者控制一个 HTTP/2 流后,可以向另一个独立的隧道注入数据,从而导致响应走私或凭据拦截。
编译并运行该模拟程序:
gcc -o curl_http2_tunnel curl_http2_tunnel_mixup.c
./curl_http2_tunnel
输出结果显示了流跨越隧道边界的情况。