What Is Content Security Policy (CSP) in Magento, and Why Does It Matter?
A clear guide to CSP in Magento 2.4.7+: what changes on payment pages, how report-only and restrict mode work, and how to deploy CSP without disruptions.
3 min read
Tim Bucciarelli
:
December 13, 2025
Magento's Content Security Policy (CSP) is enforced in restrict mode on payment pages by default since version 2.4.7. Shortly after upgrading to 2.4.7+, merchants started experiencing console errors in checkout such as “Refused to execute inline script…”. Adobe has documented this behavior in Knowledge Article (KA)-25030, which explains how inline JavaScript introduced through Admin configuration or Google Tag Manager (GTM) can be blocked when CSP restricted mode is active.
This guide builds on that article. It focuses on how to identify the source of blocked scripts, choose a fix that preserves CSP enforcement, and test changes without introducing new checkout failures.
Under restricted mode, the checkout CSP header excludes unsafe-inline from script-src, and only explicitly allowed inline scripts can run. Catalog pages often continue to function because they aren’t subject to the same enforcement. Checkout is the first place where violations become visible.
You may see:
Adobe’s KA-25030 ties these issues to inline JavaScript added through Admin and to GTM-related script execution problems.
Use console errors and page source to classify the origin.
Scripts added through Admin areas such as header or footer injection are a frequent cause of failures under restricted mode.
GTM often emits inline JavaScript or bootstrap code. In restricted mode, these snippets are blocked unless CSP requirements are met. Adobe also documents a specific issue where GTM custom scripts fail to execute because of CSP; see ACSD-60788.
Support widgets, tracking snippets, and review integrations can introduce inline JavaScript or unapproved third-party domains.
Legacy checkout customizations and third-party modules may output inline JavaScript that previously worked but no longer meets CSP rules.
The goal is not to relax CSP until checkout works. The goal is to keep checkout predictable, auditable, and compliant.
If the inline code is yours or a vendor snippet that can be modularized, relocate it into a JavaScript file loaded through Magento’s frontend pipeline.
When a module outputs a deterministic inline block, adding its hash to the allowlist is often the cleanest strict-mode solution.
If an external script is being blocked, you can allowlist its domain, but confirm the script belongs on checkout and review directives such as:
connect-src for beacons or service callsframe-src for hosted fields or iframesimg-src for tracking pixelsNonce-based approaches can help with certain inline patterns but add operational complexity. If you are troubleshooting GTM issues under CSP, Adobe’s patch ACSD-60788 addresses a case where GTM Custom HTML scripts do not execute because of CSP restrictions.
For more information about where you would use each of these options, refer to our Safe Scripting for Magento blog post.
Checkout is tightly coupled - a CSP change may appear to solve one issue but create another.
With any CSP change, be sure to test:
Payment-page CSP is designed to exclude unsafe-inline. Reinstating it weakens controls and reintroduces the risks CSP is meant to reduce.
This leads to policy sprawl and obscures which scripts actually belong on checkout.
Even when technically possible, it creates brittle behavior and makes script governance difficult.
connect-srcframe-src
A clear guide to CSP in Magento 2.4.7+: what changes on payment pages, how report-only and restrict mode work, and how to deploy CSP without disruptions.
Strengthen PCI DSS 4.0 compliance on Magento by controlling checkout scripts with clear governance, CSP enforcement, and structured monitoring.
A practical guide to PCI DSS 4.0 payment-page scripts on Magento: assess what runs today, manage GTM vs modules, and harden checkout with CSP.