Issue Task Closed

#100887Allow remote proxies to handle CSP nonce values

Oliver Hader 05/16/23, 14:06 updated 03/31/26, 09:00

Description

→ find examples at https://scotthelme.co.uk/csp-nonces-the-easy-way-with-cloudflare-workers/

Find a way that e.g. uses a static nonce value, e.g. <script src="..." nonce="[[nonce-placeholder]]"> which will be substituted by a remote proxy server (nginx, CloudFlare, …). In addition, that proxy server would have to take care of adjusting the CSP HTTP headers as well.

Reviews 7

History 1574

Show 849 earlier messages
  1. Torben Hansen commented <span data-processor="relativetime" data-value="2023-05-17T10:00:22+00:00" > 05/17/23, 10:00 </span>

    Benjamin Franzke found this https://serverfault.com/a/1064775 discussion. So in conclusion, a cached nonce may not be a general problem for the CSP

  2. Oliver Hader commented <span data-processor="relativetime" data-value="2023-05-17T10:10:00+00:00" > 05/17/23, 10:10 </span>

    Torben Hansen wrote in #note-4:
    > Benjamin Franzke found this https://serverfault.com/a/1064775 discussion. So in conclusion, a cached nonce may not be a general problem for the CSP

    As long as the nonce changes when the content is changed, this is okay.

    However for TYPO3 USER_INT or COA_INT it is unknown, which content has been served previously. I think having a few examples and documentation for dynamic workers on CloudFlare or Varnish would be a good thing.

  3. Oliver Hader commented <span data-processor="relativetime" data-value="2024-09-17T08:06:07+00:00" > 09/17/24, 08:06 </span>

    The current f:asset.script view-helper has a bunch of attributes which have specific meaning and might create new ambiguity:

    • prior to https://review.typo3.org/c/Packages/TYPO3.CMS/+/85310 where registered as tag attributes and are now handled as “additionalArguments” in Fluid
      • integrity: actually used for sub-resource-integrity (independent of content-security-policy) → however, consider to use this existing value for CSP (instead of calculating it automatically, which is actually good for remote sources)
      • nonce: actually using a given nonce for (independent of content-security-policy) → however, consider to us the existing value for CSP (instead of using the global request nonce)
    • the following attributes can be used to control the global behavior
      • useNonce: explicitly requesting to assign the global nonce (the nonce attribute might(!) take precedence)
      • csp (or any other name that fits better): automatically apply hashes or nonces if applicable → however the meaning would conflict with an explicit useNonce attribute

    Some examples what might actually happen:

    • <f:asset.script identifier="script" src="https://external.example.org/app.js" integrity="hash-abc" nonce="nonce-xyz" useNonce="1" csp="1" />
      • integrity is given and should be used for CSP unsafe-hashes, since csp="1" is given
      • nonce and useNonce should be dropped, since integrity is more specific (in case integrity has an outdated hash, the script would be blocked, since it was changed remotely – but security-wise it’s actually the desired behavior)
    • <f:asset.script identifier="script" integrity="hash-abc" nonce="nonce-xyz" useNonce="1" csp="1">console.log(1);</f:asset.script>
      • integrity might be ignored, since it does not have any impact on inline scripts in the current specs
      • the given nonce attribute should take precedence over useNonce
      • however, having the csp attribute set, should(!) adjust CSP rules – that’s ambiguous
  1. Oliver Hader commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2026-03-30T16:35:09+00:00" > 03/30/26, 16:35 </span>

    Applied in changeset commit:02e0c415bc735036fb271eea9a64d50c29b592ad.