Repository navigation
fix(rest): accept the session cookie on PUT /file with a required Origin (R-56, S-37) - #35
Merged
Merged
Conversation
…gin (R-56, S-37) The editor uploads kit manifests and .kit files with a same-origin fetch PUT to /file/sedona/..., carrying only its sandstar_session cookie. PUT /file/* sat behind check_auth (bearer only), so with auth on every kit upload got 401. Reads already accept the cookie (S-33). New check_write_auth / require_write_auth, used only by PUT /file/*: - auth not configured: every request passes (field default); - valid bearer: passes, Origin not checked (as before); - valid session cookie: passes only with an Origin header that matches the Host or --ws-allowed-origins; missing or foreign Origin gets 403. Browsers always send Origin on PUT, so this backs up the cookie's SameSite=Strict against cross-site request forgery; - otherwise 401. Routes/auth: PUT /file/* moves from require_auth to require_write_auth (still inside an auth layer). Every other write route stays bearer-only; a test checks they reject the cookie. GET /file/* and path handling (safe_join) are unchanged. Editor: no change needed. Tests: cookie/Origin matrix on PUT /file/* (none, forged cookie, same-host, allowlisted, missing, foreign, null, other port, subdomain, ftp scheme, case, duplicate cookie, second Cookie header, bearer with and without Origin); it failed on the old gate. Other write routes reject the cookie; open when auth is off. gates: 2910 passed / 0 failed. Local E2E with the real binary (--auth-token, temp SANDSTAR_FILE_ROOT): 401 / 200 / 200 / 403 / 403 / 401 / 200, file written and read back with the cookie. Largest kit in the repo is 189 KB, under the 1 MiB body limit. Not tried: a real kit upload from the editor. Docs: OVERVIEW §3 PUT /file row, HowToUses/03_WEB_EDITOR.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QKRNiek8qYRoRt7dcrDDVC
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.
Summary
PUT /file/sedona/...carrying only itssandstar_sessioncookie;PUT /file/*accepted bearer only, so with auth on kit uploads got 401 (R-56).check_write_auth(onlyPUT /file/*): bearer passes; a valid cookie passes only with anOriginmatching theHostor--ws-allowed-origins(missing/foreign Origin → 403); otherwise 401; auth off → open.Routes / auth
PUT /file/*moves fromrequire_authtorequire_write_auth.GET /file/*andsafe_joinunchanged.Test plan
PUT /file/*(fails on old gate), other write routes reject the cookie, open with auth offbash tools/gates.sh: 2910 passed / 0 failed--auth-tokenand a temp file root: status matrix as expected, file written and read backsecurity-reviewer: no significant findings; suggested regression cases added🤖 Generated with Claude Code
https://claude.ai/code/session_01QKRNiek8qYRoRt7dcrDDVC