Description
Preconditions and environment
- 2.4.8 vanilla
- Test Data deployed
Steps to reproduce
Deploy 2.4.8 With Test Data
BACKEND
System -> Commerce Services Connector
- Start Setup
- Enter Sandbox Keys
- Enter Production Keys
- Select a Saas Project and a Test Data Scope
- Finish Services Connector Setup
Sales -> Payment Services
- Sandbox Onboarding
- Complete Sandbox Onboarding
Store -> Configuration -> Sales -> Payment Methods
- Payment Services -> General
- Enabled = YES
EITHER
- Configure the checkout to show the minicart during checkout (as that area has inline scripts disabled out of the box)
or - Setup CSP to disable inline scripts everywhere (not just during checkout)
What we are trying to achieve is to have the minicart displayed in an area where inline scripts are disabled.
We can achieve option 2 using the following patch which disables inline scripts for the whole of the frontend.
--- vendor/magento/module-csp/etc/config.orig.xml 2025-04-02 22:58:42.000000000 +0100
+++ vendor/magento/module-csp/etc/config.xml 2025-06-04 19:58:48.337817478 +0100
@@ -82,7 +82,7 @@
<scripts>
<policy_id>script-src</policy_id>
<self>1</self>
- <inline>1</inline>
+ <inline>0</inline>
<eval>1</eval>
<dynamic>0</dynamic>
</scripts>
FRONTEND
Open up developer console
Add item to cart
Expected result
No CSP Violations are reported
Actual result
Additional information
The problem occurs because the Paypal Payment Module file
vendor/magento/module-payment-services-paypal/view/frontend/templates/smart_buttons_minicart.phtml
outputs an inline script amongst the minicart data passed from the section load AJAX call.
/customer/section/load/?sections=cart&force_new_section_timestamp=false
This will fail unless the area in which it is called allows inline scripts. You can see the text of the inline script in the response to that AJAX call. See "extra_actions". "extra_actions" is where the Payment Services Smart button html content is returned, but even if all of the buttons are disabled, the inline script is still output in all cases.
Any page containing the minicart, which has inline scripts turned off for CSP will log this error, or to put it another way, anywhere where you want to display the minicart, you must enable "unsafe_inline".
Release note
No response
Triage and priority
- Severity: S0 - Affects critical data or functionality and leaves users without workaround.
- Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
- Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
- Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
- Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status