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

merging unsafe-inline with nonces/hashes #220

Open
bakkot opened this issue Jun 21, 2019 · 2 comments
Open

merging unsafe-inline with nonces/hashes #220

bakkot opened this issue Jun 21, 2019 · 2 comments

Comments

@bakkot
Copy link
Member

bakkot commented Jun 21, 2019

The unsafe-inline source expression has no effect when a nonce-source or hash-source is specified (edit: or strict-dynamic, in scripts). Also, nonce-source and hash-source are effectively stricter versions of unsafe-inline, not orthogonal to it. Merging needs to take this into account:

  • Unioning script-src 'unsafe-inline' with script-src nonce-asdf should produce script-src 'unsafe-inline', rather than script-src 'unsafe-inline' nonce-asdf (which is effectively script-src nonce-asdf).
  • Intersecting script-src 'unsafe-inline' with script-src nonce-asdf should produce script-src nonce-asdf rather than script-src.
@bakkot
Copy link
Member Author

bakkot commented Jun 21, 2019

Actually it's not clear whether producing script-src nonce-asdf for the intersection is the right call. script-src 'unsafe-inline' nonce-asdf is equivalent on modern browsers and is as restrictive as possible on browsers which do not support nonce sources.

@bakkot
Copy link
Member Author

bakkot commented Jun 24, 2019

Yeah, on further consideration there's no safe way to do union or intersect these two policies. There is no way to express "allows any inline script, and also any script (even if external) with this nonce", nor "allows any inline script with this nonce, but not other inline scripts nor any external scripts".

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