Active
Project:
Piwik PRO
Version:
1.4.3
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
2 Mar 2026 at 07:54 UTC
Updated:
24 Apr 2026 at 14:35 UTC
Jump to comment: Most recent
See issue: https://www.drupal.org/project/piwik_pro/issues/3574747
A nonce should be different on every page request.
- Enable CSP nonce support in Piwik PRO module settings and inspect the source of some pages in your site.
- The nonce value within the code snippet stays the same on every page request for anonymous user.
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
hartsak commentedHey @dripa!
Thanks for the ticket!
Is the issue still happening even after the nonce builder is being added in https://www.drupal.org/project/piwik_pro/issues/3574747 ?
If it still occurs, I was thinking, would using the library mode be a better option?
Comment #3
dripa commentedHi @hartsak,
I have set this in the module config:
Load Piwik PRO snippet from a library
Enable CSP nonce support
The nonce is now added in this section
<script type="application/json" data-drupal-selector="drupal-settings-json">and replaced in the library js file. But its still the same nonce per request for anonymous users, which is not allowed as stated in: https://content-security-policy.com/nonce/Comment #4
hartsak commentedThanks for the answer @dripa!
I thought I followed the guide from here https://www.drupal.org/project/csp/issues/3447249 and the other links on the page, which suggest using the 2.x branch of the CSP module and the nonce builder service with placeholder.
The original code changes in https://www.drupal.org/project/piwik_pro/issues/3574747 were using the 1.x branch.
Do you have a suggestion how to properly keep the nonce value changing between requests made by anonymous users other than disabling caches entirely?
We might need to take another look at this!
Comment #5
dripa commented@hartsak We have success with this change in the nonce_generator module: https://git.drupalcode.org/project/nonce_generator/-/merge_requests/1/diffs
It adds a placeholder nonce which is being replaced by middleware so the nonce is unique per page request and the page is still cached.
We could implement that logic or use that module to generate the nonce.