The Patch Asked The URL Parser What The phar Wrapper Would Open
The April 4 commit landed against Shared/File.php as 93c94eb. It added two behaviors to the static File class: a new prohibitWrappers helper, and a call to prohibitWrappers placed at the top of assertFile and testFileNoThrow, the two functions every reader's load path passes through. The helper:
public static function prohibitWrappers(string $filename): void
{
$scheme = parse_url($filename, PHP_URL_SCHEME);
// strlen check > 1 to avoid issues with Windows absolute paths (e.g. C:\...), Windows quirks :)
// since no built-in or commonly registered PHP stream wrapper uses a single-character scheme, this should be ok, to my knowledge
if (is_string($scheme) && strlen($scheme) > 1) {
throw new Exception(
"Stream wrappers are not permitted as file paths: {$filename}"
);
}
}
The two comments are testimony. The first explains why the threshold is "longer than one character" rather than "any string at all": Windows drive letters like C:\foo parse as scheme c, and the maintainer wanted the helper to leave them alone. The second tells the reader what threat model the check was sized against: schemes shorter than the names of registered PHP stream wrappers. "To my knowledge" is what the maintainer wrote on the line where they decided this was the security primitive that would carry the patch for a CVSS 9.8 deserialization bug.
The threat that landed against the helper as CVE-2026-45034 was not a single-character scheme. It was parse_url deciding it could not parse the input at all.
parse_url Returned False And The Check Read False As Safe
The bypass URL is in the unit test that shipped with the May 14 fix:
$reader->load('phar:///anyoldname');
The change from the original CVE's input is one slash. Two slashes after the scheme is the canonical phar form: phar://archive.phar/inner. Three slashes is the same form with an empty authority and /archive.phar/inner interpreted as the path. PHP's phar:// stream wrapper, the sink, accepts both. PHP's parse_url, the gate, returns an array for the canonical form and false for the empty-authority variant. The PHP manual is explicit about the false case: parse_url() returns false on what it considers "seriously malformed" URLs. The seriously-malformed judgement belongs to the function, not to the caller.
The check tested the wrong return value. is_string($scheme) is the correct test when parse_url returns either the scheme string or null for "no scheme present." It is the wrong test when the third possible return is false for "I could not parse this." Inside the function, the three return values mean three different things. Inside the call site, all of them except the long string are treated as a green light.
The phar wrapper does not consult parse_url. The PHP runtime's is_file(), the next line in assertFile, opens the path through whatever stream wrapper the scheme registers. The phar extension is registered against the four characters phar. Once those four characters appear at the head of the string followed by ://, the wrapper accepts the rest, regardless of how many slashes follow or what authority lies between them. The runtime opens the archive, reads the manifest, and calls unserialize() on the metadata.
The First Fix Was One Line. The Maintainer Spent The Next Two Weeks Walking It Back.
On May 14 the bypass landed as commit 0d9203b. The helper changed:
public static function prohibitWrappers(string $filename): void
{
- $scheme = parse_url($filename, PHP_URL_SCHEME);
- if (is_string($scheme) && strlen($scheme) > 1) {
+ if (str_contains($filename, '://')) {
throw new Exception(
"Stream wrappers are not permitted as file paths: {$filename}"
);
}
}
That is the correct fix in the smallest possible form. str_contains does not parse, does not validate, does not return false for ambiguous inputs. It answers one question against the byte stream: is the substring :// present anywhere in the filename. If yes, the call is a stream-wrapper invocation; reject. The grammar of the gate is now identical to the grammar of the sink, because every PHP stream wrapper registers a scheme that ends in :// and nothing else does.
Nine days later, commit 2b89a7b reverted the one-line fix:
- if (str_contains($filename, '://')) {
+ if (
+ preg_match('~^phar://~i', $filename)
+ || (preg_match('/^([\w\s\x00-\x1f]+):/u', $filename) && !preg_match('/^([\w]+):/u', $filename))
+ || preg_match('~^php://.*phar:~i', $filename)
+ ) {
The commit message reads Block Phar Only. The reason for the rewrite is hidden in that name: str_contains('://') blocked too much. Callers passing legitimate http and ftp URLs into PhpSpreadsheet's own Drawing constructor were now rejected at the file boundary. The maintainer decided that the gate should match the specific sink the bypass had used, not the full grammar of stream wrappers.
Five days later, commit 974b349 added another regex to the chain. Its message is Close One Other Possible Vector. The new branch matches any scheme containing dots followed by :// with the substring phar: anywhere downstream, because the phar wrapper accepts compress.zlib://phar:archive.phar/inner as a phar invocation passed through the zlib decoder, and the gate now has to know that. Later the same day, commit ee67357 deleted the prior php://.*phar: branch because the new wider regex made it redundant. The message is Unneeded Check.
prohibitWrappers is a design-debt driver. The first phar-bypass fix shipped in one line on May 14. The first phar-bypass fix that the maintainer was willing to ship as the permanent gate took three more commits and fourteen more days. Five commits, two CVEs, two months of churn against one fourteen-line function, because the gate is sized against PHP's open-ended stream-wrapper registry, and every new wrapper composition is a new edge case the matcher has to learn.
What The Changelog Says The Patch Did Not Fix
The 5.8.0 changelog announces the bypass fix in a section labelled "Security Note":
A prior change had attempted to eliminate the ability to use input files using the phar protocol. Some filenames using that protocol were not caught by the earlier change. That is now fixed. The failure to detect these files did not lead to a security exposure in PhpSpreadsheet. However, if you relied on "PhpSpreadsheet can read the file" as a surrogate for "it is safe to read the file's metadata", you should not do so.
This is denial-by-pedantry. The phrase doing the work is "in PhpSpreadsheet." The function is named prohibitWrappers. It was added on the day of the CVE-2026-34084 patch as the technical control that closes that CVE. Its call sites are assertFile and testFileNoThrow, both of which exist to give downstream callers a single seam through which to ask "is it safe to read this file." The function failed for 40 days against a one-slash variant of the input it was added to reject. The library's changelog response is that callers who took the function at its name were wrong to.
The maintainer is technically correct that PhpSpreadsheet itself does not call Phar::getMetadata() on the input file. The deserialization side of the phar attack lands when downstream code, an audit logger, a thumbnail generator, an antivirus integration, calls a phar-aware PHP function on a path that PhpSpreadsheet has already validated and returned as readable. The library's contract was "I have asserted this path is a file you may open." The library's defence is that callers should not have read it that way.
Gate Narrower Than Sink
This is the gate-narrower-than-sink shape. Two matchers describe the same syntactic object, "is this string a stream-wrapper invocation," and they disagree. One matcher is parse_url, an opportunistic URL parser whose documented behavior is to return false on inputs it cannot parse. The other matcher is the PHP runtime's stream-wrapper dispatch, which accepts any string of the form <registered-scheme>://<arbitrary-bytes> and routes the call. The gate's grammar is strictly contained within the sink's. The inputs the sink accepts and the gate does not match flow through.
We have written about this shape against W3 Total Cache, where a regex with \s+ was the gate and a regex with \s* was the executor; against Starlette, where urlsplit reading a rebuilt URL was the gate and the ASGI router reading the raw request line was the sink; against shell-quote, where a JavaScript regex character class was the gate and POSIX sh was the sink. The shape recurs because the cheapest way to write a security check is to reach for a parser that already exists in the standard library, and the standard library's parser is rarely the one the sink uses.
parse_url is the most expensive form of the mistake. It is a function whose name reads as authoritative and whose documented behavior includes returning false for any input the function decides is "seriously malformed." When that function is the gate, every input the function disclaims becomes a token the downstream sink may interpret without constraint. The downstream sink is the one that decides what the string means. The gate only decided what it could parse.
PoC: GHSA-87m4-826x-3crx
The patch closes CVE-2026-45034. The next bypass will be filed against whichever stream-wrapper invocation the regex chain on line 147 of Shared/File.php reads as not-a-phar and PHP's stream-wrapper registry reads as one.