Skip to content
Misconfiguration Disclosed report Advanced

28: HTTP/3 UDP path ignores CURL_SOCKOPT_ALREADY_CONNECTED, reconnects callback-provided socket

The HTTP/3 UDP connection path in curl ignores the CURL_SOCKOPT_ALREADY_CONNECTED callback result and calls connect() on the application-supplied socket, reassociating it to the URL's destination. An attacker could cause traffic intended for an application-chosen relay or egress endpoint to be sent to a different peer instead.

giant_anteater Follow

Originally disclosed on HackerOne

  • Disclosed after 42 hours

Summary

When CURLOPT_SOCKOPTFUNCTION returns CURL_SOCKOPT_ALREADY_CONNECTED, the HTTP/3 (QUIC) UDP code path ignores it and calls connect() anyway, silently reassociating the application-provided socket to a different peer. The TCP path has the correct check. This violates the documented callback contract and can bypass an application-controlled relay or egress route.

The same class of bug was previously reported for TCP in #10626 and fixed by #10648 (commit 233810bb), but the equivalent UDP path was missed.

Root cause

In lib/cf-socket.c, cf_socket_open() records CURL_SOCKOPT_ALREADY_CONNECTED by setting cf->connected = TRUE.

cf_tcp_connect() checks this flag immediately after cf_socket_open() returns and short-circuits:

C
// lib/cf-socket.c, inside cf_tcp_connect(), after cf_socket_open():
if(cf->connected) {
  *done = TRUE;
  return CURLE_OK;
}

cf_udp_connect() has no such check. After cf_socket_open() sets cf->connected, it proceeds unconditionally into cf_udp_setup_quic(), which calls connect() with the URL's destination address, overwriting the application's chosen peer on the same file descriptor.

Reproduction

Expected output (port numbers will vary):

Vulnerable build:

VERDICT=VULNERABLE

The socket's getpeername() reports endpoint B (the URL target), B received 2 QUIC Initial datagrams (2400 bytes), A received nothing. The SO_BROADCAST marker set in the sockopt callback persists, confirming this is the same file descriptor, not a replacement socket.

Patched control:

VERDICT=FIXED

The socket's getpeername() still reports endpoint A (the callback-chosen peer), A received the 2 QUIC Initial datagrams, B received nothing.

The final line VERDICT_VALIDATED=YES confirms both checks passed.

No HTTP/3 server is required; the PoC uses two bare UDP listeners. The timeout (CURLE_OPERATION_TIMEDOUT) is expected because neither listener answers the QUIC handshake.

Impact

An application can use CURLOPT_OPENSOCKETFUNCTION + CURLOPT_SOCKOPTFUNCTION to supply a UDP socket already connected through a relay, policy boundary, or selected egress endpoint. With HTTP/3, curl silently reassociates that socket with its own resolved destination and sends pre-authentication QUIC Initial datagrams there instead.

Preconditions for exposure:

  1. HTTP/3 is used
  2. The application supplies an already-connected UDP descriptor via CURLOPT_OPENSOCKETFUNCTION
  3. CURLOPT_SOCKOPTFUNCTION returns CURL_SOCKOPT_ALREADY_CONNECTED

This is a specialized callback arrangement. I have not identified a production application relying on it, so I am reporting the confirmed contract and routing violation for the security team to assess rather than asserting a particular severity.

The original report as published on HackerOne, by giant_anteater. 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

The UDP connect function lacks the check for the already-connected flag that the TCP connect function performs after opening the socket.

Impact

An application relying on a callback-supplied, already-connected UDP socket for HTTP/3 could have its traffic silently redirected to curl's resolved destination, bypassing the intended relay or egress route; the reporter has not identified a production application using this arrangement.

What the attacker needed

HTTP/3 is used; Application supplies an already-connected UDP socket; Sockopt callback returns already-connected

The fix

The UDP connect path should check the already-connected flag after opening the socket and return early, as the TCP path does.

How it was found

  1. Provide a UDP socket already connected to endpoint A via the open-socket callback.
  2. Return the already-connected option from the sockopt callback.
  3. Make an HTTP/3 request to endpoint B.
  4. Observe that the socket's peer is now B and that B received the QUIC Initial datagrams while A received nothing.

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.

curl lets an application provide its own network socket and tell curl that the socket is already connected to the right place. In the HTTP/3 code path, curl ignored that instruction and connected the socket to a different address anyway. This means data the application meant to send through its own chosen route could go somewhere else.

What is Misconfiguration?

Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.

More by giant_anteater

View all

93 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.

Security misconfiguration

The lesson behind this report.

Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.