Missing content security policy
Moderate effortAdd a Content-Security-Policy (CSP) HTTP response header to every page to block unauthorized scripts, styles, and resources from loading in your visitors' browsers.
What it is
A Content Security Policy (CSP) is an instruction you send to your visitors' web browsers, embedded in a special HTTP header, that tells the browser exactly which sources of scripts, images, styles, fonts, and other content it is allowed to load on your site. Think of it as a strict guest list at a nightclub door: anything not on the list gets turned away. Without a CSP header, the browser will happily load resources from anywhere — including malicious scripts injected by attackers. Your site currently sends no CSP header at all, which means that protection layer is completely absent.
Why it matters
Without a CSP, your store is significantly more vulnerable to Cross-Site Scripting (XSS) attacks — one of the most common ways attackers steal customer data, hijack sessions, or install payment-skimming code (like Magecart) directly in your shoppers' browsers. A successful XSS attack can expose customers' credit card numbers, passwords, and personal information, leading to chargebacks, fines under GDPR/CCPA, PCI-DSS violations, and severe reputational damage. Google also considers site security as a ranking signal, so a visibly compromised site can lose organic search rankings fast. Adding a CSP is recognized by OWASP as a critical defense-in-depth control against injection attacks (A03:2021).
How to fix it
- Audit your site to inventory every external domain your pages legitimately load resources from (scripts, styles, fonts, images, frames, analytics, payment widgets, CDNs, etc.) — browser DevTools Network tab is ideal for this.
- Start in report-only mode: deploy the header as Content-Security-Policy-Report-Only with a permissive policy plus a report-uri endpoint so you can see violations without breaking anything for real users.
- Review violation reports, identify any legitimate sources that were blocked, and add them to your allowlist directives (e.g., script-src, style-src, img-src, font-src, connect-src, frame-src).
- Harden the policy: at minimum set default-src 'self'; script-src 'self' [your-trusted-cdn]; object-src 'none'; base-uri 'self'; — avoid 'unsafe-inline' and 'unsafe-eval' in script-src whenever possible by moving inline scripts to external files or using nonces/hashes.
- Switch the header from Content-Security-Policy-Report-Only to Content-Security-Policy once you are confident no legitimate resources are being blocked.
- Verify the header is present and correct using browser DevTools (Network tab → select any page response → Headers), or a tool like securityheaders.com.
Fix it on your platform
Pick your platform for the exact steps.
How to fix missing content security policy on Shopify
- Shopify does not allow arbitrary HTTP response headers to be set from the admin UI for storefront pages.
- Install a Shopify app such as 'EasyCSP' or 'CSP Manager' from the Shopify App Store, which injects the CSP header via a Shopify Proxy or middleware layer.
- Alternatively, if you use Shopify with a custom Oxygen / Hydrogen (headless) front-end, set the CSP header inside your Remix/Next.js server response headers in the loader or server entry file.
- For theme-level partial mitigation (not a true HTTP header), you can add a <meta http-equiv='Content-Security-Policy'> tag inside the <head> of your theme.liquid file (Online Store → Themes → Edit Code → layout/theme.liquid), but note that meta-tag CSPs do not cover all directives (e.g., frame-ancestors is ignored) and are weaker than HTTP headers.
- The most robust Shopify approach is to route traffic through Cloudflare (free plan available) and set the CSP as a Cloudflare Transform Rule (see Cloudflare entry below).
How to fix missing content security policy on Shopify Plus
- Same options as Shopify above apply.
- Shopify Plus merchants using Cloudflare for Enterprise or a custom reverse proxy have full control: configure the CSP header at the CDN/proxy layer.
- For Hydrogen/Oxygen storefronts: open your server.ts (or entry.server.tsx) file, locate the handleRequest function, and add the Content-Security-Policy header to the Response object before returning it.
How to fix missing content security policy on WooCommerce
- Install the free 'HTTP Headers' plugin by BTC (available on WordPress.org plugin repository) or the 'Headers Security Advanced & HSTS WP' plugin.
- In WordPress admin, go to Settings → HTTP Headers (or the plugin's menu item), find the Content-Security-Policy field, and enter your policy string.
- Alternatively, add the header via your theme's functions.php or a custom plugin using the send_headers action hook: add_action('send_headers', function(){ header("Content-Security-Policy: default-src 'self'; script-src 'self'; object-src 'none'; base-uri 'self';"); });
- If your host gives you access to Apache, add the header in .htaccess: Header set Content-Security-Policy "default-src 'self'; script-src 'self'; object-src 'none';"
- If your host uses Nginx, add add_header Content-Security-Policy "default-src 'self'; script-src 'self'; object-src 'none';" always; inside the relevant server {} block in your Nginx config.
- Verify in browser DevTools → Network → select a page → Response Headers.
How to fix missing content security policy on BigCommerce
- BigCommerce does not expose arbitrary HTTP response header settings in the merchant admin.
- The recommended approach is to place BigCommerce behind Cloudflare (free or paid) and configure the CSP as a Cloudflare HTTP Response Headers Transform Rule: Cloudflare Dashboard → your domain → Rules → Transform Rules → Modify Response Headers → Add header → Name: Content-Security-Policy → Value: your policy string.
- For headless BigCommerce storefronts (Next.js, Gatsby, etc.), set the header in next.config.js (headers() function) or your server middleware.
- As a partial fallback, add a <meta http-equiv='Content-Security-Policy' content='...'> tag inside your Stencil theme's base.html template (Storefront → My Themes → Edit Theme Files → templates/layout/base.html), understanding that this is weaker than an HTTP header.
How to fix missing content security policy on Adobe Commerce (Magento)
- Adobe Commerce has native CSP support (introduced in Magento 2.3.5+).
- In the Admin panel go to Stores → Configuration → Security → Content Security Policy.
- Set 'CSP Mode' to 'Restrict Mode' (enforced) — start with 'Report Only Mode' to gather violations first.
- Add your trusted domains for each directive (script-src, style-src, img-src, etc.) in the respective fields.
- To add additional directives or fine-tune, edit app/etc/config.php or create a csp_whitelist.xml file inside your custom module's etc/ directory following the Magento CSP whitelist XML schema.
- Deploy the changes and verify the header appears in browser DevTools.
How to fix missing content security policy on Magento Open Source
- Same as Adobe Commerce above — native CSP configuration is available from version 2.3.5+.
- Go to Stores → Configuration → Security → Content Security Policy in the Admin panel.
- Use Report Only mode first, then switch to Restrict (enforce) mode after reviewing violation logs.
- Add trusted domains per directive in the UI, or use a module-level csp_whitelist.xml for programmatic control.
How to fix missing content security policy on Wix
- Wix does not currently allow custom HTTP response headers on standard Wix sites.
- For Wix Studio / custom domains using a reverse proxy or Cloudflare, add the CSP header at the proxy/CDN layer (see Cloudflare approach).
- As a partial measure, Wix Velo (developer mode) lets you inject a <meta http-equiv='Content-Security-Policy'> tag into the page <head> via the 'Custom Code' feature: go to Settings → Custom Code → Add Code to Head, and paste the meta tag. Note this is weaker than an HTTP header.
- Raise this requirement with Wix Support or vote on Wix Feature Requests, as custom HTTP header support is a frequently requested feature.
How to fix missing content security policy on Wix Studio
- Wix Studio has the same HTTP header limitations as standard Wix.
- Use the Head Custom Code area (site Settings → Custom Code → Head) to add a <meta http-equiv='Content-Security-Policy'> tag as a partial measure.
- Route traffic through Cloudflare to set the real HTTP header at the CDN layer.
How to fix missing content security policy on Squarespace
- Squarespace does not allow custom HTTP response headers.
- Add a partial CSP via Settings → Advanced → Code Injection → Header field: paste a <meta http-equiv='Content-Security-Policy' content='default-src self; object-src none;'> tag. This only covers HTML pages, not all resource types, and some directives are ignored in meta-tag mode.
- For stronger enforcement, route your Squarespace site through Cloudflare and add the CSP as a Cloudflare Transform Rule on HTTP responses.
How to fix missing content security policy on Webflow
- Webflow does not support custom HTTP response headers on its hosting.
- Go to Project Settings → Custom Code → Head Code and add a <meta http-equiv='Content-Security-Policy' content='default-src self; object-src none;'> tag as a partial measure.
- For full header support, export your Webflow site and host it on a server you control (Netlify, Vercel, AWS), or route Webflow through Cloudflare and set the header via a Transform Rule.
- On Netlify: add a netlify.toml file with [[headers]] for /* and add Content-Security-Policy to the [headers.values] block.
How to fix missing content security policy on WordPress.org
- Install the 'HTTP Headers' plugin or 'Headers Security Advanced & HSTS WP' from the WordPress plugin repository.
- Configure the Content-Security-Policy header value in the plugin's settings page.
- Alternatively, add directly via functions.php: add_action('send_headers', function(){ header("Content-Security-Policy: default-src 'self'; script-src 'self'; object-src 'none'; base-uri 'self';"); });
- Or set in .htaccess (Apache): Header always set Content-Security-Policy "default-src 'self'; script-src 'self'; object-src 'none';"
- Or in Nginx config: add_header Content-Security-Policy "default-src 'self'; script-src 'self'; object-src 'none';" always;
How to fix missing content security policy on Headless / Custom (I build in code)
- Set the Content-Security-Policy header in your server's HTTP response for every route.
- Express.js: use the 'helmet' npm package — app.use(helmet.contentSecurityPolicy({ directives: { defaultSrc: ["'self'"], scriptSrc: ["'self'"], objectSrc: ["'none'"], baseUri: ["'self'"] } }));
- Next.js: add the header in next.config.js inside the headers() async function, or set it in middleware.ts using the NextResponse API.
- Nginx: add_header Content-Security-Policy "default-src 'self'; script-src 'self'; object-src 'none'; base-uri 'self';" always; in your server {} block.
- Apache: Header always set Content-Security-Policy "default-src 'self'; script-src 'self'; object-src 'none'; base-uri 'self';" in .htaccess or VirtualHost config.
- Cloudflare Workers / Pages: set the header inside the fetch handler Response constructor or via _headers file.
How to fix missing content security policy on PrestaShop
- Add the CSP header in your .htaccess file (Apache): Header always set Content-Security-Policy "default-src 'self'; script-src 'self'; object-src 'none'; base-uri 'self';"
- For Nginx servers, add add_header Content-Security-Policy "..." always; in the server block.
- Alternatively, install a PrestaShop security module such as 'Security Headers' from the PrestaShop Marketplace.
- Start in Report-Only mode first to avoid breaking legitimate third-party scripts loaded by PrestaShop modules.
How to fix missing content security policy on OpenCart
- Edit your .htaccess file (Apache) and add: Header always set Content-Security-Policy "default-src 'self'; script-src 'self'; object-src 'none'; base-uri 'self';"
- For Nginx, add the add_header directive in your OpenCart server block.
- Alternatively, modify system/startup.php or a custom controller to call header() before any output is sent.
- Use Report-Only mode initially, since OpenCart admin and extensions commonly use inline scripts.
How to fix missing content security policy on Drupal
- Install the 'Security Kit' (seckit) Drupal module from drupal.org.
- Go to Admin → Configuration → Security → Security Kit.
- Enable Content Security Policy and fill in the directive fields (default-src, script-src, object-src, etc.).
- Enable 'Report Only' mode first, review Drupal's watchdog logs for violations, then switch to enforce mode.
How to fix missing content security policy on Joomla
- Go to System → Global Configuration → Server tab → Content Security Policy (Joomla 4+ has a built-in CSP field).
- Enter your policy string in the Content Security Policy field and set the mode to 'Enforce'.
- Alternatively, use the .htaccess file: Header always set Content-Security-Policy "default-src 'self'; script-src 'self'; object-src 'none';"
- Install a Joomla security extension such as 'RSFirewall!' or 'Akeeba Admin Tools' for a UI-driven approach.
Does your site have this issue?
Run a free SEOLZ scan to find missing content security policy — and every other issue — across your whole site in minutes.
Scan my site freeFrequently asked questions
What is Missing content security policy?
A Content Security Policy (CSP) is an instruction you send to your visitors' web browsers, embedded in a special HTTP header, that tells the browser exactly which sources of scripts, images, styles, fonts, and other content it is allowed to load on your site. Think of it as a strict guest list at a nightclub door: anything not on the list gets turned away. Without a CSP header, the browser will happily load resources from anywhere — including malicious scripts injected by attackers. Your site currently sends no CSP header at all, which means that protection layer is completely absent.
Why does missing content security policy matter?
Without a CSP, your store is significantly more vulnerable to Cross-Site Scripting (XSS) attacks — one of the most common ways attackers steal customer data, hijack sessions, or install payment-skimming code (like Magecart) directly in your shoppers' browsers. A successful XSS attack can expose customers' credit card numbers, passwords, and personal information, leading to chargebacks, fines under GDPR/CCPA, PCI-DSS violations, and severe reputational damage. Google also considers site security as a ranking signal, so a visibly compromised site can lose organic search rankings fast. Adding a CSP is recognized by OWASP as a critical defense-in-depth control against injection attacks (A03:2021).
How do I fix missing content security policy?
Add a Content-Security-Policy (CSP) HTTP response header to every page to block unauthorized scripts, styles, and resources from loading in your visitors' browsers.