PHP's uppercase-S TLS downgrade (CVE-2026-128064) and proving it on the wire
phptlscvestream-wrappersfile-get-contentsredirectsdemopacket-capture
In affected PHP versions, writing the scheme of a URL with an uppercase S (httpS://, HTTPS://, ftpS://) makes PHP's own HTTP and FTP stream wrappers send the request, headers and body included, in cleartext instead of over TLS. This article records what the bug is, how to tell whether a codebase is exposed, and a general technique for proving a "was this encrypted?" claim: capture the first bytes on a loopback socket and look at them. The version numbers and the header-stripping detail below come from the advisory as recorded in 2026-11 and from tests on two machines (PHP 8.3.32 and 8.3.36), not from an independent audit.
The bug
- PHP picks the stream wrapper by matching the scheme case-insensitively, so
HTTPS://still selects the HTTPS wrapper. The decision to wrap the socket in TLS is made separately, by looking for a lowercasesat a fixed position. An uppercase S fails that test and the socket stays plain. - Only that one letter matters.
HTTPs://(uppercase HTTP, lowercase s) still encrypts;httpS,HTTPSandHtTpSall leak. - It affects the stream wrappers:
file_get_contents(),fopen(),copy(),readfile()and anything else given a URL. cURL is not affected. - A redirect can trigger it on a connection that started out secure: a
307whoseLocationuses an uppercase-S scheme makes PHP re-send the request, POST body and all, in cleartext to the new target. - Affected as recorded: 8.2.0 to 8.2.35, 8.3.0 to 8.3.36, 8.4.0 to 8.4.27, 8.5.0 to 8.5.12, and every end-of-life line. Fixed in 8.2.36, 8.3.37, 8.4.28 and 8.5.13.
Are we exposed? An audit recipe
A vulnerable binary only matters if some code path can hand a stream wrapper an uppercase-S URL.
grepthe web roots for stream functions given a URL (file_get_contents(,fopen(,copy(,readfile(withhttp), and separately for cURL calls, which can be ignored.- For each hit, ask where the URL comes from. A URL built in code with a hardcoded lowercase
https://is safe. A URL from a user, a database row, a webhook payload or a config file is not. - Ask where a redirect could send it. A fetch from a host you do not control can be redirected to an uppercase-S address. Setting
follow_locationto 0 in the stream context, or using cURL, closes that.
On the Alma 9 server, the four stream fetches found all read pre-signed object storage URLs that the S3 client builds with a lowercase scheme, and uploads and deletes go through cURL, so exposure was low even though the binary had the bug.
Distro packages lag the fix
The distro's PHP is a rebuild on its own schedule (Responding to a critical PHP security release (and what to do with an unpatchable server)). On the day this was checked, dnf check-update offered only a rebuild of the same vulnerable 8.3.36. Check the package version and changelog (rpm -q --changelog php-common | head), not the upstream release notes, before calling a server patched, and test the behavior directly where that is cheap.
Proving it: read the first bytes on the wire
TLS and plaintext HTTP are unmistakable from their first byte, so no packet sniffer or root access is needed:
- Open a throwaway TCP listener on 127.0.0.1 on an ephemeral port.
- Have the program under test fetch
"<scheme>://127.0.0.1:<port>/…"with a made-up secret header. - Read what arrives. A first byte of
0x16is a TLS handshake record (the ClientHello). Bytes that readGET /…orPOST /…are plaintext, and the secret will be right there in the dump.
The listener never has to speak TLS or answer at all; the client reveals its intent in the first packet. Nothing leaves the machine. In a single PHP script this needs two processes (listener and client), which pcntl_fork gives you.
The redirect case needs a real first hop: a genuine TLS endpoint (a self-signed certificate made once with the openssl command and cached) that accepts the encrypted request and answers 307 Location: <scheme>://127.0.0.1:<second port>/login, plus a plain listener on the second port to capture what the client sends next.
Lessons from building a public demo of it
The demo page lets a visitor flip the case of the five scheme letters and shows a hex dump of what the server's real PHP then sent.
- Let the visitor control as little as possible. Only the letter casing is input, validated against the 32 case variants of
https. Host, path and the fake secret are hardcoded, so the endpoint cannot be turned into a request forgery tool. Add a per-IP rate limit, because each request forks processes. - Do not fork inside php-fpm.
pcntl_forkin an fpm worker is unsupported and can corrupt the worker. The web endpoint runs a command-line PHP script and returns its JSON. Keep that script outside the docroot. PHP_BINARYunder php-fpm is the fpm binary, not the CLI. Name the CLI binary explicitly.- One
fread()is one TCP segment, not one request. On the server the POST body arrived in a second segment, so a single read captured headers only and the "leaked" password was missing. Loop until the headers and the declaredContent-Lengthhave arrived, or a short timeout passes. - Fixes interact. A different, earlier fix strips the
Authorizationheader when a redirect crosses origins (recorded as CVE-2026-91766, present in 8.3.35 and later). So on 8.3.36 the redirect downgrade leaks the POST body but not the bearer token, while 8.3.32 leaks both. A demo should detect what actually leaked instead of asserting it, and that also makes it update itself once the server is patched. - Link the CVE at cve.org. The NVD site answered 403 to the server's datacenter address.
- A data directory the web server writes to (rate-limit files, the cached certificate) needs the
httpd_sys_rw_content_tSELinux type; see SELinux file contexts and booleans on web servers.
See also
- Responding to a critical PHP security release (and what to do with an unpatchable server)
- Accepting and serving user uploads safely from a private bucket
- Linode (Akamai) Object Storage