Advisory: GHSA-f6gg-rchx-xw8j / CVE-2026-128064

If your PHP code fetches a URL that starts with HTTPS:// in capital letters, PHP 8.5.12 sends your headers and POST body unencrypted, with no error or warning.

PHP published an advisory for this last week. I reproduced it on 8.5.12, 8.5.13 and 8.6.0, checked whether curl and Guzzle are affected, and worked out when it can actually hurt you. I tested the HTTPS side only, not FTPS.

The short version

  • PHP 8.5.12 leaks. The advisory says other unpatched releases do too, but I didn't test 8.4 or older.
  • PHP 8.5.13 and 8.6.0 don't leak.
  • It triggers when a URL with a mixed-case scheme, such as HTTPS:// or httpS://, reaches file_get_contents(), fopen() or copy(), either directly or through a redirect.
  • Browsers, curl and Guzzle behaved correctly in my tests.
  • The fix is to upgrade PHP. If you can't, lowercase the scheme before you fetch a URL and stop PHP from following redirects automatically.

Why file_get_contents() and not curl?

The bug isn't in HTTP, and it isn't in PHP's TLS support. It's in PHP's built-in http:// and ftp:// stream wrappers, the code PHP uses to open a URL as if it were a file whenever you pass one to file_get_contents(), fopen(), copy() or file(). curl goes through libcurl and never touches those wrappers, so it behaves differently.

file_get_contents() is also still how a lot of PHP code fetches remote data: one line, no extension needed, common in older projects and quick scripts.

Who is actually at risk

Browsers aren't affected. In Chrome 156 (headless) and in Node, new URL("HTTPS://example.com/Path") becomes https://example.com/Path before any request goes out, so an uppercase scheme typed into an address bar leaks nothing. The risk is server-side PHP, and three things have to line up:

  1. A URL with an uppercase scheme reaches file_get_contents(), fopen() or copy(). It could be a webhook URL a customer saved, an "import from URL" field, a feed URL, a file fetched from a remote server or storage bucket, a config value, or a redirect's Location header.
  2. Your own check lets it through. A common "only https" check that ignores case, such as comparing strtolower(parse_url($url, PHP_URL_SCHEME)) to 'https', accepts HTTPS:// and passes the original string on. In my test, a function using that check sent the Authorization header in plaintext on 8.5.12 and a TLS handshake on 8.5.13.
  3. Someone can watch the traffic between your server and the destination, and the request carries a token, a cookie or a POST body.

The third condition decides how worried to be. The attacker is not the destination: if they control the URL and the server behind it, they get the data over TLS anyway. The bug matters when the destination is trusted and the path is not, such as a proxy, a shared network or a compromised hop.

It doesn't need an attacker to start, either. A customer pasting HTTPS://api.theirapp.com/hook into your settings, or an old config value written in capitals, quietly sends your requests unencrypted. The advisory rates this High, but its CVSS vector marks attack requirements as present, which fits the above.

Reproducing it on 8.5.12

To see what leaves the machine, I wrote a small PHP listener on localhost (full code at the end). It checks the first byte of each connection: a TLS handshake starts with 0x16, plaintext HTTP with readable text such as POST.

A client script then sends a POST with a fake bearer token and a fake secret body to three URLs:

$cases = [ 'https' => "https://127.0.0.1:$port/", 'HTTPS' => "HTTPS://127.0.0.1:$port/", 'httpS' => "httpS://127.0.0.1:$port/", ]; foreach ($cases as $label => $url) { $ctx = stream_context_create(['http' => [ 'method' => 'POST', 'header' => "Authorization: Bearer s3cret-token\r\nContent-Type: text/plain", 'content' => 's3cret=hunter2', ]]); @file_get_contents($url, false, $ctx); } 

The @ silences PHP's warning. My listener isn't a real TLS server, so the correctly encrypted attempts fail, and I want the loop to carry on to the next URL.

This is what the listener saw on PHP 8.5.12, condensed to one line per connection:

TLS_HANDSHAKE <- https:// PLAINTEXT_HTTP POST / HTTP/1.1 auth header: yes secret body: yes <- HTTPS:// PLAINTEXT_HTTP POST / HTTP/1.1 auth header: yes secret body: yes <- httpS:// 

Lowercase https:// behaved. HTTPS:// and httpS:// skipped TLS and sent the bearer token and body as readable text. According to the advisory, the stream wrapper recognises the scheme case-insensitively, but the code that decides whether to turn on TLS looks for a lowercase s at a fixed position in the string.

On the official Docker images, the same script gets a TLS handshake for all three URLs on both fixed versions:

PHP 8.5.13 -> TLS_HANDSHAKE for https, HTTPS and httpS PHP 8.6.0 -> TLS_HANDSHAKE for https, HTTPS and httpS 

The requests fail there only because the listener doesn't speak TLS.

Redirects: the case you don't control

"I never write HTTPS://, so I'm fine" is the obvious reaction, and it's wrong. The advisory says redirects count. If a server you call over a correct lowercase https:// answers with a 307 and Location: HTTPS://..., PHP follows it and the POST body goes out unencrypted.

I built a local TLS server in PHP that returns exactly that redirect (stream_socket_server() on an ssl:// address with a throwaway self-signed certificate). The results:

PHP 8.5.12: first hop (real TLS) reached over TLS, server replied 307 second hop (redirect) PLAINTEXT_HTTP secret body: yes auth header: no PHP 8.5.13: second hop (redirect) TLS_HANDSHAKE 

The POST body leaked on the second hop, but the Authorization header did not. The advisory says "any retained authentication headers" can leak, so the header may depend on setup.

You don't control what a third-party API, webhook target or OAuth provider puts in a Location header, which is why I'd check this path first.

What isn't affected

curl is fine. curl_init("HTTPS://...") negotiated TLS.

Guzzle 7.17 was fine too, with the default handler, CurlHandler and StreamHandler: all three sent a TLS handshake for HTTPS://.

How to fix it

Upgrade PHP first. 8.5.13 and 8.6.0 passed every test I ran. For 8.4 and older, check the advisory for your branch's fixed version.

If you can't upgrade today:

  • Lowercase the scheme before you pass a URL to any of these functions.
  • Turn off automatic redirects ('follow_location' => 0 in the stream context), or check each redirect's Location yourself before following it. Fixing only the first URL doesn't help, because the redirect target is a new URL that PHP follows on its own.

If your code accepts a URL after checking its scheme without regard to case, rebuild the URL with a lowercase scheme before you fetch it:

$url = 'https' . substr($url, 5); 

With that line in place, HTTPS:// and httpS:// both got a TLS handshake on 8.5.12 in my test.

For a lasting fix, replace any file_get_contents(), fopen() or copy() call that takes a URL, and any FTP usage, with Guzzle. I'd use Guzzle for every outbound request instead of the plain stream functions. In my tests Guzzle 7.17 sent a TLS handshake for HTTPS:// with every handler, including StreamHandler. In a Laravel app that means the Http facade, which is built on Guzzle (I tested Guzzle, not the facade). Keep file_get_contents() and fopen() for local files.

If you still have file_get_contents() calls on URLs in an older project, what's stopping you from moving them to Guzzle?

What I tested and what I didn't

Tested, on Linux with the PHP CLI, against localhost and with fake credentials:

  • PHP 8.5.12, 8.5.13 and 8.6.0.
  • curl, and Guzzle 7.17 with its default handler, CurlHandler and StreamHandler.
  • URL normalisation of HTTPS:// in Chrome 156 (headless) and Node.

Not tested:

  • FTPS and plain FTP.
  • PHP 8.4 and older.
  • Laravel's Http facade itself.
  • A real network capture. I told encrypted from plaintext by the first byte of each connection.

The test listener in full

Start this in one terminal and run the client script in another. It listens on 127.0.0.1 only.

$server = stream_socket_server('tcp://127.0.0.1:18443', $errno, $errstr); while ($conn = @stream_socket_accept($server, -1)) { stream_set_timeout($conn, 2); $data = (string) fread($conn, 65536); $kind = match (true) { $data === '' => 'EMPTY', ord($data[0]) === 0x16 => 'TLS_HANDSHAKE', (bool) preg_match('/^(GET|POST|HEAD) /', $data) => 'PLAINTEXT_HTTP', default => 'OTHER', }; echo json_encode([ 'kind' => $kind, 'first_line' => $kind === 'TLS_HANDSHAKE' ? '<binary TLS ClientHello>' : substr(strtok($data, "\r\n"), 0, 40), 'has_auth_header' => str_contains($data, 'Authorization'), 'has_secret_body' => str_contains($data, 's3cret='), ]), "\n"; @fwrite($conn, "HTTP/1.1 200 OK\r\nContent-Length: 2\r\nConnection: close\r\n\r\nok"); fclose($conn); } 

Sources: PHP advisory GHSA-f6gg-rchx-xw8j (CVE-2026-128064), published Nov 19, 2026 (https://github.com/php/php-src/security/advisories/GHSA-f6gg-rchx-xw8j); PHP 8.6 release announcement; php.net news archive. All test results are from my own runs on Nov 24, 2026.