Skip to content

fix: with_dynamic_directory path traversal#9162

Merged
mscolnick merged 2 commits intomainfrom
ms/dynamic-dir-path
Apr 13, 2026
Merged

fix: with_dynamic_directory path traversal#9162
mscolnick merged 2 commits intomainfrom
ms/dynamic-dir-path

Conversation

@mscolnick
Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings April 13, 2026 15:25
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 13, 2026

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

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview, Comment Apr 13, 2026 3:48pm

Request Review

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 hardens the with_dynamic_directory ASGI middleware against path traversal attempts when resolving app files from a filesystem directory.

Changes:

  • Added path traversal rejection and “must be within directory” checks when resolving dynamic app file paths.
  • Added regression tests covering raw, encoded, and nested traversal requests.

Reviewed changes

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

File Description
marimo/_server/asgi.py Adds directory-containment validation and rejects traversal segments during dynamic file matching.
tests/_server/test_asgi.py Adds a new test validating traversal attempts are blocked (return 404/pass-through).

Comment thread tests/_server/test_asgi.py Outdated
Comment thread marimo/_server/asgi.py Outdated
@mscolnick mscolnick added the bug Something isn't working label Apr 13, 2026
@mscolnick mscolnick merged commit d9cdc57 into main Apr 13, 2026
43 checks passed
@mscolnick mscolnick deleted the ms/dynamic-dir-path branch April 13, 2026 19:28
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