- Functionality: Implements the File System Access API (Spec), allowing web applications to interact directly with files and directories on the user's local device after explicit user permission grant via picker UIs.
- Key Logic: Handling user gestures for picker initiation (
showOpenFilePicker
,showSaveFilePicker
,showDirectoryPicker
), managing permissions (FileSystemAccessPermissionContext
), representing file/directory handles (FileSystemAccessFileHandleImpl
,FileSystemAccessDirectoryHandleImpl
), performing file operations (read, write, create), managing locks (FileSystemAccessLockManager
), transferring handles (createFileSystemAccessDataTransferToken
). - Core Files:
content/browser/file_system_access/file_system_access_manager_impl.cc
/.h
: Main browser-side manager. Handles picker initiation (ChooseEntries
,SetDefaultPathAndShowPicker
).content/browser/file_system_access/file_system_access_file_handle_impl.cc
/.h
content/browser/file_system_access/file_system_access_directory_handle_impl.cc
/.h
: Implements directory handle operations likeGetFileHandle
,GetDirectoryHandle
.content/browser/file_system_access/file_system_access_permission_context_impl.cc
/.h
storage/browser/file_system/file_system_operation_impl.cc
: Implements underlying file operations likeDirectoryExists
,CreateDirectory
.storage/browser/file_system/async_file_util_adapter.cc
: Adapts sync file utils.storage/browser/file_system/native_file_util.cc
: Platform-agnostic native file utilities. Callsbase::GetFileInfo
.base/files/file_util_win.cc
,base/files/file_util_posix.cc
: Platform-specific file utilities likeGetFileInfo
.
- Information Leaks via Pickers:
- VRP Pattern (Environment Variable Leak - MITIGATED):
showSaveFilePicker
'ssuggestedName
. Mitigated by%
replacement. (VRP:1247389
, etc.; VRP2.txt#1102, #2980).
- VRP Pattern (Environment Variable Leak - MITIGATED):
- Permission Bypass/Scope Issues:
- VRP Pattern (Symlink Scope Bypass - POSIX): Insufficient handling of symbolic links on POSIX platforms. When
FileSystemAccessDirectoryHandleImpl::GetDirectoryHandle
is called on a symlink name:GetDirectoryResolved
callsFileSystemOperationRunner::DirectoryExists
-> ... ->base::GetFileInfo
.- On POSIX:
base::GetFileInfo
usesstat()
which follows symlinks by default (confirmed by code search and TODO comment inbase/files/file_util_posix.cc
). If the target is a directory, the check succeeds. GetDirectoryResolved
lacks a subsequent check to validate if the resolved path (after following the symlink) is still within the scope of the original directory handle's permission grant.- A new directory handle is created for the symlink's target path, allowing access outside the granted scope.
(VRP:
1378484
- symlink via<input webkitdirectory>
, VRP2.txt#10231 - symlink viaGetDirectoryHandle
). Note:GetFileHandle
does have aConfirmSensitiveEntryAccess
check which might mitigate this for files, but it is missing for directories.
- VRP Pattern (Symlink Scope Bypass - POSIX): Insufficient handling of symbolic links on POSIX platforms. When
- Interaction with Other Features:
- VRP Pattern (Extension File Read via FSA+Downloads): Combining FSA permissions with
chrome.downloads
API to read arbitrary files (VRP:1428743
, VRP2.txt#4610). See downloads.md.
- VRP Pattern (Extension File Read via FSA+Downloads): Combining FSA permissions with
- Silent File Overwrite:
- VRP Pattern (Save Picker + Enter Key): Using Enter key to confirm save dialog initiated by
showSaveFilePicker
without sufficient interaction delay (VRP:1243802
, VRP2.txt#9302). See input.md.
- VRP Pattern (Save Picker + Enter Key): Using Enter key to confirm save dialog initiated by
- Policy Bypass: (
FileSystemAccessWriteBlockedForUrls
).
- Picker Behavior (
show*Picker
): UI interactions, gesture requirements, interaction delay protection (relevant to VRP:1243802
). - Symlink Resolution & Scope Checks (POSIX): The core issue is confirmed:
base::GetFileInfo
follows symlinks viastat()
, andGetDirectoryResolved
lacks the necessary subsequent scope check. The fix requires adding this validation step. Similar paths like<input webkitdirectory>
should also be audited. - Permission Model (
FileSystemAccessPermissionContext
): Persistence, escalation paths, lifetime management. - Handle Management & Transfer: Lifetime, manipulation potential, postMessage transfer security.
- Locking (
FileSystemAccessLockManager
): Race conditions in acquiring/releasing locks. - Enterprise Policy Enforcement: Bypasses for
FileSystemAccessWriteBlockedForUrls
, etc. .url
File Handling: How are Windows shortcut files treated? Do they pose similar risks to symlinks? (VRP:1303486
).
FileSystemAccessManagerImpl
: Main manager.ChooseEntries
,SetDefaultPathAndShowPicker
.FileSystemAccessDirectoryHandleImpl
: Implements directory ops.GetDirectoryResolved
: CallsDirectoryExists
. Crucially lacks scope validation afterDirectoryExists
succeeds for a symlink pointing outside the granted directory on POSIX.GetFileResolved
: IncludesConfirmSensitiveEntryAccess
check (might prevent symlink bypass for files).
FileSystemAccessPermissionContext
: Manages permissions.FileSystemOperationImpl
: Implements file ops.DirectoryExists
usesAsyncFileUtil::GetFileInfo
.AsyncFileUtilAdapter
: Wraps sync utils.NativeFileSystemFileUtil
: Callsbase::GetFileInfo
.base::GetFileInfo
(file_util_posix.cc
): Platform-specific metadata retrieval. Confirmed to usestat()
which follows symlinks. Contains TODO comment acknowledging need for refactoring symlink handling.SelectFileDialog
/FileChooserImpl
: Picker UI /<input>
elements. Check for interaction bypasses.
- Symlink Scope Check Fix (POSIX): Implement scope validation check within
FileSystemAccessDirectoryHandleImpl::GetDirectoryResolved
afterDirectoryExists
returns success. The check should compare the resolved path (obtained perhaps viabase::ReadSymbolicLink
or similar after detecting it's a symlink) against the handle's original granted path. .url
File Handling: Investigate how.url
files are handled by FSA operations. Are they treated as links? If so, are appropriate scope checks performed? (VRP:1303486
).- Picker Parameter Sanitization: Audit suggested name handling and other parameters passed to picker functions.
- Interaction Delays for Pickers: Verify clickjacking/keyjacking protection (
InputEventActivationProtector
?) forshow*Picker
calls (VRP:1243802
). - Handle Lifetime/Revocation: Ensure handles are correctly invalidated if permissions are revoked.
- Cross-Component Interactions: Downloads API (VRP:
1428743
), Drag/Drop, other APIs accessing the filesystem.
- Environment Variable Leaks (Mitigated for FSA): VRP:
1247389
, etc.; VRP2.txt#1102, #2980. - Symlink Scope Bypass (POSIX): VRP:
1378484
, VRP2.txt#10231 (Confirmed POSIX-specific due tostat()
following symlinks and lack of scope check after resolution inGetDirectoryHandle
flow). - Download Interaction: VRP:
1428743
/ VRP2.txt#4610. - Silent Save/Overwrite: VRP:
1243802
/ VRP2.txt#9302. .url
File Handling: VRP:1303486
/ VRP2.txt#12993.