Overview
Advanced CSP & Security Headers lets Magento administrators manage the store’s Content Security Policy (CSP) and key HTTP security headers from the Admin. Instead of editing CSP files and deploying code for every change, you add, edit and remove allowed sources in a grid, test the policy in Report-Only mode, then enforce it.
The user guide (PDF) on the Adobe Commerce Marketplace listing has screenshots of every screen for your version. Use it together with this guide.
Before you start
| Requirement | Supported | Notes |
|---|---|---|
| Magento Open Source | 2.4 | |
| Adobe Commerce (on-prem) | 2.4 | |
| Adobe Commerce (cloud) | 2.4 | |
| Varnish | Yes | Passed the Marketplace installation and Varnish tests |
| Multi-store setups | Not yet verified |
For installation you need shell (SSH) access to the server and Composer, as for any Marketplace extension. Prefer not to install it yourself? The Marketplace listing offers an optional installation service at checkout.
Get the extension
- Open the extension’s Adobe Commerce Marketplace listing.
- Choose your edition (Adobe Commerce cloud, Adobe Commerce on-prem or Magento Open Source) and your store version.
- Add optional support or the installation service if you want them, then complete checkout.
Install with Composer
Install on a staging copy of your store first, and take a backup of the code and database before installing on production.
- Make sure your Marketplace access keys are in your project’s
auth.json(Marketplace → My Profile → Access Keys). - Put the store in maintenance mode.
- Require the package with Composer, using the package name shown with your purchase in your Marketplace account.
- Run the Magento setup commands below, then turn maintenance mode off.
bin/magento maintenance:enable
composer require <package-name-from-your-purchase>
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento setup:static-content:deploy -f
bin/magento cache:flush
bin/magento maintenance:disable
On Adobe Commerce cloud, run composer require locally, commit composer.json and composer.lock, and push. The cloud deployment runs the setup steps for you.
Roll out a policy safely
A strict policy can block scripts your store needs, such as a payment form. Follow these steps so nothing breaks:
- Add allow-list entries. In the Manage Policy grid, add Host and Hash entries for the trusted sources your store uses.
- Start in Report-Only. Keep the storefront, Admin and checkout in Report-Only mode, so nothing is blocked while you test.
- Review violations. Browse the storefront, Admin and checkout with your browser’s developer console open, and note any CSP violation messages.
- Fix and repeat. Add the missing hosts, hashes or directives until no violations remain.
- Switch to Restrictive one area at a time, and test each area after switching.
Manage the allow-list
CSP entries are managed in the Manage Policy grid in the Magento Admin. Each entry belongs to a directive, chosen from the Policy dropdown. The grid supports inline editing and mass delete.
| Entry type | Use it to | Example |
|---|---|---|
| Host | Allow a trusted domain for one directive | https://cdn.example.com for script-src |
| Hash | Allow one specific inline script or style by its hash | A sha256-… value for an inline script |
Entries plug into Magento’s native CSP system, so there is no whitelist.xml file to maintain. When you save or delete an entry, the Full Page Cache and Config cache are invalidated automatically.
Directives
Six directives are included by default. You can add others to the directive list, and they then appear in the Policy dropdown.
| Directive | Controls |
|---|---|
script-src | JavaScript files and inline scripts |
style-src | Stylesheets and inline styles |
connect-src | Connections made by scripts (fetch, XHR, WebSocket) |
img-src | Images |
font-src | Web fonts |
media-src | Audio and video |
Third-party services
Payment gateways, analytics, CDNs, marketing tools and support widgets each need their domains allowed. Check each provider’s documentation for the domains and directives they need, add them as Host entries, and confirm in Report-Only mode before enforcing.
Report-Only and Restrictive modes
Each area has its own toggle, so you can enforce the storefront while the checkout is still being tested:
| Area | Report-Only | Restrictive |
|---|---|---|
| Storefront | Logs violations, blocks nothing | Enforces the policy |
| Admin | Logs violations, blocks nothing | Enforces the policy |
| Checkout inline scripts | Logs violations, blocks nothing | Enforces the policy |
| Checkout inline event handlers (onclick, onchange…) | Logs violations, blocks nothing | Enforces the policy |
Security headers
| Header | What it does |
|---|---|
| Permissions-Policy | Limits which browser features (camera, microphone, geolocation…) the site and embedded content may use. |
| Referrer-Policy | Controls how much of the page URL is sent to other sites when visitors follow a link. |
| HSTS | Tells browsers to use HTTPS only. The extension links to Magento’s native HSTS setting. |
Before enabling HSTS, make sure your whole store works over HTTPS. Browsers remember the setting, so turning it off later does not take effect for returning visitors right away.
Troubleshooting
Something stopped working after switching to Restrictive
- Switch that area back to Report-Only.
- Open the browser console on the broken page and find the CSP message. It names the blocked URL and the directive.
- Add a Host entry for that domain (or a Hash entry for an inline script) under the named directive.
- Test in Report-Only, then switch back to Restrictive.
The payment form at checkout does not load
Payment providers usually load scripts, frames and connections from their own domains. Add their domains to the directives named in the console messages, and check the two checkout toggles. If a directive you need is not in the list (for example frame-src), add it to the directive list first.
My change does not show yet
Magento’s caches are invalidated automatically. If you also use a CDN or an external Varnish, purge it too.
Frequently asked questions
Does this replace editing CSP files by hand?
For routine updates, yes. Entries are managed in the Admin and feed Magento’s native CSP pipeline, so there is no whitelist.xml to maintain.
What is the difference between Host and Hash entries?
A Host entry allows a trusted domain for a directive. A Hash entry allows one specific inline script or style by its hash.
Do I need to clear the cache after a change?
Yes. The Full Page Cache and Config cache are invalidated automatically when an entry is saved or deleted.
Will it change how my storefront looks?
No. It adds no customer-facing pages or components. It only affects which resources the browser may load.
Does it make my store secure or compliant on its own?
No single tool does. CSP and security headers are one layer of browser-side hardening; use them as part of your wider security practice.
Support and license
Email [email protected], use Contact Vendor on the Marketplace listing, or open a ticket. The extension is licensed under the Open Software License 3.0 (OSL-3.0).