Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Missing Content-Security-Policy header: how to add one safely

OPS-170Medium impactDetectedBy FunnelGuardPublished Updated
On this page

What this issue is

A Content-Security-Policy is an HTTP response header. It gives the browser a list of places your page is allowed to load scripts, styles, images, frames and form targets from. Anything not on the list is blocked.

If the header is missing, the browser applies no such limit. A malicious script added through a hacked plugin, a compromised third-party tag or a cross-site scripting (XSS) hole can load more code from anywhere and send data wherever it likes.

Why it costs you leads or sales

Without a CSP, one injected script on a checkout or lead form page can copy what visitors type, redirect them, or add a fake form. Visitors who see a warning or lose card data stop trusting you. Search engines and ad platforms can also flag a hacked site, which can pause your campaigns.

There is a second cost in the other direction: a badly written CSP blocks your own form scripts, chat widget or ad tags. That is why the fix needs care.

How a missing CSP lets an injected script hurt a funnel
  1. Visitor opens form pagePage loads normally
  2. Injected script loadsNo CSP to block an unknown domain
  3. Form data copiedDetails sent to a third party
  4. Trust and leads lostWarnings, refunds, paused ads

Without a CSP the browser has no rule to stop the foreign script.

How to check if your site has it

Check for a CSP header
  1. Use browser DevTools

    Open your page, press F12, go to the Network tab, reload, click the first document request and look under Response Headers for content-security-policy.

  2. Or use the command line

    Run the command below and look for a content-security-policy line. No line means no CSP.

  3. Check key page types

    Test the home page, a form page and checkout. Headers can differ by path, especially behind a CDN or on a hosted checkout.

Look for the headerbash
curl -sI https://www.example.com/ | grep -i content-security-policy

How to fix it

The safe route is to start with Content-Security-Policy-Report-Only. The browser reports what it would block but blocks nothing. Review the console messages, add the domains you trust, then switch to the enforcing header.

Roll out a CSP without breaking your funnel
  1. List what your pages load

    Note every domain for forms, payments, chat, fonts, video and tracking tags (for example Google Tag Manager, Meta, LinkedIn).

  2. Send the report-only header

    Add the starter policy below with the header name Content-Security-Policy-Report-Only.

  3. Test your journeys

    Submit a form, open the chat, run a test checkout. Read the console for 'Refused to load' style messages and add the needed domains.

  4. Enforce

    When the console is quiet, rename the header to Content-Security-Policy.

  5. Tighten over time

    Move away from 'unsafe-inline' using nonces or hashes where your setup allows it.

Starter policy (edit the domains to match your site)text
Content-Security-Policy-Report-Only: default-src 'self'; script-src 'self' 'unsafe-inline' https://www.googletagmanager.com https://www.google-analytics.com; img-src 'self' data: https:; style-src 'self' 'unsafe-inline'; connect-src 'self' https://www.google-analytics.com https://*.analytics.google.com; frame-ancestors 'self'; form-action 'self'; base-uri 'self'
Where to add the header
  1. Use a headers plugin or server config

    Use a security headers plugin that supports Content-Security-Policy, or add the header in your server config (nginx or .htaccess). Start with report-only.

  2. Watch plugin scripts

    Form, chat and page builder plugins often use inline scripts, so expect to allow 'unsafe-inline' at first.

nginx: add the header (report-only first)nginx
add_header Content-Security-Policy-Report-Only "default-src 'self'; script-src 'self' https://www.googletagmanager.com; img-src 'self' data: https:; frame-ancestors 'self'" always;
Apache .htaccess (needs mod_headers)htaccess
<IfModule mod_headers.c>
Header set Content-Security-Policy-Report-Only "default-src 'self'; script-src 'self' https://www.googletagmanager.com; img-src 'self' data: https:; frame-ancestors 'self'"
</IfModule>
Before and after

No CSP

  • Browser loads scripts from any domain
  • Injected code can send data anywhere
  • No visibility into what pages load

Tuned CSP

  • Only approved domains can load scripts
  • Unknown script sources are blocked
  • Forms, chat and tracking still work

How to confirm it's fixed

Confirmation checklist
  • curl or DevTools shows the content-security-policy header on home, form and checkout pages
  • The browser console shows no 'Refused to load' errors for your own scripts
  • A test form submission reaches your inbox or CRM
  • Tag Assistant or the Network tab shows GA4, Google Ads and Meta hits still firing
  • Chat, video and payment widgets still load

How to prevent it happening again

Treat the CSP as part of your tag change process. Every time someone adds a new pixel, widget or form tool, add its domain to the policy first. Keep a short list of approved domains and review it when you remove tools.

Run a header check after theme, CDN or hosting changes, since they can drop or overwrite headers.

Example rollout over four weeks
  1. Week 1

    Audit domains and add the report-only header

  2. Week 2

    Fix console warnings, test forms and checkout

  3. Week 3

    Switch to enforcing on a low-traffic page first

  4. Week 4

    Enforce site-wide and confirm tags still fire

How FunnelGuard handles this

FunnelGuard does not check for a missing Content-Security-Policy today. It is a possible future check, not a current feature.

What it does cover nearby is the damage a bad CSP can cause. A robot visitor runs your real journeys on a schedule, checks each step, and checks the tracking hits sent to GA4, Google Ads, Meta and other platforms, and whether test leads reach the inbox and CRM. If an enforced CSP blocked a form script or a tag, that journey failure would show up. It would not tell you the header itself is missing.

To watch for the header itself, run the curl command above after releases, or use a free online security header scanner on a schedule. You can start with the free plan (1 site, 2 journeys, daily checks) to keep an eye on your forms and tracking while you tune a policy.

Questions people ask

What is a Content-Security-Policy header?

It is an HTTP response header that tells the browser which sources your page may load scripts, styles, images, frames and form targets from. Anything outside the list is blocked. It limits the damage from injected or compromised scripts.

Why is my site missing a Content-Security-Policy?

Servers and CMS platforms do not send one by default, because a correct policy depends on the specific tools your site uses. You have to define and add it yourself at the server, CDN or through a plugin.

How do I check if my website has a CSP header?

Open DevTools, go to the Network tab, reload and click the page request, then look for content-security-policy under Response Headers. Or run curl -sI on your URL and search for the header name.

Will adding a CSP break my tracking or forms?

It can if the policy does not allow the domains your tags, forms and widgets use. Start with Content-Security-Policy-Report-Only, fix the console warnings, then enforce, and test a form and your conversion tags afterwards.

What is CSP report-only mode?

Report-only mode uses the header Content-Security-Policy-Report-Only. The browser logs what the policy would block but blocks nothing, so you can tune the rules safely before enforcing them.

Can I add a CSP on Shopify, Wix or Squarespace?

Usually not as a full response header, because these platforms control headers themselves. Check their current documentation, and focus on removing unneeded scripts and apps instead.

Does FunnelGuard detect a missing Content-Security-Policy?

No. FunnelGuard does not check this yet. It can show if a journey or tracking hit breaks after you change your policy, and you can check the header yourself with curl or a header scanner.

Does FunnelGuard catch this?

Detected

FunnelGuard checks for this today.

How: site safety (Stage 26, daily): Content-Security-Policy.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.