Integer Overflow Risk in HTTP/2 Proxy Window Size Calculations
The HTTP/2 proxy code in curl may have integer overflow and excessive window size issues that could lead to memory corruption or denial of service. An attacker controlling a malicious proxy could exploit these to cause resource exhaustion or crashes.
Originally disclosed on HackerOne
- Disclosed after 34 hours
Summary: The HTTP/2 proxy implementation in curl contains potential integer overflow vulnerabilities in buffer size calculations that could lead to memory corruption or denial of service.
AI Usage Statement: This report was prepared by a human security researcher after manual code review. No AI was used to generate this report.
Affected Version: All curl versions containing the HTTP/2 proxy implementation (since introduction of the feature). Tested with curl 8.6.0 on Linux x86_64. Examine the window size calculations in cf-h2-proxy.c: #define PROXY_H2_CHUNK_SIZE (16*1024) #define H2_TUNNEL_WINDOW_SIZE (10 * 1024 * 1024) #define PROXY_H2_NW_RECV_CHUNKS (H2_TUNNEL_WINDOW_SIZE / PROXY_H2_CHUNK_SIZE)
The calculation H2_TUNNEL_WINDOW_SIZE / PROXY_H2_CHUNK_SIZE could overflow if either value is manipulated via malicious HTTP/2 frames.
nghttp2_session_set_local_window_size(ctx->h2, NGHTTP2_FLAG_NONE, 0, PROXY_HTTP2_HUGE_WINDOW_SIZE); uses a 100MB window size (PROXY_HTTP2_HUGE_WINDOW_SIZE) which could lead to memory exhaustion.
Supporting Material/References:
The vulnerable code is in lib/cf-h2-proxy.c in the curl source repository
Similar vulnerabilities have been found in other HTTP/2 implementations (CVE-2019-9511, CVE-2019-9513)
Impact
An attacker controlling a malicious HTTP/2 proxy server could potentially:
Cause integer overflows leading to memory corruption
Trigger resource exhaustion via extremely large window sizes
Cause denial of service through crafted window size advertisements
The impact is limited to:
Systems using curl with HTTP/2 proxy support enabled
When connecting to untrusted or compromised HTTP/2 proxies
Requires the attacker to be in a MITM position or control the proxy server
Recommended Fixes Add bounds checking for window size calculations
Implement reasonable maximum limits for window sizes
Add validation of window size advertisements from peers
Consider using saturating arithmetic for size calculations
Additional Information This vulnerability was discovered through manual code review focusing on integer handling in the HTTP/2 proxy implementation. The risk is somewhat mitigated by the fact that it requires proxy server compromise or MITM position, but the potential impact justifies addressing these issues.
The vulnerability shares characteristics with known HTTP/2 implementation flaws that have been exploited in other software (e.g., nghttp2, Apache HTTP Server).
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely, the code does not properly check or limit window size values received from the proxy, leading to integer overflow or excessive memory allocation.
Impact
An attacker controlling a malicious HTTP/2 proxy could potentially cause integer overflows leading to memory corruption, trigger resource exhaustion via extremely large window sizes, or cause denial of service through crafted window size advertisements.
What the attacker needed
Curl with HTTP/2 proxy support; attacker controls or MITMs the proxy
The fix
The report recommends adding bounds checking for window size calculations, implementing reasonable maximum limits, validating window size advertisements, and considering saturating arithmetic.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
This report is about a possible bug in curl, a tool for downloading files. The bug is in the part that talks to proxy servers using a newer version of HTTP. If a bad proxy sends tricky numbers, curl might get confused and crash or use too much memory. The report is based on reading the code, not on actually breaking into a system.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.