Skip to content

Fix admin CSRF rejection caused by no-referrer origin serialization - #15

Merged
Traydr merged 1 commit into
mainfrom
fix/admin-origin-null
Aug 13, 2026
Merged

Traydr merged 1 commit into
mainfrom
fix/admin-origin-null

Conversation

@Traydr

@Traydr Traydr commented Aug 13, 2026

Copy link
Copy Markdown
Owner

Problem

Every admin write returned 403 "The request could not be verified" in a real browser.

The admin pages ship referrer-policy: no-referrer. Per the Fetch spec (whatwg/fetch#1066), browsers serialize the Origin header as null under that policy even for same-origin form POSTs. The CSRF middleware requires an HTTPS same-host Origin, so every browser submission failed — while the test suite and curl, which supply their own Origin header, passed.

Reproduced live: an authenticated POST /admin/spaces with Origin: https://shutter-control.traydr.dev succeeds; the same request with Origin: null returns 403.

Fix

Serve the admin pages with referrer-policy: same-origin: the referrer still never leaves the host, and same-origin POSTs carry the real Origin. A test pins the header so the policy cannot regress to a value that breaks the Origin check.

🤖 Generated with Claude Code

Under referrer-policy: no-referrer, browsers serialize the Origin header
as "null" even on same-origin form POSTs (Fetch spec), so every admin
write failed the same-host Origin check with 403 in a real browser
while passing in tests and curl, which supply their own Origin.

same-origin keeps the referrer inside the admin host and makes the
browser send the real Origin, restoring the check's intent. A test pins
the policy so it cannot regress.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Traydr
Traydr merged commit 46cfc57 into main Aug 13, 2026
1 check passed
@Traydr
Traydr deleted the fix/admin-origin-null branch August 13, 2026 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant