Fix: form-action CSP blocked atproto login form submission (v0.4.2)#107
Merged
Conversation
The handle-entry form sets a strict CSP. The `form-action 'self'` directive (added for defense-in-depth) silently broke login: submitting the form hits our endpoint, which immediately 302-redirects to the user's own authorization server (any PDS, cross-origin). `form-action` is enforced across the entire redirect chain, so `'self'` blocks the submission and the browser does nothing — exactly the "form doesn't send me there" symptom, while navigating to the auth URL directly worked (no form-action involved). Remove the `form-action` directive entirely — it is fundamentally incompatible with a login form that must redirect to per-user auth servers. The rest of the hardening (default-src 'none', no scripts, frame-ancestors, nosniff, no-store, style-src 'self') stays. Add a regression test asserting the form CSP never carries form-action. Reproduced and verified the fix by driving the form in headless Chrome. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
startup-api | 1ef82e6 | Jun 29 2026, 02:36 AM |
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.
Regression in 0.4.1 — atproto login form does nothing
The hardened CSP added to the handle-entry form in #106 included
form-action 'self', which silently breaks login.Root cause
Submitting the handle form hits our
/users/auth/atproto?handle=…endpoint, which immediately 302-redirects to the user's own authorization server (any PDS —bsky.socialor self-hosted, cross-origin).form-actionis enforced across the entire redirect chain, so'self'rejects the submission and the browser does nothing.This is exactly the reported symptom: navigating to the auth URL directly works (no form involved), but the form "doesn't send you there."
Reproduced in headless Chrome — the console shows:
Fix
Remove the
form-actiondirective from the handle form. It's fundamentally incompatible with a login form that must redirect to per-user auth servers. All other hardening stays:default-src 'none'(no scripts),frame-ancestors 'none',style-src 'self',nosniff,no-store. Added a regression test asserting the form CSP never carriesform-action.Verified
wrangler dev: submission now navigates to the auth endpoint with the handle and no CSP violation (localhost returns 400 only because bsky can't fetch a127.0.0.1client-metadata URL for PAR; on the live HTTPS demo it 302s to bsky).tsc+eslintclean; full suite 129/129.Bumps patch version to 0.4.2 (0.4.1 is live-broken).
🤖 Generated with Claude Code