Repository navigation
[13.x] Block phar:// stream wrapper in Filesystem::exists() and isFile() - #62164
Merged
taylorotwell merged 2 commits intoOct 24, 2026
Merged
taylorotwell merged 2 commits into
taylorotwell merged 2 commits into
Conversation
PHP filesystem functions automatically deserialize the PHAR manifest when passed a phar:// URI, which can execute arbitrary code through gadget chains present in vendor dependencies. Filesystem::exists() and isFile() now return false for phar:// paths, preventing deserialization. Filesystem::get() is protected transitively because it calls isFile() internally. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
AsahiSoftWareEngineer
pushed a commit
to AsahiSoftWareEngineer/docs
that referenced
this pull request
Oct 23, 2026
…#62164 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
taylorotwell
pushed a commit
to laravel/docs
that referenced
this pull request
Oct 24, 2026
… upload risk (#11422) * [13.x] Warn against user-controlled filenames in storeAs and polyglot file risk in mimes * [13.x] Warn against PHAR deserialization via File:: facade and response()->download() PHP filesystem functions trigger PHAR archive deserialization when passed a phar:// URI. File::exists(), File::get(), and related methods call these functions directly without scheme validation, as do response()->download() and response()->file() internally via Symfony's BinaryFileResponse. An attacker who can upload a polyglot PHAR file and influence a path argument can exploit this to execute arbitrary code through gadget chains present in vendor dependencies. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Remove PHAR deserialization warnings — addressed in laravel/framework#62164 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Asahi <asahi@AsahinoMacBook-Air.local> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
albertcht
pushed a commit
to hypervel/filesystem
that referenced
this pull request
Nov 1, 2026
Port laravel/framework#62164 (a21f9d110a4b957defa0e14f6e43924b54470c58) together with required follow-up #62174 (02e2f700a3d8d43e55fc1878a593e7cf853c43da). Apply the guard at exists/isFile so dependent file and require helpers reject foreign archives, while applications packaged in a running PHAR retain access to their own files. Compare only the protocol prefix and document the executable-file boundary without relying on obsolete automatic metadata-deserialization behavior. Validation: all upstream cases, real archive rejection and bounded running-archive subprocess coverage pass (91 tests, 233 assertions); source/type analysis and formatting pass.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
There are a few reasons why I think this should be addressed at the framework level.
First, methods like
Filesystem::exists()andisFile()pass paths directly to PHP's native filesystem functions without checking for thephar://scheme. This can potentially introduce a deserialization risk.Interestingly,
Storage::doesn't have the same behavior because Flysystem's path normalizer happens to modify thephar://URI. However, this seems to be an implementation detail rather than an intentional security measure, andFilesystem::doesn't provide equivalent protection.Laravel 13 has already introduced protections against PHP deserialization gadget chains in its cache and session handling. I think it would make sense to apply the same security considerations to filesystem operations for consistency.
The proposed fix is also fairly small. Adding a scheme check to the relevant filesystem methods should be straightforward, without affecting normal filesystem operations.
Changes
Filesystem::exists()returnsfalseforphar://pathsFilesystem::isFile()returnsfalseforphar://pathsFilesystem::get()throwsFileNotFoundExceptionforphar://paths (viaisFile())