Repository navigation
fix(sandbox): return 400 instead of crashing on malformed WebDAV request paths - #5008
Closed
pedrofrxncx wants to merge 1 commit into
Closed
pedrofrxncx wants to merge 1 commit into
pedrofrxncx wants to merge 1 commit into
Conversation
…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.
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] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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()callsdecodeURIComponent(new URL(req.url).pathname)to turn the request URL into an in-volume path, but that call was made before the handler'stry/catch. A request whose path contains invalid percent-encoding (e.g.GET /%zz) makesdecodeURIComponentthrow aURIErrorthat 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:
pathFromUrlnow catches the decode error and throws a controlledOrgFsApiError(400, ...), and the call site was moved inside the existingtry/catch(which already mapsOrgFsApiErrorto its status viamapError). Behavior for every valid path is unchanged — same normalization, same routing.Regression test: added
"400s instead of throwing on invalid percent-encoding"inwebdav.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.pathFromUrlnow catches decode errors and throwsOrgFsApiError(400, "Malformed request path").try/catchsomapErrorreturns a clean response.Written for commit e86f717. Summary will update on new commits.