Review main Ready for review Orphaned

94054[BUGFIX] Add nonce to JavaScript modules

Matthias Vogel CR +1 V +1 Easy +1 −0 updated 05/13/26, 10:23

Commit message

Currently, using JavaScript modules via the
`AssetCollector->addJavaScriptModule` does not add nonces.
This usually works because the default Content Security Policy (CSP)
settings set the `"self"` source list keyword.

However, if the website wants the CSP to be stricter
and only allow nonces then none of the JavaScript modules will load.

This patch adds nonces to the JavaScript modules.

Test this change

Run a command in your clone of the TYPO3 Core. Then try what the change does and vote on Verified in Gerrit. How to review a patch

Check out patch set 2
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/54/94054/2 && git checkout FETCH_HEAD
Cherry-pick onto main
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/54/94054/2 && git cherry-pick FETCH_HEAD

Review

  • Code review CR +1 Needs a vote
    • Albrecht Köhnlein +1
  • Verified V +1 Needs a vote
    • Albrecht Köhnlein +1
    • core-ci +1 CI

Merge conflicts 3

Issues 1

Files 1

Review log 68

  1. Matthias Vogel uploaded patch set 1 05/11/26, 12:22

  2. Matthias Vogel updated the commit message in patch set 2 05/11/26, 12:28

  3. Matthias Vogel marked it ready for review 05/11/26, 12:34

  4. core-ci voted on patch set 1 V +1 05/11/26, 12:34 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/101819

  5. core-ci voted on patch set 2 V +1 05/11/26, 13:08 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/101823

  6. Albrecht Köhnlein commented on patch set 2 CR +1 V +1 05/13/26, 08:53

  7. Benjamin Franzke commented on patch set 2 05/13/26, 09:59

    Unresolved

    Hm, I'm not sure with this change, since it kinda contradicts what @oliver.hader@typo3.org tried to achieve with: > 93419: [FEATURE] Prefer CSP hash values over nonce values | https://review.typo3.org/c/Packages/TYPO3.CMS/+/93419 (v14 only) The problem with nonces is that they disable caching. Doing that without explicit integrator enablements is not very nice for sites that rely on static cachability. Also see BUGFIXes like: > 84435: [BUGFIX] Do not render nonceProxy if nonce has not been consumed | https://review.typo3.org/c/Packages/TYPO3.CMS/+/84435 Ideally we'd a) generate hashes instead of nonces b) detect if a CSP config is active that requires nonces to be rendered (that also affects other modules like AssetRenderer) All in all this feels like too much for backporting to v13.4, since that version is in priority BUGFIX mode.
    I guess you refer to `strict-dynamic` which invalidates `self` or do you actually disable `self` on purpose?
  8. Albrecht Köhnlein commented on patch set 2 05/13/26, 10:23

    Reply Unresolved

    Correct. The original problem was that EXT:visual_editor does not work properly in combination with `strict-dynamic`. I reported that in GitHub https://github.com/FriendsOfTYPO3/visual_editor/issues/78