Skip to content
Misconfiguration Disclosed report Intermediate

HSTS accepted from HTTP origin behind HTTPS proxy

curl accepts and stores a Strict-Transport-Security header from a plain http:// origin when the request is routed through an https:// proxy, because the HSTS gate checks whether the first connection hop is TLS rather than the origin scheme. An attacker controlling an http origin could therefore plant persistent HSTS state for that host, causing later http:// requests to be silently upgraded to https://.

lg_oled77c5pua Follow

Originally disclosed on HackerOne

  • Disclosed after 20 hours

curl/libcurl appears to accept and persist Strict-Transport-Security from an http:// origin when the request is sent through an https:// proxy. After that, a later http:// request for the same host is automatically upgraded to https:// due to stored HSTS state.

Affected versions

8.12.0 through 8.19.0

This appears to be introduced by commit 25b445e https://github.com/curl/curl/commit/25b445e4796bcbf9f842de686a8c384b30f6c2a2

As a side effect of that broad switch from handler-based SSL checks to connection-based SSL checks, the HSTS gate now passes for plain http:// requests sent over an HTTPS proxy because the first connection hop is TLS.

Reproduction

First request:

Bash
curl -v \
  --proxy https://127.0.0.1:18443 --proxy-insecure \
  --hsts ./hsts-cache.txt \
  http://hsts-probe.test:18080/

origin replied with Strict-Transport-Security: max-age=31536000 curl stored an HSTS entry for hsts-probe.test

Second request with the same HSTS file:

Bash
curl -v \
  --proxy https://127.0.0.1:18443 --proxy-insecure \
  --hsts ./hsts-cache.txt \
  http://hsts-probe.test:18080/

curl printed: Switched from HTTP to HTTPS due to HSTS => https://hsts-probe.test:18080/ curl then sent CONNECT hsts-probe.test:18080 HTTP/1.1 to the proxy

I can provide a minimal test script if needed.

Expected behavior

An http:// origin response should not be able to set HSTS just because the proxy connection is HTTPS. Proxy TLS should not be treated as origin HTTPS for HSTS learning.

Impact

Persistent HSTS state can be learned for a host from an http:// origin when that origin is accessed through an https:// proxy, causing later http:// requests for that host to be automatically upgraded to https://

The original report as published on HackerOne, by lg_oled77c5pua. 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 a regression from switching SSL checks from per-handler to per-connection, so the HSTS eligibility test looks at whether the first hop is TLS instead of whether the origin URL scheme is https.

Impact

Persistent HSTS state can be learned for a host from an http:// origin accessed through an https:// proxy, causing later http:// requests for that host to be automatically upgraded to https://.

What the attacker needed

Curl 8.12.0 to 8.19.0; request routed through an https:// proxy; HSTS cache file enabled; attacker controls the http:// origin

The fix

The reporter expects proxy TLS not to count as origin HTTPS for HSTS learning, with the gate checking the origin scheme.

How it was found

  1. Send an http:// request through an https:// proxy with an HSTS cache file enabled.
  2. Have the origin reply with a Strict-Transport-Security header.
  3. Observe that curl stores an HSTS entry for the host.
  4. Repeat the same http:// request with the same HSTS file.
  5. Observe curl switching the URL to https:// and sending CONNECT to the proxy.

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.

HSTS is a rule a website can send telling the browser or client to always use the secure https:// version of that site in future. Here curl wrongly accepted that rule from an ordinary unencrypted http:// site, simply because the connection to the proxy in front of it was encrypted. That means a site that should never have been allowed to set the rule could make curl switch to https:// later on.

What is Misconfiguration?

Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.

More from curl

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Security misconfiguration

The lesson behind this report.

Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.