Skip to content

fix(sandbox): return 400 instead of crashing on malformed WebDAV request paths - #5008

Closed
pedrofrxncx wants to merge 1 commit into
mainfrom
fix/webdav-malformed-path-w2
Closed

pedrofrxncx wants to merge 1 commit into
mainfrom
fix/webdav-malformed-path-w2

Conversation

@pedrofrxncx

@pedrofrxncx pedrofrxncx commented Jul 22, 2026 •

Copy link
Copy Markdown
Collaborator

A concrete validation gap in the sandbox daemon's in-process WebDAV server (apps/mesh/src/file-storage/mount/webdav.ts), which the org-fs mount daemon serves to rclone (loopback-only) to expose org-fs volumes as a real filesystem.

Bug: pathFromUrl() calls decodeURIComponent(new URL(req.url).pathname) to turn the request URL into an in-volume path, but that call was made before the handler's try/catch. A request whose path contains invalid percent-encoding (e.g. GET /%zz) makes decodeURIComponent throw a URIError that escapes uncaught instead of producing a clean HTTP error response — the exact kind of malformed input a filesystem client (buggy rclone cache state, unusual unicode filenames, etc.) can legitimately produce.

Fix: pathFromUrl now catches the decode error and throws a controlled OrgFsApiError(400, ...), and the call site was moved inside the existing try/catch (which already maps OrgFsApiError to its status via mapError). Behavior for every valid path is unchanged — same normalization, same routing.

Regression test: added "400s instead of throwing on invalid percent-encoding" in webdav.test.ts, which reproduces the crash against the real handler (verified it throws before the fix) and asserts a 400 response after.

Reviewer check: bun test apps/mesh/src/file-storage/mount/webdav.test.ts (7 pass, including the new case).

Locally verified: bun run fmt, cd apps/mesh && bunx tsc --noEmit (clean), and the targeted test file above. Full CI covers the rest.


Summary by cubic

Return 400 on malformed WebDAV request paths instead of crashing the sandbox daemon. Prevents uncaught errors when paths have invalid percent-encoding (e.g. %zz) while keeping behavior unchanged for valid paths.

  • Bug Fixes
    • pathFromUrl now catches decode errors and throws OrgFsApiError(400, "Malformed request path").
    • Moved URL parsing inside the handler try/catch so mapError returns a clean response.
    • Added a regression test that asserts a 400 for invalid percent-encoding.

Written for commit e86f717. Summary will update on new commits.

Review in cubic

…est paths

A WebDAV request with an invalid percent-encoded path (e.g. `%zz`) made
decodeURIComponent throw a URIError outside the handler's try/catch, so
the request failed as an uncaught rejection instead of a clean HTTP error.
@pedrofrxncx

Copy link
Copy Markdown
Collaborator Author

Closing as stale: this PR sat past the bot's 48h merge window, main has moved on, and its CI results no longer reflect the current base. This is a housekeeping close, not a rejection of the change — if the underlying problem still exists, the bot will find it again and open a fresh, rebased PR.

[studio-bot:stale-close]

@pedrofrxncx
pedrofrxncx deleted the fix/webdav-malformed-path-w2 branch August 31, 2026 17:41
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.

1 participant