Issue Bug Closed

#108897Nonce not added to configured directive

Torben Hansen 02/07/26, 14:27 updated 02/09/26, 18:06

Description

Using the directive argument in the f:security.nonce ViewHelper does not add the nonce to the configured directive.

Example from docs:

<style nonce="{f:security.nonce(directive: 'style-src')}">
    body {
        background-color: #f5f5f5;
    }
</style>

The nonce is generated for the nonce attribute of the style tag, but the generated nonce is added shown in the script-src CSP directive instead of the style-src.

Example outout:

    <style nonce="ehDpyDdsdUsHToBGBljOzQj1_IXu48U6qchvjWURF0xC911GfTpHBg">
        body {
            background-color: #f5f5f5;
        }
    </style>

Example CSP header for code above:

Content-Security-Policy default-src 'self'; script-src 'self' 'nonce-ehDpyDdsdUsHToBGBljOzQj1_IXu48U6qchvjWURF0xC911GfTpHBg' 'report-sample'; style-src-attr 'unsafe-inline' 'report-sample'; img-src 'self' data: *.ytimg.com *.vimeocdn.com; base-uri 'self'; frame-src 'self' *.youtube-nocookie.com *.youtube.com *.vimeo.com; report-uri https://typo3.local/@http-reporting?csp=report&requestTime=1770474372594502&requestHash=40149c1e6eee82179c50f08494b8c7c2a51f2e18

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.