Skip to content

Fix sandbox bypass and frontend/backend desync in file explorer#280

Merged
Edwardvaneechoud merged 2 commits intomainfrom
claude/fix-filebrowser-navigation-21ean
Jan 31, 2026
Merged

Fix sandbox bypass and frontend/backend desync in file explorer#280
Edwardvaneechoud merged 2 commits intomainfrom
claude/fix-filebrowser-navigation-21ean

Conversation

@Edwardvaneechoud
Copy link
Copy Markdown
Owner

Summary

This PR fixes a critical security and UX issue in the file explorer where invalid paths could cause frontend/backend state desynchronization. The changes enforce strict sandbox validation and improve error handling across the stack.

Key Changes

  • Backend validation (funcs.py): Changed SecureFileExplorer to raise PermissionError when initial path is outside sandbox, instead of silently falling back to sandbox root. This prevents silent state mismatches between frontend and backend.

  • Route error handling (routes.py):

    • Added Electron mode detection to conditionally disable sandboxing (allow full filesystem access in Electron, sandbox to user data directory otherwise)
    • Added explicit PermissionError handling to return HTTP 403
    • Fixed missing raise statement for 404 exception
  • Frontend resilience (fileBrowser.vue):

    • Enhanced navigateToPath() to gracefully handle navigation failures
    • On error, reverts to previous directory state and shows a warning message instead of entering an error state
    • Prevents user from being stuck in an invalid state when navigation fails

Implementation Details

The fix ensures that when a user attempts to navigate to a restricted path:

  1. Backend rejects it with a clear PermissionError
  2. Frontend catches the error, reverts local state, and notifies the user
  3. User remains at their previous valid location with full functionality intact

This approach prioritizes user experience while maintaining security boundaries.

The file browser would get out of sync between frontend and backend when
navigating up past the home directory. The backend silently returned the
home directory contents instead of an error, while the frontend updated
its path state to the requested (parent) directory. This caused all
subsequent navigation to break.

Three changes:
- In Electron mode, remove the sandbox restriction so users can browse
  the entire filesystem (matching the existing validate_path_under_cwd
  behavior for desktop apps)
- SecureFileExplorer now raises PermissionError instead of silently
  falling back to the sandbox root when the path is outside the sandbox
- Frontend navigateToPath reverts to the previous directory on failure
  instead of showing an error state, keeping the browser usable

Also fixes a missing 'raise' on HTTPException in the directory_contents
error handler.

https://claude.ai/code/session_01TtjvcF8KWykkB1o6mStB5L
@netlify
Copy link
Copy Markdown

netlify bot commented Jan 30, 2026

Deploy Preview for flowfile-wasm canceled.

Name Link
🔨 Latest commit 43e0d9b
🔍 Latest deploy log https://app.netlify.com/projects/flowfile-wasm/deploys/697cd068af5897000818e952

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jan 30, 2026

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Covers the new Electron/non-Electron mode branching and error handling:
- Electron mode allows browsing any readable directory
- Non-Electron mode blocks access outside sandbox (403)
- Non-Electron mode allows access inside sandbox (200)
- Non-existent directory returns 404

https://claude.ai/code/session_01TtjvcF8KWykkB1o6mStB5L
@Edwardvaneechoud Edwardvaneechoud merged commit 64bca38 into main Jan 31, 2026
21 checks passed
@Edwardvaneechoud Edwardvaneechoud deleted the claude/fix-filebrowser-navigation-21ean branch February 2, 2026 20:27
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.

3 participants