Issue Bug Closed

#108422NonceViewHelper wrong aspect

Marek Skopal 12/08/25, 00:51 updated 03/31/26, 09:01

Description

After changes from https://forge.typo3.org/issues/107062 NonceViewHelper does not work properly in cached pages.

There is nonce consume call in NonceViewHelper class

$this->requestId->nonce->consumeInline(self::class);

but self::class is not CSP aspect from TYPO3\CMS\Core\Security\ContentSecurityPolicy\Direcive class. For that reason familyConsumedInlineNonce method in AvoidContentSecurityPolicyNonceEventListener always return false even if NonceViewHelper is used in your templates and nonce is required and nonce is always removed from cached pages.

Reviews 2

History 710

  1. Oliver Hader commented <span data-processor="relativetime" data-value="2025-12-17T08:29:53+00:00" > 12/17/25, 08:29 </span>

    The drawback of using <script nonce="{f:security.nonce()}">const inline = 'script';</script> is that the nonce view-helper does not know for which scope/directive it actually has been used.

    I only see two possibilities to change that:

    • skip nonce optimization of issue #107062 when f:security.nonce has been used
    • introduce an additional directive hint like {f:security.nonce(directive:'script-src')}
  2. Gerrit Code Review pushed patch set 1 for main to change 92138 status Accepted Under Review <span data-processor="relativetime" data-value="2025-12-17T10:26:29+00:00" > 12/17/25, 10:26 </span>

  3. Oliver Hader commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2025-12-19T07:50:09+00:00" > 12/19/25, 07:50 </span>

    Applied in changeset commit:b5bdc079539aaffd69cc530d93d66c72bf2ed288.