Review 12.4 Merged

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

Benjamin Franzke CR +2 V +2 Normal +44 −17 updated 07/28/23, 20:18

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 Done
    • Benjamin Franzke +2
    • Oliver Hader +1
  • Verified V +2 Done
    • Benjamin Franzke +2
    • core-ci +1 CI

Issues 1

Files 3

Review log 34

  1. Benjamin Franzke uploaded patch set 1 07/28/23, 20:03

  2. core-ci voted on patch set 1 V +1 07/28/23, 20:11 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/44702

  3. Oliver Hader voted on patch set 1 CR +1 07/28/23, 20:12

  4. Oliver Hader merged patch set 2 07/28/23, 20:18