Skip to content

Conversation

@markknoffler
Copy link

Fixes #517

Summary

This PR fixes a security vulnerability in FileExplorer by 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

  • Added sandbox restriction: FileExplorer now restricts file access to a configurable sandbox directory (defaults to current working directory)
  • Blocked sensitive system paths: Explicitly blocks access to /etc, /usr, /bin, /sbin, /var, /sys, /proc, /dev, /root
  • Blocked sensitive home paths: Blocks access to ~/.ssh, ~/.bashrc, ~/.bash_history, ~/.zshrc, ~/.gitconfig, ~/.env
  • Path validation: All paths are validated before any file operation
  • Clear error messages: Returns descriptive error messages when access is denied

Security Impact

Before: FileExplorer could read any file accessible to the process, allowing:

  • Credential theft (SSH keys, API tokens, passwords)
  • System information disclosure (/etc/passwd, config files)
  • Privacy violations (user data, personal files)

After: FileExplorer is restricted to a sandbox directory and blocks access to sensitive paths, preventing arbitrary file reads.

Implementation Details

  • Added __init__() method with optional sandbox_root parameter
  • Added _validate_path() method that checks:
    1. Path is within the sandbox root
    2. Path is not in a restricted system directory
    3. Path is not a sensitive home directory file
  • Updated call() method to validate paths before file operations
  • Updated documentation and examples to reflect sandboxing

Testing

The fix has been verified with a demo script that shows:

  • Attempts to access paths outside sandbox → Access denied
  • Attempts to access sensitive home files → Access denied
  • Attempts to access system files → Access denied

All attack scenarios are now properly blocked.

Screenshot 2026-01-26 at 1 40 26 AM

…cess

Restricts FileExplorer to a configurable sandbox directory and blocks access to sensitive system and home directory paths.

- Add sandbox_root parameter (defaults to current working directory)
- Block access to sensitive system paths (/etc, /usr, /bin, etc.)
- Block access to sensitive home directory paths (~/.ssh, ~/.bashrc, etc.)
- Validate all paths before file operations
- Use os.path.expanduser for home directory detection (epath.Path doesn't have home() method)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FileExplorer tool allows arbitrary file reads without path restrictions (security vulnerability)

1 participant