Skip to content

fix: add form-action and frame-ancestors to CSP header in redirects#242

Open
Sumit-Mayani wants to merge 1 commit intoexpressjs:masterfrom
Sumit-Mayani:fix/csp-missing-directives
Open

fix: add form-action and frame-ancestors to CSP header in redirects#242
Sumit-Mayani wants to merge 1 commit intoexpressjs:masterfrom
Sumit-Mayani:fix/csp-missing-directives

Conversation

@Sumit-Mayani
Copy link
Copy Markdown

Fixes #187

Problem

The redirect response sets Content-Security-Policy: default-src 'none', but per the CSP spec, form-action and frame-ancestors directives do not inherit from default-src. Omitting them is equivalent to allowing anything for those vectors.

Fix

Add the two missing directives explicitly:

Content-Security-Policy: default-src 'none'; form-action 'none'; frame-ancestors 'none'

Testing

Updated the existing CSP test to assert the full header value. All 92 tests pass.

default-src does not cover form-action or frame-ancestors directives per
CSP spec, so omitting them allows unrestricted behavior for those vectors.
Closes expressjs#187

Assisted-by AI: Claude (Anthropic)
@Sumit-Mayani Sumit-Mayani force-pushed the fix/csp-missing-directives branch from 2f5570f to 767d7ba Compare April 22, 2026 10:25
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.

too wide CSP header in redirect response

1 participant