Skip to content
Info disclosure Disclosed report Intermediate

CURL_NETRC_REQUIRED sends the URL password when the .netrc file has no matching entry

In required netrc mode, libcurl is documented to ignore credentials embedded in the URL, but when the .netrc file loads and has no matching entry, the URL password is still sent as preemptive HTTP Basic authentication. An attacker who controls a URL passed to a vulnerable application could therefore have that URL's password transmitted to the URL's host, contrary to the documented behaviour.

tlh02 Follow

Originally disclosed on HackerOne

  • Disclosed after 22 hours

Summary

In required netrc mode (CURL_NETRC_REQUIRED, as set by --netrc or --netrc-file), the CURLOPT_NETRC documentation says any credential information present in the URL is ignored, but when the configured .netrc file loads successfully yet has no entry matching the requested host and username, libcurl keeps the password from the URL and sends it to the server as preemptive HTTP Basic authentication.

Affected version: curl/libcurl 8.23.0 and current git master (8.23.1-DEV, commit eabeacb9ff), macOS; 8.20.0 does not behave this way.

Steps To Reproduce:

Shell
# a .netrc that loads but has no entry for user 'alice'
printf 'machine example.com login bob password sekret\n' > nrc

# start any local HTTP server on 127.0.0.1:$PORT that logs request headers,
# then (required mode is implied by --netrc-file; URL carries user AND password):
curl -v --netrc-file nrc \
  --resolve example.com:$PORT:127.0.0.1 \
  "http://alice:[email protected]:$PORT/"

After the request goes out it carries Authorization: Basic YWxpY2U6c2VjcmV0 (base64 of alice:secret), so the URL password secret is transmitted even though required mode matched no .netrc entry.

Impact

An application that forwards externally supplied URLs to libcurl and selects required netrc mode specifically to stop URL-embedded credentials from being used would, when its .netrc has no matching entry, still send the URL password to that URL's host, contrary to the documented behavior. The scope is limited because the password is the one already present in the fetched URL and it is sent only to that same host, so no stored .netrc secret is exposed, credentials do not cross origins, and there is no server-side authentication bypass.

The original report as published on HackerOne, by tlh02. 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

Likely the credential-selection logic falls back to the URL password when required netrc mode finds no matching entry, instead of discarding URL credentials as documented.

Impact

An application that forwards externally supplied URLs to libcurl and relies on required netrc mode to block URL credentials would still send the URL password to that URL's host, though the exposure is limited to the password already in the URL and only to the same host.

What the attacker needed

Attacker-supplied URL with embedded password; application uses required netrc mode; no matching .netrc entry for that host

How it was found

  1. Create a .netrc file that loads but has no entry for the username used in the URL.
  2. Start a local HTTP server that logs request headers.
  3. Run curl with the netrc file option against a URL that contains both a username and a password, resolving the host to the local server.
  4. Observe that the outgoing request carries a Basic authentication header built from the URL credentials.

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.

When a program fetches a web address, it can include a username and password inside the address itself. A .netrc file is a small local file that stores logins, and 'required' mode is meant to say: only use logins from this file, never the ones in the address. The bug is that when the file has no matching login, the password from the address is still sent to the server anyway.

What is Info disclosure?

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

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.