fix(consent): allow IdP origin in CSP form-action for Chromium#33
Merged
Conversation
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.
This was referenced May 28, 2026
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
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.
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.