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
Both should be true depending on how you use intercom-rails:
If doing manual insertion with intercom_script_tag: The intercom_script_tag.csp_sha256 should match the hash of the script injected into the HTML
If doing automatic insertion: The sha256 in the hook described in the CSP section of the readmedef self.csp_sha256_hook(controller, sha256) should match the hash of the script injected into the HTML
Actual behavior
The browser reports
Refused to execute inline script because it violates the following Content Security Policy directive: [...] Either the 'unsafe-inline' keyword, a hash ('sha256-0wDuHgTA8dC7F+INUiUehCTAmoC3UVFkJl6ECD9w+iY='), or a nonce ('nonce-...') is required to enable inline execution.
There are CDATA tags surrounding the script resulting in the hash generated by intercom-rails not matching the browser's hash of the script:
I verified that if I take a manual sha256 hash with the CDATA tags included it does match the hash reported by the browser.
Steps to reproduce
Configure standard intercom-rails integration
Enable rails CSP and set config.content_security_policy_report_only = false
Load the app and notice the browser reports it cannot execute the intercom script
Logs
Refused to execute inline script because it violates the following Content Security Policy directive: [...] Either the 'unsafe-inline' keyword, a hash ('sha256-0wDuHgTA8dC7F+INUiUehCTAmoC3UVFkJl6ECD9w+iY='), or a nonce ('nonce-...') is required to enable inline execution.
The text was updated successfully, but these errors were encountered:
baueric
changed the title
CDATA in intercom_script_tag results in the csp_sha256 not matching and a failing CSP
CDATA in intercom_script_tag results in the csp_sha256 mismatch and a failing CSP
Jun 28, 2023
Version info
Expected behavior
Both should be true depending on how you use
intercom-rails
:intercom_script_tag
: Theintercom_script_tag.csp_sha256
should match the hash of the script injected into the HTMLsha256
in the hook described in the CSP section of the readmedef self.csp_sha256_hook(controller, sha256)
should match the hash of the script injected into the HTMLActual behavior
The browser reports
There are
CDATA
tags surrounding the script resulting in the hash generated byintercom-rails
not matching the browser's hash of the script:I verified that if I take a manual sha256 hash with the CDATA tags included it does match the hash reported by the browser.
Steps to reproduce
intercom-rails
integrationconfig.content_security_policy_report_only = false
Logs
The text was updated successfully, but these errors were encountered: