PHP advisory: mixed-case HTTPS and FTPS URLs can expose data in plaintext github...

@best

PHP advisory: mixed-case HTTPS and FTPS URLs can expose data in plaintext github.com · 12 points · 2 comments · HN thread

TL;DR A GitHub security advisory for PHP says the HTTP and FTP stream wrappers skip TLS when an HTTPS or FTPS URL has an uppercase letter in its scheme, such as HTTPS:// or FTPS://. Because the TLS check looks at a lowercase 's' at a fixed position, data passed to functions like file_get_contents() or fopen() can travel unencrypted, exposing credentials, tokens, POST bodies or files to network observers. The fix compares the whole scheme case-insensitively, and no patched release is named yet.

  • The stream wrappers parse schemes case-insensitively, but the TLS decision checks for a lowercase 's' at a fixed position, so uppercase or mixed-case HTTPS and FTPS URLs use plaintext HTTP or FTP.
  • Applications whose own case-insensitive HTTPS or FTPS validation passes such URLs are affected, and so are HTTP redirects to uppercase HTTPS:// targets, where POST bodies and retained auth headers can be sent in cleartext.
  • Impact includes Basic auth credentials, bearer tokens, cookies, POST data, FTP logins and file contents, for an attacker who can observe the traffic.
  • The advisory says mixed-case URLs have been affected since PHP 5.2.0 and redirects since PHP 4.3.0, based on code inspection rather than a demonstrated exploit.
  • Mitigations: lowercase the scheme before calling stream functions, and disable automatic redirects or validate and normalise every redirect target. Normalising only the initial URL does not cover redirects.
  • The fix is said to compare the full scheme case-insensitively in both the HTTP and FTP wrappers; a fixed release is not yet available at the time of the advisory.

Discussion The thread is very small, with two comments. One commenter questions the scope of the advisory, noting that the description covers more than mixed case, since fully uppercase schemes like HTTPS:// are also affected, and speculates about legacy systems that uppercase URLs to save space. The other comment only points to a related Hacker News discussion about PHP 8.5.13. The mood is neutral and factual, with no strong debate.

  • Scope is broader than mixed case, including all-uppercase schemes (some): A commenter points out that the advisory's wording covers any uppercase 's' in the scheme, so fully uppercase URLs are affected too. They suggest legacy systems that store or convert URLs to uppercase, for example to save space, could be exposed.
  • Related discussion exists for the PHP 8.5.13 release (a few): One commenter links to a separate Hacker News thread tied to PHP 8.5.13, suggesting the issue may be connected to that release cycle.

Links from the comments

#php #security #tls #streamWrappers #vulnerability #httpRedirects