From 0e9637ae714bdf1c629cc3487f2fb355d8eea702 Mon Sep 17 00:00:00 2001 From: Johan Date: Wed, 5 Aug 2026 16:17:43 +0200 Subject: [PATCH] Drop form-action from the CSP: it was blocking every login MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added this afternoon, and it broke signing in for everybody — the phone first, then the desktop the moment that session was signed out. Logging in is a form that submits to /login, which answers 302 to the authorize URL on whichever PDS hosts the handle. Chrome and WebKit enforce form-action against the *redirect target* of a submission, not just its immediate action, so 'self' cancelled the navigation to the PDS. Silently: no error, no request, no callback ever reaching the server — the browser just stayed put, which reads as 'the login page bounced me back'. Firefox does not do this, so it looks browser-specific and is not. It cannot be fixed by listing hosts, because in atproto the PDS is wherever that person keeps their repo. form-action does not fall back to default-src, so leaving it out restores the default rather than opening a hole in the rest of the policy. The reader keeps form-action 'none' — it has no forms — with a note saying why it must not be copied to the chat side. Verified: 24 login attempts in the log, all 302 to a PDS, and zero /oauth/callback hits ever on this machine. Co-Authored-By: Claude Opus 5 --- reader/chat.html | 6 +++++- reader/index.html | 6 +++++- server/proxy.py | 18 +++++++++++++++++- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/reader/chat.html b/reader/chat.html index 615c53a..e1fe556 100644 --- a/reader/chat.html +++ b/reader/chat.html @@ -12,7 +12,11 @@ rides in the document. `script-src 'self'` is the point of it: every library this page uses is in shared/, so nothing may be fetched from a CDN even if a tag for one reappears. `connect-src https:` stays open - because reading atproto means talking to whichever PDS hosts the author. --> + because reading atproto means talking to whichever PDS hosts the author. + `form-action 'none'` is safe *here* and is not on the chat side: this page + has no forms. The chat's login is a form that redirects to whichever PDS + hosts the handle, and Chrome and WebKit apply form-action to the redirect + target — which silently cancelled every login. Do not copy this line over. --> diff --git a/reader/index.html b/reader/index.html index f45b32c..adfb481 100644 --- a/reader/index.html +++ b/reader/index.html @@ -11,7 +11,11 @@ rides in the document. `script-src 'self'` is the point of it: every library this page uses is in shared/, so nothing may be fetched from a CDN even if a tag for one reappears. `connect-src https:` stays open - because reading atproto means talking to whichever PDS hosts the author. --> + because reading atproto means talking to whichever PDS hosts the author. + `form-action 'none'` is safe *here* and is not on the chat side: this page + has no forms. The chat's login is a form that redirects to whichever PDS + hosts the handle, and Chrome and WebKit apply form-action to the redirect + target — which silently cancelled every login. Do not copy this line over. --> diff --git a/server/proxy.py b/server/proxy.py index 9cfe7fe..f5fb001 100644 --- a/server/proxy.py +++ b/server/proxy.py @@ -117,6 +117,23 @@ GLOBAL_EVENTS = {"server.connected"} # `'unsafe-inline'` is there because the whole application is one inline script # and one inline style; it is not what this policy is for. `connect-src 'self'` # is: an injected script still could not send anything off this origin. +# **No `form-action`, deliberately.** It was here for one afternoon and it +# broke every login on the service, including for people already signed in the +# moment they signed out. +# +# Logging in is a form that submits to `/login`, which answers 302 to the +# authorize URL on whichever PDS hosts that handle. Chrome and WebKit enforce +# `form-action` against the *redirect target* of a submission, not just its +# immediate action — so `'self'` cancelled the navigation to the PDS silently. +# No error, no console message the user would find, no request reaching +# anything: the browser simply stayed put, which reads exactly like "the login +# page bounced me back". Firefox does not do this, so it depends on the +# browser too. +# +# It cannot be fixed by listing hosts, because the whole point of atproto is +# that the PDS is wherever that person keeps their repo. `form-action` does not +# fall back to `default-src`, so leaving it out is not a hole in the rest of +# this policy — it restores the default of not restricting where forms go. CSP = ("default-src 'none'; " "script-src 'self' 'unsafe-inline'; " "style-src 'self' 'unsafe-inline'; " @@ -124,7 +141,6 @@ CSP = ("default-src 'none'; " "connect-src 'self' https://public.api.bsky.app https://plc.directory; " "font-src 'self'; " "base-uri 'none'; " - "form-action 'self'; " "frame-ancestors 'none'") CONTENT_TYPES = { -- knotmirror 0.0.1