Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve parsing of multi-value CSP headers #25

Open
mrl5 opened this issue Jan 7, 2021 · 0 comments
Open

improve parsing of multi-value CSP headers #25

mrl5 opened this issue Jan 7, 2021 · 0 comments

Comments

@mrl5
Copy link

mrl5 commented Jan 7, 2021

Intro

This might be controversial because RFC 2616 states "each separated by a comma":

It MUST be possible to combine the multiple header fields into one "field-name: field-value" pair, without changing the semantics of the message, by appending each subsequent field-value to the first, each separated by a comma.

but I figured that it would be good to create such issue anyway so that you are aware and can decide

Steps to reproduce

lets assume that https://example.com responds with this headers:

Content-Security-Policy: frame-ancestors 'none'
Content-Security-Policy: object-src 'none'
Content-Security-Policy: script-src 'self' 'sha256-ungWv48Bz+pBQUDeXa4iI7ADYaOWF3qctBD/YfIAFa0='

put https://example.com into textarea of https://csp-evaluator.withgoogle.com/

Actual result

in textarea of https://csp-evaluator.withgoogle.com/ they will be parsed as:

Content-Security-Policy: frame-ancestors 'none', object-src 'none', script-src 'self' 'sha256-ungWv48Bz+pBQUDeXa4iI7ADYaOWF3qctBD/YfIAFa0='

(notice , instead of ;). Because of commas object-src + script-src will be marked as missing

Expected result

headers from steps to reproduce are parsed as

Content-Security-Policy: frame-ancestors 'none'; object-src 'none'; script-src 'self' 'sha256-ungWv48Bz+pBQUDeXa4iI7ADYaOWF3qctBD/YfIAFa0='

Additional info

google chrome 87 interprets headers from Steps to reproduce in a way that object-src and script-src are respected

Proposed solution

Multi value headers should be joined by using ; instead of ,

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

No branches or pull requests

1 participant