CVE-2026–8932: curl/libcurl mTLS Connection Reuse Vulnerability
libcurl's connection reuse check ignored several client-certificate options, so two easy handles with different private keys could share an already-authenticated mTLS connection. An attacker could then have their request processed as another user's identity.
medium.com
Published on medium.com
Cve
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
libcurl does not open a fresh TLS connection for every transfer. It keeps established TLS connections in a connection pool and reuses them for later transfers whose settings appear to match. The decision about whether two easy handles may share a connection is made by comparing their TLS configuration, and that comparison is where this bug lived.
CVE-2026-8932 is a logic flaw in that comparison. Five client-certificate options were silently left out of it: SSLKEY, SSLKEYTYPE, KEYPASSWD, SSLCERTTYPE and SSLKEYBLOB. Two easy handles that differed only in those options could therefore end up sharing the same already-authenticated mTLS connection. The curl team classified it as CWE-305 (Authentication Bypass) and was explicit that it is a pure logic flaw, not a memory-safety bug, pointing to CVE-2022-27782 as a similar prior case.

Setup
The exposure is limited to long-running applications that share a connection pool across multiple easy handles, via a CURLSH share handle or a multi handle, while switching client-certificate credentials between them. A typical case is a server-side proxy or API gateway that authenticates different users to a backend over mTLS, each with their own client-certificate private key.
The curl CLI itself is unaffected, because each invocation is a fresh process with its own connection pool. No special tooling is needed to reason about the bug: the relevant code is in lib/vtls/vtls.c, and the fix was validated with two new test cases, 3303 and 3304.
Finding it
libcurl keeps TLS settings in two different structs:
ssl_primary_config, the struct actually used bymatch_ssl_primary_config()to decide whether a connection can be reused, and by the TLS session-cache keyssl_config_data, a larger struct holding the rest of the TLS configuration, which embedsssl_primary_configas a member
The five fields needed to actually open a client certificate, cert_type, key, key_type, key_passwd and key_blob, lived in ssl_config_data, not in ssl_primary_config. Since match_ssl_primary_config() only compares ssl_primary_config, those five fields were entirely outside its field of view. Before the patch, ssl_config_data looked roughly like this:
struct ssl_config_data { char *cert_type; char *key; struct curl_blob *key_blob; char *key_type; char *key_passwd; BIT(certinfo); };
And the reuse-check function in lib/vtls/vtls.c only compared ssl_primary_config fields:
static bool match_ssl_primary_config(struct Curl_easy *data, struct ssl_primary_config *c1, struct ssl_primary_config *c2){ if(Curl_safecmp(c1->CApath, c2->CApath) && Curl_safecmp(c1->CAfile, c2->CAfile) && Curl_safecmp(c1->issuercert, c2->issuercert) && Curl_safecmp(c1->clientcert, c2->clientcert) && Curl_safecmp(c1->CRLfile, c2->CRLfile) && Curl_safecmp(c1->pinned_key, c2->pinned_key)) return TRUE; return FALSE;}
clientcert, the certificate file path, was compared, but the fields that determine which private key opens that certificate, key and key_passwd, were not. If two handles used the same SSLCERT but different SSLKEY values, the function would still conclude "same config" and let the connection be reused.
The TLS session cache had a parallel issue. Its cache key appended a fixed string, ":CCERT", to represent "this session used a client cert", without encoding which certificate. Sessions using different client certificates could therefore also collide in the session cache.

The diagram shows the split: the left card lists the fields match_ssl_primary_config() actually compares (ssl_primary_config), and the right card lists the five fields that were excluded before the patch (ssl_config_data).
Exploitation

Step 1: Handle A authenticates
Handle A connects with SSLCERT=client.pem and SSLKEY=keyA.pem, completes the mTLS handshake, and the resulting connection is cached in the pool as "authenticated as user A".
Step 2: Handle B asks for a connection
Handle B sends a request using the same SSLCERT=client.pem but a different SSLKEY=keyB.pem.
Step 3: The comparison passes
match_ssl_primary_config() only checks that clientcert matches, so Handle B is handed the already-authenticated connection from Handle A without a new TLS handshake.
Step 4: The server attributes the request to user A
From the server's point of view, this connection is still verified against user A's mTLS certificate, so it processes Handle B's request as if it came from user A.
In effect, two requests intended to authenticate as different identities end up sharing the same authenticated channel simply because their private keys differed.
Root cause
The mistake is structural. The fields that identify which private key opens a client certificate were stored in ssl_config_data, while the reuse decision only ever looked at ssl_primary_config. The comparison was correct for every field it could see; the five key-related fields were simply not part of the struct it compared. Comparing clientcert alone was not enough, because the certificate path does not determine the private key used with it.
The session cache repeated the same assumption in a different form: a fixed ":CCERT" marker recorded that a client certificate was used, but not which one, so distinct client certificates could map to the same cache entry.
Impact
In an application that pools connections across easy handles and switches client-certificate credentials between them, a request can be processed under another user's mTLS identity. The server sees a connection already verified against the first user's certificate and treats the second handle's request as coming from that user.
The conditions are narrow. The curl CLI is unaffected. Only long-running applications that share a connection pool via CURLSH or a multi handle, and that switch client-certificate credentials between handles, are exposed, such as a proxy or gateway authenticating different users over mTLS.
The bug traces back to commit a1d6ad2 around curl 7.7 (roughly 2010) and existed for nearly 16 years before being fixed in curl 8.21.0.
Fix
The fix in commit 7541ae5 promotes the five affected fields from ssl_config_data into ssl_primary_config:
struct ssl_primary_config { char *pinned_key; char *CRLfile; char *cert_type; char *key; char *key_type; char *key_passwd; struct curl_blob *cert_blob; struct curl_blob *ca_info_blob; struct curl_blob *issuercert_blob; struct curl_blob *key_blob; };
The comparison function now checks all five. Notably, key_passwd is compared with Curl_timestrcmp(), a timing-attack-resistant string comparison:
static bool match_ssl_primary_config(struct Curl_easy *data, struct ssl_primary_config *c1, struct ssl_primary_config *c2){ if( Curl_safecmp(c1->pinned_key, c2->pinned_key) && curl_strequal(c1->cert_type, c2->cert_type) && Curl_safecmp(c1->key, c2->key) && curl_strequal(c1->key_type, c2->key_type) && !Curl_timestrcmp(c1->key_passwd, c2->key_passwd)) return TRUE; return FALSE;
Because the fields moved, every backend file referencing them had to change, 19 files in total, including openssl.c, gtls.c, mbedtls.c, rustls.c, schannel.c, wolfssl.c, libssh.c, libssh2.c and ldap.c. References like ssl_config->key became ssl_config->primary.key. The OpenSSL backend, for example, changed like this:
result = client_cert(data, octx->ssl_ctx, ssl_cert, ssl_cert_blob, ssl_cert_type, ssl_config->key, ssl_config->key_blob, ssl_config->key_type, ssl_config->key_passwd);result = client_cert(data, octx->ssl_ctx, ssl_cert, ssl_cert_blob, ssl_cert_type, ssl_config->primary.key, ssl_config->primary.key_blob, ssl_config->primary.key_type, ssl_config->primary.key_passwd);
On the session-cache side, the fixed ":CCERT" marker was replaced with the actual clientcert path value, so sessions using different client certificates can no longer share a cache entry. clone_ssl_primary_config() and free_primary_ssl_config() also gained clone/free logic (CLONE_STRING, CLONE_BLOB, curlx_safefree) for the newly relocated fields. The fix was validated with two new test cases, 3303 and 3304.
Remediation options:
- Upgrade libcurl to 8.21.0 or later (recommended).
- If upgrading is not possible yet, backport commit
7541ae5and rebuild. - As a temporary mitigation, avoid reusing handles when client-certificate credentials change; create a new handle instead.
Variants to test
- Other pooled TLS settings that live outside the compared struct. Look for any option that affects the authenticated identity of a connection but is stored in a struct the reuse check does not read. A positive result is two handles with different identity-bearing options receiving the same pooled connection without a new handshake.
- Session-cache key collisions. Check whether any cache key component is a fixed marker rather than the value that distinguishes sessions. A positive result is two sessions with different client certificates resolving to the same cache entry.
- Shared pools in proxies and gateways. Exercise a
CURLSHor multi-handle setup that switches client-certificate credentials between requests. A positive result is the backend attributing the second request to the first user's certificate. - Handle reuse after credential changes. Reuse an existing handle after changing
SSLCERTorSSLKEYinstead of creating a new one. A positive result is the old authenticated connection being used for the new credentials. - Backend coverage. Repeat the comparison review across TLS backends (
openssl.c,gtls.c,mbedtls.c,rustls.c,schannel.c,wolfssl.c), since the fix touched 19 files. A positive result is a backend that still reads the relocated fields from the old location or omits one from the comparison.
What happened, in plain words
A very widely used piece of software called curl (and its library form, libcurl) had a bug in how it decided whether it could reuse an already-open secure connection. Under certain conditions, a request that was supposed to be made as one user could be sent over a connection that had been authenticated as a different user. The curl team called this an authentication bypass: the check that was supposed to keep identities apart did not do its job.
This article walks through what the software does, where the mistake was, how the mistake could be abused, and how it was fixed. You do not need to know how to program to follow it. Every technical word is explained the first time it appears, and there is a glossary at the end.

The background you need first
What curl and libcurl are
curl is a command-line program that fetches things from the internet: a web page, a file, an API response. You type a command, it makes a network request, it prints the answer. libcurl is the same engine packaged as a library, meaning other programs can call it from inside their own code instead of running the curl program. Many applications, including server-side programs, use libcurl to talk to other servers.
What TLS is
TLS (Transport Layer Security) is the technology that turns a normal network connection into an encrypted one. When your browser shows a padlock, TLS is what put it there. It does two jobs: it scrambles the traffic so nobody in the middle can read it, and it lets each side prove who it is.
What mTLS is
Normally only the server proves its identity to the client: that is the padlock. mTLS (mutual TLS) means both sides prove who they are. The client also presents a certificate. This is common between servers: a proxy or gateway connecting to a backend service can prove it is allowed to be there.
What a client certificate and a private key are
A client certificate is a digital identity document. It says "this is who I am" and is signed by someone the other side trusts. A private key is the secret half that proves you really own that certificate. Think of the certificate as a passport and the private key as your face: the passport alone proves nothing unless you can show the face that matches it. In practice the two are usually stored as two separate files, and the software is told where each one is.
What a connection pool is
Opening a TLS connection is slow: several messages have to go back and forth and cryptographic maths has to be done. So libcurl does not open a fresh one for every request. It keeps finished, working connections in a connection pool and reuses them for later requests that look like they need the same settings. It is like keeping a few taxis parked outside instead of calling a new one for every trip.
What an easy handle is
In libcurl, an easy handle is the object that represents one transfer: one request with its own settings. A program can have several easy handles at once. When several handles are allowed to draw connections from the same pool, the library has to decide whether handle B may use the connection that handle A already opened. That decision is made by comparing their settings.
What the vulnerability class means
CWE-305, Authentication Bypass, is a category of bug where a program is supposed to check who someone is, and the check can be avoided or made to pass when it should not. Nothing crashes, nothing is corrupted: the program simply believes something untrue about identity. The curl team was explicit that this is a pure logic flaw, not a memory-safety bug, and pointed to CVE-2022-27782 as a similar prior case.
Context: where the bug lives
libcurl does not open a fresh TLS connection for every transfer. It keeps established TLS connections in a connection pool and reuses them for later transfers whose settings appear to match. The decision about whether two easy handles may share a connection is made by comparing their TLS configuration, and that comparison is where this bug lived.
CVE-2026-8932 is a logic flaw in that comparison. Five client-certificate options were silently left out of it: SSLKEY, SSLKEYTYPE, KEYPASSWD, SSLCERTTYPE and SSLKEYBLOB. Two easy handles that differed only in those options could therefore end up sharing the same already-authenticated mTLS connection.
In plain terms: the library asked "are these two requests configured the same?" but forgot to look at five of the settings that say which key is being used. If two requests used the same certificate but different private keys, the library saw them as identical.

Setup: who is actually affected
The exposure is limited to long-running applications that share a connection pool across multiple easy handles, via a CURLSH share handle or a multi handle, while switching client-certificate credentials between them. A typical case is a server-side proxy or API gateway that authenticates different users to a backend over mTLS, each with their own client-certificate private key.
A few of those words need unpacking:
- A long-running application is a program that stays alive for a long time and serves many requests, such as a web service, rather than a program you run once and close.
- A share handle (
CURLSH) is libcurl's mechanism for letting several easy handles deliberately share things, including connections. - A multi handle is another libcurl mechanism for running several transfers together, which also lets them share connections.
- A proxy is a server that sits between clients and a backend and forwards requests on their behalf.
- An API gateway is a front door for a set of backend services: all requests come in through it, and it decides where each one goes and who is allowed to make it.
The curl CLI itself is unaffected, because each invocation is a fresh process with its own connection pool. When you type a curl command in a terminal, the program starts, does its one job, and exits. There is no pool left over for a second request to reuse, so the bug cannot show up there.
No special tooling is needed to reason about the bug: the relevant code is in lib/vtls/vtls.c, and the fix was validated with two new test cases, 3303 and 3304. A test case here is an automated check in curl's own test suite that reproduces a scenario and confirms the software behaves correctly.
Finding it: two boxes and a forgotten list
To understand the mistake you need one idea from programming: a struct. A struct is a labelled box that groups related pieces of information together. If you were writing software for a car rental company, you might have a struct called car holding colour, plate_number and mileage. Programs read and compare these boxes all the time.
libcurl keeps TLS settings in two different structs:
ssl_primary_config, the struct actually used bymatch_ssl_primary_config()to decide whether a connection can be reused, and by the TLS session-cache keyssl_config_data, a larger struct holding the rest of the TLS configuration, which embedsssl_primary_configas a member
A function is a named block of code that does one job; match_ssl_primary_config() is the function whose job is to answer "are these two configurations the same?". A session cache is a store of previously negotiated TLS sessions so they can be resumed quickly instead of negotiated from scratch; its key is the label under which an entry is filed, a bit like the name on a folder. "Embeds as a member" means the smaller struct sits inside the larger one, like a small box placed inside a bigger box.
The five fields needed to actually open a client certificate, cert_type, key, key_type, key_passwd and key_blob, lived in ssl_config_data, not in ssl_primary_config. Since match_ssl_primary_config() only compares ssl_primary_config, those five fields were entirely outside its field of view. Before the patch, ssl_config_data looked roughly like this:
struct ssl_config_data { char *cert_type; char *key; struct curl_blob *key_blob; char *key_type; char *key_passwd; BIT(certinfo); };
Line by line, in plain words:
struct ssl_config_data {opens the definition of the bigger box and gives it a name.char *cert_type;is a slot for the type of the certificate, such as the file format it is stored in.char *key;is a slot for where the private key is.struct curl_blob *key_blob;is a slot for a private key held in memory as raw bytes rather than in a file. A blob is just a chunk of binary data with no particular structure.char *key_type;is a slot for the type of that key.char *key_passwd;is a slot for the password that unlocks the key, if it is protected by one.BIT(certinfo);is a single on/off switch, here controlling whether extra certificate information is collected.};closes the definition.
The important part is that all five key-related slots are in this box, the one the reuse check does not read.
And the reuse-check function in lib/vtls/vtls.c only compared ssl_primary_config fields:
static bool match_ssl_primary_config(struct Curl_easy *data, struct ssl_primary_config *c1, struct ssl_primary_config *c2){ if(Curl_safecmp(c1->CApath, c2->CApath) && Curl_safecmp(c1->CAfile, c2->CAfile) && Curl_safecmp(c1->issuercert, c2->issuercert) && Curl_safecmp(c1->clientcert, c2->clientcert) && Curl_safecmp(c1->CRLfile, c2->CRLfile) && Curl_safecmp(c1->pinned_key, c2->pinned_key)) return TRUE; return FALSE;}
Line by line:
static bool match_ssl_primary_config(...)declares a function that returns a yes/no answer (boolmeans true or false) and is only visible inside this file (static).- The three parameters are the transfer context (
data) and the two configurations being compared,c1andc2. if(starts a chain of conditions that must all hold.Curl_safecmp(c1->CApath, c2->CApath)compares the two settings for where trusted certificate authorities are found on disk. A certificate authority is an organisation whose signature makes a certificate trustworthy.Curl_safecmp(c1->CAfile, c2->CAfile)compares the equivalent single-file setting.Curl_safecmp(c1->issuercert, c2->issuercert)compares the issuer certificate setting.Curl_safecmp(c1->clientcert, c2->clientcert)compares the client certificate path. This is the one identity-related check that was present.Curl_safecmp(c1->CRLfile, c2->CRLfile)compares the file listing revoked certificates. A CRL is a published list of certificates that should no longer be trusted.Curl_safecmp(c1->pinned_key, c2->pinned_key)compares a pinned public key, a setting that ties a connection to one specific key.return TRUE;means: every comparison matched, so the configurations are the same and the connection may be reused.return FALSE;means: something differed, so a new connection is needed.
clientcert, the certificate file path, was compared, but the fields that determine which private key opens that certificate, key and key_passwd, were not. If two handles used the same SSLCERT but different SSLKEY values, the function would still conclude "same config" and let the connection be reused. Going back to the passport comparison: the check confirmed the two people were carrying the same passport, but never looked at whose face was behind it.
The TLS session cache had a parallel issue. Its cache key appended a fixed string, ":CCERT", to represent "this session used a client cert", without encoding which certificate. Sessions using different client certificates could therefore also collide in the session cache. A collision here means two different things being filed under the same label, so one can be handed out in place of the other.

The diagram shows the split: the left card lists the fields match_ssl_primary_config() actually compares (ssl_primary_config), and the right card lists the five fields that were excluded before the patch (ssl_config_data).
Exploitation: how the mistake turns into a wrong identity

Step 1: Handle A authenticates
Handle A connects with SSLCERT=client.pem and SSLKEY=keyA.pem, completes the mTLS handshake, and the resulting connection is cached in the pool as "authenticated as user A".
Why this step matters: this is the moment a real, verified identity is established. The handshake is the opening conversation of a TLS connection where the two sides agree on encryption and exchange certificates. Once it finishes, the server has checked user A's certificate and considers this connection to belong to user A. The connection is then parked in the pool for later use.
Step 2: Handle B asks for a connection
Handle B sends a request using the same SSLCERT=client.pem but a different SSLKEY=keyB.pem.
Why this step matters: handle B is meant to be a different identity. It presents the same certificate file but a different private key. In a correct world, that difference should be noticed, because the settings are not the same.
Step 3: The comparison passes
match_ssl_primary_config() only checks that clientcert matches, so Handle B is handed the already-authenticated connection from Handle A without a new TLS handshake.
Why this step matters: this is the bug firing. The library runs its "are these the same?" check, sees the same certificate path, and concludes the settings match. It never looks at the key. Handle B gets the parked connection, and no new handshake takes place, so the server is never asked to verify anything new.
Step 4: The server attributes the request to user A
From the server's point of view, this connection is still verified against user A's mTLS certificate, so it processes Handle B's request as if it came from user A.
Why this step matters: the server is not misbehaving. It did its check correctly, once, at the start. It has no way to know that a different request is now travelling over the connection it already approved. The result is that handle B's request is handled under user A's identity.
In effect, two requests intended to authenticate as different identities end up sharing the same authenticated channel simply because their private keys differed.
Root cause: why the check was wrong
The mistake is structural. The fields that identify which private key opens a client certificate were stored in ssl_config_data, while the reuse decision only ever looked at ssl_primary_config. The comparison was correct for every field it could see; the five key-related fields were simply not part of the struct it compared. Comparing clientcert alone was not enough, because the certificate path does not determine the private key used with it.
A useful comparison: imagine a building receptionist with a list of approved visitors. The list records names but not photographs. Anyone who can say an approved name gets in, because the check only ever looks at the name. The receptionist is doing exactly what the list says; the list is simply missing the thing that would distinguish two people.
The session cache repeated the same assumption in a different form: a fixed ":CCERT" marker recorded that a client certificate was used, but not which one, so distinct client certificates could map to the same cache entry.
Impact: what an attacker could actually achieve
In an application that pools connections across easy handles and switches client-certificate credentials between them, a request can be processed under another user's mTLS identity. The server sees a connection already verified against the first user's certificate and treats the second handle's request as coming from that user.
The conditions are narrow. The curl CLI is unaffected. Only long-running applications that share a connection pool via CURLSH or a multi handle, and that switch client-certificate credentials between handles, are exposed, such as a proxy or gateway authenticating different users over mTLS.
The bug traces back to commit a1d6ad2 around curl 7.7 (roughly 2010) and existed for nearly 16 years before being fixed in curl 8.21.0. A commit is a recorded change in a software project's history, identified by a short code; it is how developers point at exactly which edit they mean.
Fix: moving the fields into the box that gets checked
The fix in commit 7541ae5 promotes the five affected fields from ssl_config_data into ssl_primary_config:
struct ssl_primary_config { char *pinned_key; char *CRLfile; char *cert_type; char *key; char *key_type; char *key_passwd; struct curl_blob *cert_blob; struct curl_blob *ca_info_blob; struct curl_blob *issuercert_blob; struct curl_blob *key_blob; };
Line by line:
struct ssl_primary_config {opens the definition of the box that the reuse check actually reads.char *pinned_key;andchar *CRLfile;were already there: the pinned key and the revocation list file.char *cert_type;is now here: the certificate type.char *key;is now here: the private key location.char *key_type;is now here: the private key type.char *key_passwd;is now here: the password protecting the key.struct curl_blob *cert_blob;,struct curl_blob *ca_info_blob;,struct curl_blob *issuercert_blob;andstruct curl_blob *key_blob;are the in-memory blob versions of the certificate, the authority information, the issuer certificate and the private key.key_blobis the one that matters for this bug.};closes the definition.
The point of the change is simple: the five settings that decide which key opens which certificate now sit in the box that the comparison function reads. The check cannot miss them any more, because they are in front of it.
The comparison function now checks all five. Notably, key_passwd is compared with Curl_timestrcmp(), a timing-attack-resistant string comparison:
static bool match_ssl_primary_config(struct Curl_easy *data, struct ssl_primary_config *c1, struct ssl_primary_config *c2){ if( Curl_safecmp(c1->pinned_key, c2->pinned_key) && curl_strequal(c1->cert_type, c2->cert_type) && Curl_safecmp(c1->key, c2->key) && curl_strequal(c1->key_type, c2->key_type) && !Curl_timestrcmp(c1->key_passwd, c2->key_passwd)) return TRUE; return FALSE;
Line by line:
- The function signature is unchanged: it still takes the transfer context and the two configurations.
Curl_safecmp(c1->pinned_key, c2->pinned_key)still compares the pinned key.curl_strequal(c1->cert_type, c2->cert_type)now compares the certificate type.Curl_safecmp(c1->key, c2->key)now compares the private key location. This is the check whose absence caused the bug.curl_strequal(c1->key_type, c2->key_type)now compares the private key type.!Curl_timestrcmp(c1->key_passwd, c2->key_passwd)now compares the key password. The!means "not": the condition holds when the two passwords are not different, that is, when they match.Curl_timestrcmp()is a comparison written so that the time it takes does not reveal how much of the password was correct. A timing attack is when an attacker measures how long a check takes to guess a secret piece by piece; a comparison that always takes the same time gives nothing away.return TRUE;means all settings match, so reuse is allowed.return FALSE;means something differs, so a new connection is needed.
Because the fields moved, every backend file referencing them had to change, 19 files in total, including openssl.c, gtls.c, mbedtls.c, rustls.c, schannel.c, wolfssl.c, libssh.c, libssh2.c and ldap.c. A backend here is the part of libcurl that talks to one particular TLS implementation; libcurl supports several, so the same settings have to be read in each of them. References like ssl_config->key became ssl_config->primary.key. The OpenSSL backend, for example, changed like this:
result = client_cert(data, octx->ssl_ctx, ssl_cert, ssl_cert_blob, ssl_cert_type, ssl_config->key, ssl_config->key_blob, ssl_config->key_type, ssl_config->key_passwd);result = client_cert(data, octx->ssl_ctx, ssl_cert, ssl_cert_blob, ssl_cert_type, ssl_config->primary.key, ssl_config->primary.key_blob, ssl_config->primary.key_type, ssl_config->primary.key_passwd);
Line by line:
- The first block is the old code. It calls a function
client_cert()that sets up the client certificate, passing the transfer context, the TLS context, the certificate and its blob, the certificate type, and then the key, key blob, key type and key password. - In that old code the key settings are read as
ssl_config->key,ssl_config->key_blob,ssl_config->key_typeandssl_config->key_passwd, straight from the larger struct. - The second block is the new code. The call is the same, but the four key settings are now read as
ssl_config->primary.key,ssl_config->primary.key_blob,ssl_config->primary.key_typeandssl_config->primary.key_passwd. primaryis the name of the smaller struct now sitting inside the larger one, so the code is saying "look in the primary box for these". This is a mechanical change repeated across the backends, but it is what makes the relocated fields reachable from the place that uses them.
On the session-cache side, the fixed ":CCERT" marker was replaced with the actual clientcert path value, so sessions using different client certificates can no longer share a cache entry. clone_ssl_primary_config() and free_primary_ssl_config() also gained clone/free logic (CLONE_STRING, CLONE_BLOB, curlx_safefree) for the newly relocated fields. In plain words: when a configuration is copied, the new fields are now copied too, and when it is thrown away, the memory they use is now released. Clone means make a copy; free means give memory back to the system so it is not wasted.
The fix was validated with two new test cases, 3303 and 3304.
Remediation options:
- Upgrade libcurl to 8.21.0 or later (recommended).
- If upgrading is not possible yet, backport commit
7541ae5and rebuild. To backport is to take a fix written for a newer version and apply it to an older one you are still using; to rebuild is to compile the software again from its source code so the change takes effect. - As a temporary mitigation, avoid reusing handles when client-certificate credentials change; create a new handle instead. A mitigation is a workaround that reduces risk while the real fix is applied.
Variants to test
These are the areas worth checking if you maintain software that uses libcurl, or if you are reviewing similar code.
- Other pooled TLS settings that live outside the compared struct. Look for any option that affects the authenticated identity of a connection but is stored in a struct the reuse check does not read. A positive result is two handles with different identity-bearing options receiving the same pooled connection without a new handshake.
- Session-cache key collisions. Check whether any cache key component is a fixed marker rather than the value that distinguishes sessions. A positive result is two sessions with different client certificates resolving to the same cache entry.
- Shared pools in proxies and gateways. Exercise a
CURLSHor multi-handle setup that switches client-certificate credentials between requests. A positive result is the backend attributing the second request to the first user's certificate. - Handle reuse after credential changes. Reuse an existing handle after changing
SSLCERTorSSLKEYinstead of creating a new one. A positive result is the old authenticated connection being used for the new credentials. - Backend coverage. Repeat the comparison review across TLS backends (
openssl.c,gtls.c,mbedtls.c,rustls.c,schannel.c,wolfssl.c), since the fix touched 19 files. A positive result is a backend that still reads the relocated fields from the old location or omits one from the comparison.
Glossary
- API: a defined way for one program to ask another program to do something, like a menu of requests a service accepts.
- API gateway: a front door for a set of backend services that receives all requests and decides where each goes and who may make it.
- Authentication: the process of proving who you are.
- Authentication bypass: a bug where a program's identity check can be avoided or made to pass when it should not.
- Backend: in this context, the part of libcurl that talks to one particular TLS implementation; also used generally for the server behind a proxy or gateway.
- Backport: applying a fix written for a newer version of software to an older version still in use.
- Blob: a chunk of binary data with no particular structure.
- Certificate authority: an organisation whose signature makes a certificate trustworthy.
- Client certificate: a digital identity document a client presents to prove who it is.
- Clone: to make a copy of something, here a configuration.
- Collision: two different things filed under the same label, so one can be handed out in place of the other.
- Commit: a recorded change in a software project's history, identified by a short code.
- Connection pool: a store of already-open connections kept for reuse instead of opening new ones each time.
- CRL: a published list of certificates that should no longer be trusted.
- CURLSH: libcurl's share handle, a mechanism that lets several easy handles deliberately share things such as connections.
- curl / libcurl: curl is a command-line program for fetching things over the network; libcurl is the same engine packaged as a library other programs can call.
- CWE-305: the standard catalogue entry for Authentication Bypass.
- Easy handle: libcurl's object representing one transfer with its own settings.
- Free: to give memory back to the system so it is not wasted.
- Function: a named block of code that does one job.
- Handshake: the opening conversation of a TLS connection where the two sides agree on encryption and exchange certificates.
- Long-running application: a program that stays alive and serves many requests over time, rather than running once and exiting.
- Mitigation: a workaround that reduces risk while the real fix is applied.
- mTLS: mutual TLS, where both sides of a connection prove their identity, not just the server.
- Multi handle: a libcurl mechanism for running several transfers together, which also lets them share connections.
- Private key: the secret half of a certificate that proves you really own it.
- Proxy: a server that sits between clients and a backend and forwards requests on their behalf.
- Rebuild: to compile software again from its source code so a change takes effect.
- Session cache: a store of previously negotiated TLS sessions so they can be resumed quickly instead of negotiated from scratch.
- Share handle: see CURLSH.
- Struct: a labelled box in a program that groups related pieces of information together.
- Test case: an automated check that reproduces a scenario and confirms the software behaves correctly.
- Timing attack: measuring how long a check takes to guess a secret piece by piece.
- TLS: the technology that encrypts a network connection and lets each side prove who it is.
- Vulnerability: a weakness in software that can be used to make it behave in a way its authors did not intend.