Summary:  
A security flaw tracked as CVE-2023-27536 impacts all versions of *libcurl* prior to 8... It allows an attacker to get unauthorized access by tricking libcurl into reusing a network connection for someone else—a direct result of mishandling a security setting called CURLOPT_GSSAPI_DELEGATION during authentication.

This post breaks down what happened, which code is affected, how attackers could use it, and how to stay safe.

What is libcurl?

libcurl is a very popular open-source library for transferring data with URLs. Many command line tools (like curl) and programs use it for network communication.

About the Vulnerability

CVE-2023-27536 is an authentication bypass vulnerability related to libcurl's *connection reuse* feature. When libcurl talks to servers, it tries to reuse existing connections to reduce overhead. For complex login methods (Kerberos/Negotiate/GSSAPI), users can hand over different levels of credential delegation using the CURLOPT_GSSAPI_DELEGATION option.

> The Problem:  
libcurl failed to correctly check if the CURLOPT_GSSAPI_DELEGATION setting had changed between requests for the same server. As a result, it could reuse a connection with old credentials, even if new requests lowered those permissions.

This bug affects

- Kerberos/krb5

GSSAPI transfers

Impact:  
Attackers may get access to sensitive data because they inherit elevated permissions from a reused connection that should have been separated. If one user allowed delegation and another didn't, the second could accidentally "piggyback" on the first's more privileged session.

- curl Security Advisory: CVE-2023-27536
- GitHub Issue
- NVD Entry

The Vulnerable Code (Simplified Example)

Let's see a simplified version of what went wrong. The connection pool didn't care if CURLOPT_GSSAPI_DELEGATION had changed.

Pseudocode Before

// Picking a connection for reuse
for each connection in pool:
    if (conn.host == requested.host && conn.port == requested.port) {
        // Forgot to check GSSAPI_DELEGATION here!
        return conn; // Reuse!
    }
}

Corrected Code

// Picking a connection for reuse
for each connection in pool:
    if (conn.host == requested.host && conn.port == requested.port) {
        if (conn.gssapi_delegation == requested.gssapi_delegation) {
            return conn; // Reuse only if delegation settings match
        }
    }
}

Because the check was missing before, connections were reused even across different delegation modes.

Exploit Scenario Example

Let’s say an attacker controls one request and a victim’s request happens right after, using the same destination.

Second User (Victim):

Makes a request with delegation disabled (CURLOPT_GSSAPI_DELEGATION=OFF)—expecting less risk and no credential exposure.

But:  
libcurl reuses the same connection! The attacker’s more privileged connection is now used for a lower-permission task. This could expose sensitive information or allow the attacker to do things they shouldn’t.

Proof of Concept Snippet

> Note: On a real system, you must set up a GSSAPI server, but here’s how it’d look in code.

CURL *curl = curl_easy_init();

if(curl) {
    // Attacker: Delegation enabled
    curl_easy_setopt(curl, CURLOPT_URL, "http://sensitive.internal";);
    curl_easy_setopt(curl, CURLOPT_GSSAPI_DELEGATION, CURLGSSAPI_DELEGATION_FLAG);

    curl_easy_perform(curl); // connection established with delegation

    // Victim: Delegation disabled
    curl_easy_setopt(curl, CURLOPT_GSSAPI_DELEGATION, );

    curl_easy_perform(curl); // reuses earlier connection (bug)
}

The second request should NOT reuse the first, but before 8.. it still would.

How to Fix or Protect Yourself

Best option:  
Upgrade to *libcurl* 8.. or later (released March 2023), which adds the missing check.

Until you can upgrade:  
- Explicitly close connections after sensitive operations (using CURLOPT_FORBID_REUSE or CURLOPT_CLOSEPOLICY).

Conclusion

CVE-2023-27536 is a great example of how subtle mistakes in connection management can break security. If you use *libcurl* and GSSAPI/Kerberos/Negotiate, check your version *right now!* and protect your apps and your users.

References

- Official curl CVE-2023-27536 Advisory
- NVD listing
- Discussion on curl GitHub

Timeline

Published on: 03/30/2023 20:15:00 UTC
Last modified on: 04/21/2023 23:15:00 UTC