Skip to the content
Start free

No Content-Security-Policy header

Nothing tells browsers which sources may run scripts on the page, so an injected script would run freely.

Medium priority Security and HTTPS

Why it matters #

A Content-Security-Policy (CSP) lists the places a page may load scripts, styles, images and frames from. If an attacker manages to inject a script, for example through a weak plugin or a form, a good policy stops it running.

CSP is a second line of defence, not a fix for the hole itself, but it limits the damage. It is one of the headers security guides recommend most often.

How to fix it #

Start with Content-Security-Policy-Report-Only: it blocks nothing, but the browser console shows what a real policy would block. Add the sources you really use, such as your own domain, your analytics and your payment provider, then send it as Content-Security-Policy.

On WordPress, a security plugin or your host can add the header. The Security Headers Checker suggests a line to start from.

What it looks like, and fixed #

The problem
HTTP/2 200
content-type: text/html; charset=UTF-8
strict-transport-security: max-age=31536000

No Content-Security-Policy, so any injected script would run.

Fixed
Content-Security-Policy-Report-Only: default-src 'self'; script-src 'self' https://www.googletagmanager.com; img-src 'self' data: https:; object-src 'none'; base-uri 'self'; frame-ancestors 'self'

A starting policy in report-only mode: it blocks nothing yet, and the browser console shows what it would block. Add the sources your site really uses.

Fix it with your AI assistant #

Paste this into ChatGPT, Claude, Gemini or your coding agent. Fill in the words in [square brackets] first. It checks before it changes anything, changes only this, and tells you how to prove it worked.

Your instruction for the AI
Help me add a Content-Security-Policy to [your website address], built with [your platform, e.g. WordPress with WooCommerce]. A checker says no CSP header is sent, so an injected script would run freely. First, read the source of my key pages (home, a product or article, the basket or checkout, the contact form), or ask me to paste them, and list every outside host that loads scripts, styles, fonts, images and frames, such as analytics, payment and chat. Explain plainly what the site depends on. Then write a starting policy sent as Content-Security-Policy-Report-Only, with default-src 'self', object-src 'none', base-uri 'self' and only the hosts you found. Rules: report-only first, never block my payment provider or checkout, do not add 'unsafe-eval' unless something truly needs it, back up configuration first, and keep all other headers. Tell me how to read the console reports, and when to switch to Content-Security-Policy. Give the exact header and where it goes. Finally, tell me to re-check with the URSY.com Security Headers Checker at ursy.com/security-headers-checker/.

We find the problems, and help you fix them

  1. Check Run a free tool or the full audit.
  2. Fix it with your AI Download your AI Fix Pack and drop it into ChatGPT, Claude or Gemini. A free account is enough.
  3. Re-check Come back, check again, and watch each fix turn green.

How the AI Fix Pack works, with a sample to download

Fix it on your platform #

WordPress

Some security plugins can send a CSP header, or your host can add it. Test on a staging copy first, because themes and plugins load scripts from many places.

Your server or hosting

On nginx use add_header Content-Security-Policy-Report-Only "..." always; and on Apache use Header always set. Switch the name to Content-Security-Policy when the reports are clean.

Your CDN (for example Cloudflare)

On Cloudflare a response header Transform Rule can add the header without touching the server.

Check it is fixed #

Run the Security Headers Checker again: it should find a Content-Security-Policy (or report-only policy while you test). Test checkout and forms with the browser console open.

Official source #

MDN: Content-Security-Policy

Questions #

Can a CSP break my site?

Yes, an enforced policy that misses a source blocks it. That is why you start in report-only mode and switch over only when the reports show nothing you need.

Does a CSP help my Google ranking?

Google does not list it as a ranking signal. It protects visitors, and helps stop injected spam that could harm the site.

More problems in Security and HTTPS

See every problem in the library

For AI assistants and developers: Instructions for AI · Developers · How to cite URSY.com