You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using GoodJob to process jobs on Rails 6. The GoodJob dashboard includes a number of scripts and styles. These all have nonces set using the content_security_policy_nonce method.
I would expect Secure Headers to set the nonce in the CSP header so that these scripts are permitted.
Actual outcome
No nonce is set in the CSP header. I think that Rails' own content_security_policy_nonce method is being called rather than the Secure Headers method of the same name. This means that the CSP set by Secure Headers doesn't include the nonce, and the scripts and styles are therefore not permitted.
I know that recommend practice when using Secure Headers is to use the nonced_javascript_tag method, but since this is in a gem I can't do that.
The core problem seems to be that the nonced_javascript_tag is not setting the correct nonce value inside the CSP header, as the browser doesn't have the value. Checking the source code however does reveal that the generated <script> tag contains the nonce value.
I'd like to add that this issue was a Firefox problem for me, and actually caused by caching.
Wiping out the cache in Firefox and forcing a hard reload made it all work.
Expected outcome
I am using GoodJob to process jobs on Rails 6. The GoodJob dashboard includes a number of scripts and styles. These all have nonces set using the
content_security_policy_nonce
method.(link to code)
I would expect Secure Headers to set the nonce in the CSP header so that these scripts are permitted.
Actual outcome
No nonce is set in the CSP header. I think that Rails' own
content_security_policy_nonce
method is being called rather than the Secure Headers method of the same name. This means that the CSP set by Secure Headers doesn't include the nonce, and the scripts and styles are therefore not permitted.I know that recommend practice when using Secure Headers is to use the
nonced_javascript_tag
method, but since this is in a gem I can't do that.Possible related issues:
content_security_policy_nonce
with Rails 5.2 #392Config
Generated headers
The text was updated successfully, but these errors were encountered: