Skip to content

fix: file navigator#9307

Merged
dmadisetti merged 3 commits into
mainfrom
dm/file-nav
Apr 23, 2026
Merged

fix: file navigator#9307
dmadisetti merged 3 commits into
mainfrom
dm/file-nav

Conversation

@dmadisetti

Copy link
Copy Markdown
Member

📝 Summary

File browser path restriction can be subverted

@dmadisetti dmadisetti requested review from Copilot and mscolnick April 21, 2026 19:04
@vercel

vercel Bot commented Apr 21, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview, Comment Apr 23, 2026 7:33pm

Request Review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR closes a path traversal / navigation restriction bypass in the file browser by tightening the server-side containment check and adding regression tests for common escape attempts.

Changes:

  • Hardened _list_directory navigation restriction to require the requested path to be contained within the initial path.
  • Added tests covering sibling directory access, arbitrary absolute paths, and .. traversal escapes.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
marimo/_plugins/ui/_impl/file_browser.py Replaces the parent-only restriction check with a containment check based on resolve() + relative_to().
tests/_plugins/ui/_impl/test_file_browser.py Adds regression tests for multiple navigation bypass vectors.

if self._restrict_navigation:
try:
path.resolve().relative_to(self._initial_path.resolve())
except ValueError:

Copilot AI Apr 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Path.resolve() can raise exceptions other than ValueError (e.g., RuntimeError for symlink loops, OSError for invalid paths). Currently those would bubble up as unexpected errors rather than a consistent "navigation restricted" failure. Consider catching those exceptions and raising a controlled RuntimeError (or a more specific exception type) with an appropriate message.

Suggested change
except ValueError:
except (ValueError, RuntimeError, OSError):

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would add these errors

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

symlink loops

Symlink loops create an OSError, but added

Comment thread marimo/_plugins/ui/_impl/file_browser.py Outdated
Comment thread marimo/_plugins/ui/_impl/file_browser.py
Comment thread tests/_plugins/ui/_impl/test_file_browser.py
Comment thread tests/_plugins/ui/_impl/test_file_browser.py
Comment thread tests/_plugins/ui/_impl/test_file_browser.py
@dmadisetti dmadisetti added the bug Something isn't working label Apr 21, 2026
mscolnick
mscolnick previously approved these changes Apr 23, 2026
@dmadisetti dmadisetti merged commit c5e88fa into main Apr 23, 2026
43 checks passed
@dmadisetti dmadisetti deleted the dm/file-nav branch April 23, 2026 19:36
@github-actions

Copy link
Copy Markdown

🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.23.3-dev34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants