Add sandbox restrictions to FileExplorer to prevent arbitrary file access #518
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.
Fixes #517
Summary
This PR fixes a security vulnerability in
FileExplorerby adding path restrictions and validation. The tool previously allowed unrestricted access to any file the process could read, including sensitive system files, SSH keys, and user credentials.What Changed
FileExplorernow restricts file access to a configurable sandbox directory (defaults to current working directory)/etc,/usr,/bin,/sbin,/var,/sys,/proc,/dev,/root~/.ssh,~/.bashrc,~/.bash_history,~/.zshrc,~/.gitconfig,~/.envSecurity Impact
Before: FileExplorer could read any file accessible to the process, allowing:
/etc/passwd, config files)After: FileExplorer is restricted to a sandbox directory and blocks access to sensitive paths, preventing arbitrary file reads.
Implementation Details
__init__()method with optionalsandbox_rootparameter_validate_path()method that checks:call()method to validate paths before file operationsTesting
The fix has been verified with a demo script that shows:
All attack scenarios are now properly blocked.