Skip to content

fix(consent): allow IdP origin in CSP form-action for Chromium#33

Merged
babs merged 1 commit into
masterfrom
fix/csp-form-action-redirect
May 26, 2026
Merged

fix(consent): allow IdP origin in CSP form-action for Chromium#33
babs merged 1 commit into
masterfrom
fix/csp-form-action-redirect

Conversation

@babs

@babs babs commented May 26, 2026

Copy link
Copy Markdown
Owner

The consent page CSP set form-action 'self', which Chromium enforces against every URL in the redirect chain initiated by a form submit (CSP3 §6.5). The approve POST 302s to the upstream IdP, so Chrome / Edge / Brave / Opera blocked the navigation client-side and /callback never fired. Firefox and Safari work because they check only the immediate action= URL.

Derive the upstream authorize endpoint's origin once at handler construction from oauth2Cfg.Endpoint.AuthURL (already populated by OIDC discovery — no new config required for the common case), lower- case it per CSP3 §6.7.2.5, and append to the form-action source list. Skip the precompute + warn when RenderConsentPage=false.

Add CSP_FORM_ACTION_EXTRA for IdP topologies whose redirect chain crosses the authorize host (Entra B2C, federated AD FS, personal Microsoft accounts, sovereign clouds). Entries are validated against the CSP3 §2.4 host-source ABNF — stricter than RFC 3986 reg-name so sub-delims (;, ,, &, _) that would break out of the directive when emitted are rejected at startup.

The consent page CSP set `form-action 'self'`, which Chromium enforces
against every URL in the redirect chain initiated by a form submit
(CSP3 §6.5). The approve POST 302s to the upstream IdP, so Chrome /
Edge / Brave / Opera blocked the navigation client-side and /callback
never fired. Firefox and Safari work because they check only the
immediate action= URL.

Derive the upstream authorize endpoint's origin once at handler
construction from oauth2Cfg.Endpoint.AuthURL (already populated by
OIDC discovery — no new config required for the common case), lower-
case it per CSP3 §6.7.2.5, and append to the form-action source list.
Skip the precompute + warn when RenderConsentPage=false.

Add CSP_FORM_ACTION_EXTRA for IdP topologies whose redirect chain
crosses the authorize host (Entra B2C, federated AD FS, personal
Microsoft accounts, sovereign clouds). Entries are validated against
the CSP3 §2.4 host-source ABNF — stricter than RFC 3986 reg-name so
sub-delims (`;`, `,`, `&`, `_`) that would break out of the directive
when emitted are rejected at startup.
@babs babs merged commit 1ffd796 into master May 26, 2026
7 checks passed
@babs babs deleted the fix/csp-form-action-redirect branch May 26, 2026 01:59
babs added a commit that referenced this pull request Jun 4, 2026
Chromium enforces the consent page's form-action directive against
every hop of the redirect chain a form submit initiates. Client-side
hops after redirect_uri (e.g. Power Platform's
global.consent.azure-apim.net -> regional UI origin) are unknowable
in advance, so origin enumeration (#33 IdP extras, #35 redirect_uri)
could never be complete.

- answer POST /consent (approve/deny/server-error) with a 200
  same-origin interstitial (meta refresh, no JS) instead of a 302;
  form navigation ends at the proxy, downstream hops are a regular
  navigation that form-action does not govern
- tighten consent page CSP to form-action 'self'; drop
  buildConsentCSPSources/formatConsentCSP and per-render widening
- deprecate CSP_FORM_ACTION_EXTRA (parsed, ignored, startup warn)
- re-render consent page with fresh JTI on replayed submit instead
  of a dead-end 400 consent_replay; decision still requires a new
  explicit click, single-use guarantee unchanged
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