Skip to content
Crypto Disclosed report Advanced

10: CURLOPT_MAXLIFETIME_CONN bypass on active HTTP/2 connections

libcurl fails to enforce the CURLOPT_MAXLIFETIME_CONN age limit when a new transfer is attached to an already-active multiplexed HTTP/2 connection, because the age check is skipped for in-use connections. An attacker could cause a new transfer to silently reuse an over-age connection, bypassing the certificate revalidation that a fresh connection would perform.

giant_anteater Follow

Originally disclosed on HackerOne

  • Disclosed after 18 days

Summary

CURLOPT_MAXLIFETIME_CONN is not enforced when a new transfer is attached to an active multiplexed HTTP/2 connection. The connection-age eligibility check in url_match_conn() is gated behind !CONN_INUSE(conn), so an in-use HTTP/2 connection with spare stream capacity is accepted without any age check. A new transfer silently reuses an over-age connection, bypassing certificate revalidation.

Since 8.17.0 this option defaults to 24 hours and libcurl-security.md recommends it as the mechanism to bound how long a validated connection remains eligible: "Further transfers require a new connection with validation performed again." The bypass defeats that guarantee for any multiplexed connection that still has an active stream.

Root cause

In lib/url.c, url_match_conn() calls Curl_cpool_conn_seems_healthy() only for idle connections:

C
if(!CONN_INUSE(conn) &&
   !Curl_cpool_conn_seems_healthy(conn, m->data, &m->now)) {

An active multiplexed connection passes url_match_multiplex_limits() (stream capacity check) and then falls through directly to m->found = conn without any health or age check.

Inside Curl_cpool_conn_seems_healthy() in lib/conncache.c, the age check is also guarded:

C
if(!CONN_INUSE(conn) && cpool_conn_maxage(data, conn, pnow))
  return FALSE;

So the creation-age check (conn_max_age_ms) never evaluates for an in-use multiplexed connection.

Reproduction

Tested at commit c2676bf9e639e31e44b12a2cc82cf2046231b056 with OpenSSL and nghttp2. All files below are self-contained in a Docker build.

docker build -t curl-maxlifetime-h2-poc .
docker run --rm curl-maxlifetime-h2-poc

The PoC does:

  1. Generate CA A, unrelated CA B, and a localhost server cert signed by CA A.
  2. Start an HTTP/2 TLS server on port 8443.
  3. Transfer A opens an HTTP/2 stream using CA A. The server holds this stream open (sends headers but no end-of-stream), keeping the connection active.
  4. Wait 2.2 seconds (CURLOPT_MAXLIFETIME_CONN is set to 1 second).
  5. Replace the CA file on disk with CA B (same path). TLS session cache and CA cache are disabled.
  6. Transfer B is added normally. It succeeds on the same connection (conn_id=0, num_connects=0) — the age check was skipped.
  7. Transfer C is added with CURLOPT_FRESH_CONNECT=1 as a control. It opens a new connection and fails with CURLE_PEER_FAILED_VERIFICATION (60), proving the CA replacement is effective.

Suggested fix

Apply the creation-age eligibility check before attaching any matching connection, including active multiplexed ones. An over-age active connection should be rejected for the new transfer and marked non-reusable, while allowing its existing streams to finish normally.

Affected versions

7.80.0 through 8.21.0+ (current master). The severity increased in 8.17.0 when the option became enabled by default (24-hour lifetime).

Impact

Summary:

A new transfer can silently reuse an HTTP/2 connection that has exceeded its configured maximum lifetime, bypassing the certificate revalidation that would occur on a fresh connection.

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 connection-age eligibility check is gated behind a 'not in use' condition, so active multiplexed HTTP/2 connections are accepted without any age or health check.

Impact

A new transfer can silently reuse an HTTP/2 connection that has exceeded its configured maximum lifetime, bypassing the certificate revalidation that would occur on a fresh connection.

What the attacker needed

HTTP/2 multiplexing in use; an active stream on the connection; connection older than the configured lifetime

The fix

The creation-age eligibility check should be applied before attaching any matching connection, including active multiplexed ones, rejecting over-age connections for new transfers while letting existing streams finish.

How it was found

  1. Generate a CA, an unrelated CA, and a server certificate signed by the first CA.
  2. Start an HTTP/2 TLS server and open a stream that the server keeps active.
  3. Wait longer than the configured maximum connection lifetime.
  4. Replace the CA file on disk with the unrelated CA.
  5. Add a new transfer and observe it succeeds on the same connection.
  6. Add a control transfer with a fresh-connect option and observe it fails certificate verification.

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.

libcurl is a library programs use to make network requests. It has a setting that says a connection should only be trusted for a limited time, after which a new connection must be made and the server's certificate checked again. This report shows that when an HTTP/2 connection is still busy with another request, that time limit is ignored, so a new request can ride on an old connection without the certificate being checked again.

What is Crypto?

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.

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.

Cryptographic weaknesses

The lesson behind this report.

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.