Skip to content
Info disclosure Disclosed report Advanced

libcurl stale CURLOPT_AUTOREFERER leaks a previous request URL to a different origin on a reused easy handle

libcurl keeps the previous request URL in its easy-handle state after a redirect when CURLOPT_AUTOREFERER is enabled, and does not clear it between transfers. A later unrelated request on the same handle can therefore send a stale Referer header, including query strings, to a different origin.

asdwe Follow

Originally disclosed on HackerOne

  • Disclosed after 3 days

Summary:

libcurl keeps a stale data->state.referer after an HTTP redirect when CURLOPT_AUTOREFERER is enabled. Curl_http_follow() stores the previous URL into data->state.referer at lib/http.c:1166-1189, and later requests reuse that value when building Referer: at lib/http.c:2954-2957. In my local checkout, lib/transfer.c:495-503 resets follow/auth state but does not reset data->state.referer. As a result, after one redirecting transfer completes, a subsequent unrelated request on the same easy handle can send a stale Referer: header to a different origin. I reproduced this on curl 8.19.0 / libcurl 8.19.0 on x86_64 Linux, and included controls showing the leak disappears when the second request uses a new easy handle or when CURLOPT_AUTOREFERER is disabled. An attachment with the PoC source, server script, and captured output is included.

Affected version

Reproduced on: curl 8.19.0 (x86_64-pc-linux-gnu) libcurl/8.19.0 OpenSSL/3.5.5 zlib/1.3.1 brotli/1.2.0 zstd/1.5.7 libidn2/2.3.8 libpsl/0.21.5 libssh2/1.11.1 nghttp2/1.68.1 ngtcp2/1.21.0 nghttp3/1.15.0 librtmp/2.3 mit-krb5/1.22.1 OpenLDAP/2.6.10 Platform: Linux x86_64

Steps To Reproduce:

  1. Start the attached local server: python3 -u stale_autoreferer_server.py 18084
  2. Build the attached PoC: cc poc_stale_autoreferer.c -o poc_stale_autoreferer $(curl-config --cflags --libs)
  3. Run the PoC: ./poc_stale_autoreferer
  4. Observe the base case output: req1=0 effective=http://b.test:18084/final referer=http://a.test:18084/start?token=SECRET123 req2=0 effective=http://attacker.test:18084/check referer=http://a.test:18084/start?token=SECRET123
  5. Observe control 1: with a new easy handle for request 2, attacker.test receives referer=(null)
  6. Observe control 2: with CURLOPT_AUTOREFERER disabled, the stale Referer: is not sent on request 2
  7. Observe the attached server log for the base case: {"host": "a.test:18084", "path": "/start?token=SECRET123", "referer": null} {"host": "b.test:18084", "path": "/final", "referer": "http://a.test:18084/start?token=SECRET123"} {"host": "attacker.test:18084", "path": "/check", "referer": "http://a.test:18084/start?token=SECRET123"}

Impact

Summary:

This causes cross-origin disclosure of the previous transfer URL through a stale Referer: header on a later request using the same easy handle. Because the leaked URL can include query parameters, path segments, signed URLs, internal endpoint names, or other sensitive values, an attacker-controlled origin can receive data unrelated to the current request. The included controls show that the leak is specifically caused by persisted CURLOPT_AUTOREFERER state across transfers, not normal referer behavior.

The original report as published on HackerOne, by asdwe. 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 per-transfer reset in lib/transfer.c clears follow and auth state but leaves data->state.referer untouched, so the value set during a redirect persists into later transfers on the same easy handle.

Impact

An attacker-controlled origin could receive the previous transfer's URL, which may contain query parameters, signed URLs or internal endpoint names; the leak only occurs when the same easy handle is reused and CURLOPT_AUTOREFERER is enabled.

What the attacker needed

Application reuses one easy handle; CURLOPT_AUTOREFERER enabled; first request redirects; second request goes to another origin

How it was found

  1. Start the local test server.
  2. Build the proof-of-concept program against libcurl.
  3. Run the program so the first request redirects and the second goes to a different host.
  4. Observe that the second host receives the first request's URL as Referer.
  5. Repeat with a fresh easy handle and see no Referer is sent.
  6. Repeat with CURLOPT_AUTOREFERER disabled and see no stale Referer is sent.

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.

A Referer header tells a website which page you came from. libcurl is a library programs use to make web requests, and an easy handle is a reusable object that holds settings and state between requests. Here the library remembered an old page address and sent it to a completely different site on the next request, which can leak private details in that address.

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.