Repository navigation
Confine the file path Share.File vends to the share sheet - #5
Merged
Merged
Conversation
Share.File takes a filePath straight from the web view bridge and hands it to
the OS share sheet with no checks. A page (XSS, or bundled third-party JS) can
name .env or the SQLite database and have the share sheet offer it up — a file
read-out. It is gated by the user picking a share target, so lower severity
than mobile-file's silent copy, but the same root cause.
Mirror the source-side confinement from core's FileFunctions: canonicalise the
path (resolving symlinks and ..) and require it to land inside one of the app's
readable roots — the OS temp dir, the caches dir, or storage_path('app') —
before anything reaches the share sheet. Anything else (.env, *.sqlite,
public/, bootstrap/cache, storage/framework) is refused. URLs are not files, so
the URL branch is left alone, and the documented use (sharing a captured file
from temp/cache or storage/app) still works.
The storage root is derived from LARAVEL_STORAGE_PATH + /app on iOS and
getDir("storage")/persisted_data/storage/app on Android, matching how core
resolves storage_path(), so it tracks the persistent location rather than the
ephemeral app extract.
Tests read the two native files and assert the guard stays in place and ahead
of the share call on both platforms, since no PHP test can run the native code.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Confines the file path
Share.Filehands to the share sheet, so a web view page can't exfiltrate a named sandbox file.Share.Filetook a page-suppliedfilePathand passed it to the OS share sheet (iOSUIActivityViewController, AndroidFileProvider+ACTION_SEND) with no confinement. Because/_native/api/callis reachable from web view script (an XSS, or a bundled third-party script), a page could name.envor the SQLite database and have it vended out. It's gated by the user picking a share target, so lower severity than a silent read, but the same root cause as thenativephp/mobile-filepath issue.The fix confines the source: canonicalise
filePath(resolve symlinks and..) and require it to resolve inside the app's readable roots (temp, caches,storage_path('app')), refusing.env,*.sqlite,bootstrap/cache,storage/framework,storage/logs,public/. Legitimate use — sharing a file the app captured into temp/cache/storage — still works. Source-assertion tests pin the guard on both platforms. Releases as 1.1.1.🤖 Generated with Claude Code