Skip to content

fix(csp): resolve the consent form-action origin for PAR and localhost clients - #62

Merged
matthew-demidoff merged 1 commit into
masterfrom
fix/consent-csp-par
Aug 20, 2026
Merged

fix(csp): resolve the consent form-action origin for PAR and localhost clients#62
matthew-demidoff merged 1 commit into
masterfrom
fix/consent-csp-par

Conversation

@matthew-demidoff

@matthew-demidoff matthew-demidoff commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

b4684ab widened form-action on /oauth/authorize from the redirect_uri query param only. PAR clients (RFC 9126) arrive with client_id + request_uri and no query redirect_uri, so a signed-in user's Approve 303 was still CSP-blocked in Chromium - the exact breakage that commit set out to fix, on the flow the developer docs show as canonical. The https-only filter also broke documented http://localhost clients.

  • consentFormActionOrigins resolves the redirect origin from the pushed request (findPushedRequest) whenever request_uri is present, taking precedence over any query redirect_uri to mirror getOAuthAuthorizeView - a crafted link carrying both params can no longer desync the CSP from the form target.
  • http origins are allowed for localhost/127.0.0.1, matching the redirect URI rule enforced at registration.
  • Origins must match a strict scheme://host:port shape before entering the header, so hostname oddities cannot split the form-action directive.
  • DB failure during the lookup degrades to form-action 'self' (pre-fix behavior) rather than failing the request.

Review attention: proxy.ts now imports the oauth repository, so the Node-runtime proxy bundle carries pg and lazily opens its own pool (up to DATABASE_POOL_MAX, default 10) once PAR consent traffic occurs - worth sizing against max_connections with the web and worker pools on the same host. The build was verified with the import in place. A longer-term alternative would retire the widening entirely: a same-origin continuation page after approve.

…t clients

consentFormActionOrigins only read redirect_uri from the query string, so
PAR clients (client_id + request_uri, the flow the developer docs show)
still rendered consent with form-action 'self' and Chromium blocked the
approve 303 - the exact breakage b4684ab set out to fix. Resolve the
redirect origin from the pushed request when only request_uri is present.
Also allow http origins for localhost/127.0.0.1, matching the redirect
URI rule enforced at app registration, so local dev clients can complete
consent.
@matthew-demidoff
matthew-demidoff merged commit 759a78d into master Aug 20, 2026
2 checks passed
@matthew-demidoff
matthew-demidoff deleted the fix/consent-csp-par branch August 20, 2026 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant