Skip to content
Smuggling / CRLF Disclosed report Advanced

curl CONNECT response header colon-check bypass in cf-h1-proxy single_header — proxy authentication bypass via injected HTTP/1.x status line

In curl's HTTP/1.1 proxy-CONNECT response parser, the per-request header line counter is never incremented, so the colon-presence check that normally rejects garbage lines in the header area is skipped. A malicious proxy can therefore inject a line shaped like an HTTP/1.x status line into a 407 response, overwrite the status code to 200, and make curl believe the tunnel is established, causing it to send the real request and proxy credentials to the attacker.

noraqiu Follow

Originally disclosed on HackerOne

  • Disclosed after 2 days

Summary

In the HTTP/1.1 proxy-CONNECT response parser (lib/cf-h1-proxy.c, single_header()), the per-line counter data->req.headerline (a.k.a. k->headerline) is never incremented — only the tunnel-local ts->headerlines is. Curl_req_soft_reset() resets k->headerline to 0 before the CONNECT exchange begins, and it stays 0 for the entire CONNECT response. Curl_verify_header() (lib/http.c) treats k->headerline < 2 as "this is a status line" and returns CURLE_OK without performing its colon-presence check, so that colon check — which exists precisely to reject garbage/injected lines in the header area — is dead code on the CONNECT path. The normal HTTP response path (http_rw_hd) increments k->headerline (if(!k->headerline++)), so the guard works there and only there.

Because the colon check is inert on the CONNECT path, a malicious proxy can inject a line shaped like an HTTP/1.x status line into the header area of a 407 Proxy Authentication Required response. on_resp_header() matches any line beginning with HTTP/1. (without checking whether it is the first/status line, and without requiring a colon) and overwrites k->httpcode and data->info.httpproxycode with the parsed status code. Injecting HTTP/1.1 200 OK: x overwrites the 407 with 200. The end-of-headers empty-line handler then sees httpcode == 200 (not 407) and proceeds to KEEPON_DONE; recv_CONNECT_resp() sees httpproxycode/100 == 2 and skips Curl_http_auth_act(); H1_CONNECT() sees the same 2xx and marks the tunnel H1_TUNNEL_ESTABLISHED. The client believes the tunnel is up, never retries with proxy authentication, and sends the real request — Cookie, Authorization, POST bodies, and the Proxy-Authorization header from the CONNECT request — over the attacker's connection.

The injected line must carry a colon (e.g. HTTP/1.1 200 OK: x) to satisfy the secondary colon check in Curl_headers_push() → namevalue(). This does not change the root cause; it only shapes the payload.

Impact variant (all verified end-to-end) Target scheme What the attacker captures / controls
Plaintext request leak http:// target Full request: method, Host, Cookie, Authorization, POST body; attacker can also return a forged response (integrity)
TLS ClientHello intercept https:// target TLS ClientHello incl. SNI and connection metadata; TLS content stays encrypted; attacker may send a TLS alert to kill the connection (availability)
Proxy-credential capture any CONNECT Proxy-Authorization: Basic from the CONNECT request, base64-decoded to user:password
No-auth-configured hijack any target, no --proxy-user Tunnel still marked established; plaintext HTTP request captured

Affected versions

  • curl 8.21.0-DEV (mbedTLS 3.6.5 debug build).
  • Current master 9b2caf3 (8.22.0-DEV, verified 2026-08-31). Still affected. all five verification checks pass; verbose output is byte-for-byte identical to 8.21.0-DEV: the 407 is overwritten to 200 by the injected line, * CONNECT tunnel established, response 200 is printed, and the tunneled request carrying Cookie: secret=session123 + Authorization: Bearer sensitive_token is captured (curl/8.22.0-DEV User-Agent).
  • lib/cf-h1-proxy.c single_header() (master line 474) still only does ts->headerlines++; data->req.headerline is never incremented, and k is a const pointer (line 470) so the existing code cannot mutate it. No fix has landed.

PoC

The attacker operates a malicious HTTP proxy (or is a man-in-the-middle between the curl client and the legitimate proxy — curl's documented attacker capability "B"). The client uses curl with --proxy-tunnel (-p) or simply requests an https:// target through the proxy (which forces a CONNECT), and has proxy authentication configured (--proxy-user / CURLOPT_PROXYUSERPWD). The client's request also carries sensitive headers (Cookie, Authorization).

  1. The client sends CONNECT <host>:<port> HTTP/1.1 to the attacker's proxy, including a Proxy-Authorization: Basic <base64(user:pass)> header.

  2. The attacker responds with a 407 challenge and, in the header area, an injected line:

    HTTP/1.1 407 Proxy Authentication Required\r\n
    Proxy-Authenticate: Basic realm="proxy"\r\n
    HTTP/1.1 200 OK: x\r\n
    Content-Length: 0\r\n
    \r\n
    

    The injected HTTP/1.1 200 OK: x carries a colon (required to pass the secondary namevalue() colon check) while still matching the HTTP/1. prefix pattern in on_resp_header().

  3. Curl_verify_header() returns CURLE_OK for the injected line (headerline == 0 < 2, colon check skipped).

  4. Curl_headers_push() → namevalue() accepts the line (it contains a colon).

  5. on_resp_header() matches the HTTP/1.x pattern and overwrites k->httpcode / data->info.httpproxycode from 407 to 200.

  6. At the empty line, httpcode is 200, so the handler takes the KEEPON_DONE branch instead of KEEPON_IGNORE.

  7. recv_CONNECT_resp() sees httpproxycode/100 == 2 and does not call Curl_http_auth_act() — no authentication retry, data->req.newurl is not set.

  8. H1_CONNECT() sees 2xx and marks the tunnel H1_TUNNEL_ESTABLISHED; cf_h1_proxy_connect sets cf->connected = TRUE.

  9. The client, believing the tunnel is established, sends the real request over the attacker's connection. For an http:// target this is the full plaintext request (Cookie, Authorization, POST body); for an https:// target it is the TLS ClientHello (SNI exposed, TLS content encrypted).

The negative control — the same injection without -p (normal HTTP proxy path through http_rw_hd, where k->headerline is incremented) — does not overwrite httpcode, does not establish a tunnel, and does not bypass authentication, confirming the bug is specific to the CONNECT response path. The full proof-of-concept script (malicious proxy) is available on request.

Impact

  • CVSS 3.1: 9.6 (Critical) — AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:N.
  • Trigger conditions: The attacker must operate a malicious HTTP proxy or be positioned as a MITM between the client and the legitimate proxy (curl's documented attacker capability "B"). No privileges on the client host are required. The client must use CONNECT tunnelling (-p / --proxy-tunnel, or any https:// request through a proxy). The injected line must carry a colon to pass the secondary namevalue() check.
  • Realized impact:
    • http:// targets: full plaintext request captured — Cookie, Authorization, POST bodies, and all custom headers; the attacker can also return a forged HTTP response (integrity). Session hijacking and API-key/credential disclosure.
    • Proxy authentication is fully bypassed — even with CURLOPT_PROXYUSERPWD set, the auth retry never fires.
    • The Proxy-Authorization: Basic header from the CONNECT request is captured and base64-decoded to plaintext proxy credentials.
    • https:// targets: TLS ClientHello (incl. SNI) is intercepted; TLS-encrypted content is not exposed. The attacker may send a TLS alert to terminate the connection (availability), or complete a MITM if the client has disabled TLS verification (-k).
  • Severity bound: The C:H/I:H is fully realized for plaintext HTTP targets and for proxy-credential capture. For HTTPS targets the confidentiality impact is bounded to SNI/connection-metadata exposure (TLS content remains encrypted), and the availability impact is limited to connection termination. The attack requires the attacker to control the proxy or be a MITM; it does not grant the attacker any new network position they did not already hold, but it defeats proxy authentication — the mechanism intended to gate access to the proxy and to the upstream — and turns a proxy that would have rejected the unauthenticated CONNECT into one that silently exfiltrates the client's request and credentials.

The original report as published on HackerOne, by noraqiu. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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 CONNECT response parser increments only a tunnel-local header line counter and never the request-level counter that the header verification routine uses to decide whether a line is a status line, so its colon check is skipped for every line of the CONNECT response.

Impact

For plaintext HTTP targets the attacker captures the full request including cookies, authorization headers and POST bodies and can return forged responses, and proxy credentials are exposed; for HTTPS targets only the TLS ClientHello and SNI are exposed and the attacker may terminate the connection, with full interception only if the client has disabled TLS verification.

What the attacker needed

Attacker runs or sits in front of the proxy; client uses CONNECT tunnelling; injected line must contain a colon

The fix

The CONNECT response parser should increment the request-level header line counter so the colon check applies, and the status-line matcher should only accept a status line in the first position; the text states no fix has landed.

How it was found

  1. The client sends a CONNECT request to the attacker's proxy, including a Proxy-Authorization header.
  2. The attacker replies with a 407 challenge containing an injected line shaped like an HTTP/1.x status line with a colon.
  3. The header verification routine skips its colon check because the line counter is still zero.
  4. The response header handler matches the injected line and overwrites the status code from 407 to 200.
  5. At the end of the headers the handler treats the response as complete rather than ignored, and no authentication retry is triggered.
  6. The tunnel is marked established and the client sends the real request over the attacker's connection.

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.

When curl talks to a proxy to reach a secure site, it first asks the proxy to open a tunnel, and the proxy may reply '407, please log in'. curl reads that reply line by line and has a safety check that rejects lines that do not look like proper headers. Here that check was accidentally switched off for this one kind of reply, so a hostile proxy could slip in a fake 'success' line. curl then thought the tunnel was open and sent the user's cookies, tokens and proxy password straight to the attacker.

What is Smuggling / CRLF?

A front end and a back end split one connection's bytes into requests differently, letting an attacker hide a request inside another user's.

More by noraqiu

View all

5 more disclosed reports, best first.

More from curl

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Request smuggling and header injection

The lesson behind this report.

A front end and a back end split one connection's bytes into requests differently, letting an attacker hide a request inside another user's.