Advanced CSP & Security Headers

Guide for

Advanced CSP & Security Headers

  • Magento
  • $49.00
  • 5 min read
  • Updated Nov 30, 2026

Manage your store's Content Security Policy and key HTTP security headers from one Magento Admin screen — no configuration files to edit and no code deployment for routine policy updates.

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

RequirementSupportedNotes
Magento Open Source2.4
Adobe Commerce (on-prem)2.4
Adobe Commerce (cloud)2.4
VarnishYesPassed the Marketplace installation and Varnish tests
Multi-store setupsNot 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

  1. Open the extension’s Adobe Commerce Marketplace listing.
  2. Choose your edition (Adobe Commerce cloud, Adobe Commerce on-prem or Magento Open Source) and your store version.
  3. 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.

  1. Make sure your Marketplace access keys are in your project’s auth.json (Marketplace → My Profile → Access Keys).
  2. Put the store in maintenance mode.
  3. Require the package with Composer, using the package name shown with your purchase in your Marketplace account.
  4. 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:

  1. Add allow-list entries. In the Manage Policy grid, add Host and Hash entries for the trusted sources your store uses.
  2. Start in Report-Only. Keep the storefront, Admin and checkout in Report-Only mode, so nothing is blocked while you test.
  3. Review violations. Browse the storefront, Admin and checkout with your browser’s developer console open, and note any CSP violation messages.
  4. Fix and repeat. Add the missing hosts, hashes or directives until no violations remain.
  5. 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 typeUse it toExample
HostAllow a trusted domain for one directivehttps://cdn.example.com for script-src
HashAllow one specific inline script or style by its hashA 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.

DirectiveControls
script-srcJavaScript files and inline scripts
style-srcStylesheets and inline styles
connect-srcConnections made by scripts (fetch, XHR, WebSocket)
img-srcImages
font-srcWeb fonts
media-srcAudio 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:

AreaReport-OnlyRestrictive
StorefrontLogs violations, blocks nothingEnforces the policy
AdminLogs violations, blocks nothingEnforces the policy
Checkout inline scriptsLogs violations, blocks nothingEnforces the policy
Checkout inline event handlers (onclick, onchange…)Logs violations, blocks nothingEnforces the policy

Security headers

HeaderWhat it does
Permissions-PolicyLimits which browser features (camera, microphone, geolocation…) the site and embedded content may use.
Referrer-PolicyControls how much of the page URL is sent to other sites when visitors follow a link.
HSTSTells 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

  1. Switch that area back to Report-Only.
  2. Open the browser console on the broken page and find the CSP message. It names the blocked URL and the directive.
  3. Add a Host entry for that domain (or a Hash entry for an inline script) under the named directive.
  4. 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).