Kerberos/SPNEGO Connection Reuse Vulnerability
curl reuses HTTP connections across different users without checking Kerberos authentication state, so a later user's request can inherit an earlier user's GSS security context. An attacker could then act with the previous user's privileges on shared servers or CI/CD pipelines.
Originally disclosed on HackerOne
- Disclosed after 3 days
Kerberos/SPNEGO Connection Reuse Vulnerability in curl
Summary
curl reuses HTTP connections across different users without checking Kerberos state. User B's request can inherit User A's GSS security context, allowing authentication bypass.
Affected Versions
All curl versions with Kerberos support (tested and confirmed on curl 8.5.0)
Root Cause
ConnectionExists() in lib/url.c checks NTLM state (lines 1214-1273) but has no equivalent check for http_negotiate_state or proxy_negotiate_state.
When Kerberos auth completes, conn->http_negotiate_state advances to GSS_AUTHSUCC and the GSS security context remains valid. Since hashkey() (lib/conncache.c:126-150) only uses port+hostname (no credentials) and HTTP sets PROTOPT_CREDSPERREQUEST which skips credential checks, any request to the same host:port reuses the connection with the previous user's GSS context.
Partial Mitigation
curl has noauthpersist (lib/http_negotiate.c:140-152) that cleans up GSS context for single-roundtrip Negotiate (MIT Kerberos). However:
- When
havemultiplerequestsis TRUE (multi-roundtrip auth, common with Windows AD/IIS),noauthpersistis FALSE and no cleanup occurs - This cleanup happens AFTER
ConnectionExists()already matched the connection - wrong defensive layer - NTLM has protection in both layers; Negotiate has neither
Suggested Fix
Add #if defined(USE_SPNEGO) block to ConnectionExists() mirroring the NTLM pattern:
- Compare credentials when Negotiate is wanted
- Reject connections with active Negotiate state if new request doesn't want it
- Add per-transfer Negotiate state reset (like NTLM at
url.c:3776-3792)
Note: For SSO (--negotiate -u :), usernames are empty so credential comparison won't work - might need to clear GSS context unconditionally or force separate connections. Apply to both http_negotiate_state and proxy_negotiate_state.
Proof of Concept
I've developed a complete reproduction package with real Kerberos authentication:
Files Included:
- source-analysis.md - Detailed code analysis with line numbers and exploitation flow
- run-exploit.sh - Automated PoC demonstrating the vulnerability
- test-server.py - GSSAPI test server that tracks GSS context per TCP connection
Reproduction Steps:
- Setup Kerberos KDC with test users (alice, bob)
- Run
./run-exploit.sh - Observe connection reuse and GSS context inheritance
The PoC demonstrates:
- Alice authenticates with
--negotiate - Bob makes a request to the same server
- Connection is reused (same TCP socket)
- Server logs show:
"CONNECTION REUSED - GSS context persists for [email protected]"
Technical Details
See attached source-analysis.md for:
- Complete code analysis
- Comparison with NTLM protection mechanism
- Exploitation flow for different scenarios (single-roundtrip vs multi-roundtrip)
- Root cause explanation with exact file/line references
Attachments
source-analysis.md- Technical deep diverun-exploit.sh- Working proof-of-concepttest-server.py- Test server for reproduction
Reported by: Ramesh Adhikari ([email protected])
Impact
Impact
Corporate environments using Kerberos authentication are at high risk. Attack scenarios include:
- CI/CD pipelines with multiple service accounts accessing the same API
- Shared web servers where User B's request executes with User A's privileges
- Multi-tenant applications where connection pools are shared across users
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 connection reuse check only compares host and port and checks NTLM state, but never checks the Kerberos (SPNEGO) authentication state or credentials before reusing a connection.
Impact
In corporate environments using Kerberos, a later user's request could execute with an earlier user's privileges, affecting CI/CD pipelines, shared web servers and multi-tenant applications; the text notes a partial mitigation for single-roundtrip Negotiate but not for multi-roundtrip auth.
What the attacker needed
Kerberos-enabled curl; Shared connection pool across users
The fix
The text suggests adding a SPNEGO check in ConnectionExists() that compares credentials and rejects connections with active Negotiate state, plus a per-transfer state reset, and notes that SSO with empty usernames may need the GSS context cleared unconditionally or separate connections forced.
How it was found
- Set up a Kerberos KDC with two test users.
- Run the provided exploit script.
- Observe that the connection is reused and the GSS context carries over to the second user.
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.
Kerberos is a login system that proves who you are to a server. curl is a tool that makes web requests and can keep connections open to save time. The bug is that curl reuses an already-logged-in connection for a different user, so the second person can be treated as the first person without proving who they are.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.