#107636Flaws with importmap in PageRenderer:setApplyNonceHint() in the frontend context
Description
In the frontend context, the lit-nonce is added using $pageRenderer->setApplyNonceHint(true);
In TYPO3 v13 and since issue #101297 was merged, the frontend output contains the full importmap (which is not applied when having CSP activated and not allowing unsafe-inline, since the nonce value for the import map was explicitly omitted in the frontend context in PageRenderer::renderMainJavaScriptLibraries).
$pageRenderer->setApplyNonceHint(true); for the frontend context the following happens:
- in
TYPO3\CMS\Core\Page\JavaScriptRenderer::renderImportMaptheinstructionsWithItemshold thelitNonceassignment - this requires
typo3/core/java-script-item-handler.jsto be loaded - this resolves and adds the imports for
typo3/core/*packages
However, all this does not seem to be necessary, since in the frontend PageRenderer still uses Object.assign for assigning litNonce.
<script type="importmap">{"imports":{"@typo3/core/":"/_assets/1ee1d3e909b58d32e30dcea666dd3224/JavaScript/",
"autosize":"/_assets/1ee1d3e909b58d32e30dcea666dd3224/JavaScript/Contrib/autosize.js?bust=1760004735", ...</script>
<script nonce="oyplKMHWtccMJ-ut1hYjggWM0Hcu_m-c3mt1n30NBl7P-e3quHiPBQ">
Object.assign(globalThis, {"litNonce":"oyplKMHWtccMJ-ut1hYjggWM0Hcu_m-c3mt1n30NBl7P-e3quHiPBQ"})</script>
<script src="/_assets/af46f1853e4e259cbb8ebcb816eb0403/JavaScript/elements.js?1759920968" type="module" async="1" nonce="oyplKMHWtccMJ-ut1hYjggWM0Hcu_m-c3mt1n30NBl7P-e3quHiPBQ"></script>
<script src="/_assets/af46f1853e4e259cbb8ebcb816eb0403/JavaScript/globals.js?1759920968" type="module" async="1" nonce="oyplKMHWtccMJ-ut1hYjggWM0Hcu_m-c3mt1n30NBl7P-e3quHiPBQ"></script>Reviews 2
Related issues 1
History 35
-
Oliver Hader changed Related to #101297 <span data-processor="relativetime" data-value="2025-10-09T10:24:24+00:00" > 10/09/25, 10:24 </span>
-
Oliver Hader changed subject
Flaws with PageRenderer:setApplyNonceHint() in the frontend contextFlaws with importmap in PageRenderer:setApplyNonceHint() in the frontend context <span data-processor="relativetime" data-value="2025-10-13T07:20:04+00:00" > 10/13/25, 07:20 </span> -
Gerrit Code Review pushed patch set 1 for main to change 96721 status
NewUnder Review <span data-processor="relativetime" data-value="2026-10-15T13:54:55+00:00" > 10/15/26, 13:54 </span> -
Gerrit Code Review pushed patch set 1 for 14.3 to change 97548 <span data-processor="relativetime" data-value="2026-11-11T15:12:53+00:00" > 11/11/26, 15:12 </span>
-
Benni Mack commented and changed status
Under ReviewResolved done0 %100 % <span data-processor="relativetime" data-value="2026-11-11T15:20:13+00:00" > 11/11/26, 15:20 </span>
Applied in changeset commit:811d4cca0da4297a96f7730d95b977bad3106c8d.