Review main Merged

80185[BUGFIX] Allow strict-dynamic only for applicable CSP directives

Oliver Hader CR +2 V +2 Normal +44 −17 updated 07/28/23, 19:56

Commit message

Using 'strict-dynamic' (SourceKeyword::strictDynamic) should only
be allowed for script-src*[1] directives. Using it for any other
directive produces strange side effects, since it implicitly adds
a CSP nonce value to that directive when compiling the policy.

Thus, this change
+ ensures 'strict-dynamic' is applicable for script-src* when
  using Policy::set, Policy::extend or the constructor
+ removes invalid policy purges when 'strict-dynamic' was used,
  since that was only valid for CSP level 3 - ignoring these
  directives is supposed to be handled by the browser[2], not by
  the server-side API, in order to preserve CSP v1/v2 BC.

[1] https://w3c.github.io/webappsec-csp/#allow-all-inline
> 'strict-dynamic' only applies to scripts, not other resource types.

[2] https://w3c.github.io/webappsec-csp/#strict-dynamic-usage
> 8.2. Usage of "'strict-dynamic'"
> If present in a script-src or default-src directive, it has two
> main effects:
> * host-source and scheme-source expressions, as well as the
>   "'unsafe-inline'" and "'self' keyword-sources will be ignored
>   when loading script.

Review

  • Code review CR +2

    Imported before Forger kept the single votes, the next import adds them.

  • Verified V +2

    Imported before Forger kept the single votes, the next import adds them.

Issues 1

Files 3