Free Content Security Policy (CSP) Checker

Free tool

Scan your Content Security Policy for unsafe-inline, unsafe-eval, missing object-src and base-uri, and weak sources. Get nonce and strict-dynamic fixes you can ship today.

  • CSP directives analysis
  • Detect unsafe-inline/eval
  • CSP violation detection
No credit card requiredProduction-safe (100% passive)No setup or code required
Trusted by 3,500+ security & engineering teams
Oracle logoShopify logoGoDaddy logoChubb logoToshiba logoMAPFRE logoBelfius logoGBG logoWEKA logoShift Technology logo

What you get for free

18 core security checks via this tool, passive scans, step-by-step remediation, security score on every result.

What Essential adds at $39/mo

+17 advanced checks, continuous monitoring, daily security score history, email alerts, GitHub SAST, board-ready PDFs, SOC 2 / ISO 27001 / PCI reports.

What is Content Security Policy (CSP)?

CSP is a browser security layer that controls where your app can load resources from (scripts, styles, images, frames, etc.). A strict policy prevents XSS and reduces supply‑chain risk by blocking unexpected sources.

Why CSP matters

A strong CSP can neutralize whole classes of injection bugs and mitigate third‑party script risk. It also provides defense in depth when combined with escaping, sanitization, and Trusted Types.

How to fix common failures

  • Replace script-src 'unsafe-inline' with nonces (rotate per request)
  • Add object-src 'none'; base-uri 'none'; form-action 'self'
  • Audit third‑party domains and restrict to explicit allow‑lists
  • Enable upgrade-insecure-requests and avoid mixed content

Examples (good vs bad)

Bad: script-src 'self' 'unsafe-inline' https://cdn.example.com

Better: script-src 'self' 'nonce-...' 'strict-dynamic' https://cdn.example.com; object-src 'none'; base-uri 'none'

What this checker validates

  • Detects unsafe directives (unsafe-inline, unsafe-eval)
  • Flags missing baselines: object-src 'none', base-uri 'none'
  • Evaluates nonce/hash usage and recommends strict-dynamic
  • Reviews frame-ancestors, form-action, upgrade-insecure-requests
  • Monitors CSP console errors to identify blocked legitimate resources

Across 7,440 recent scans, 98.9% are missing a strict Content Security Policy, and 98.0% have no Trusted Types directive.

Implementation examples

Once you've identified the gap, applying the fix is straightforward. Here are the three configurations developers reach for most often.

Nginx

add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'nonce-$request_id' 'strict-dynamic'; object-src 'none'; base-uri 'none'; form-action 'self'; frame-ancestors 'none'; upgrade-insecure-requests" always;

Apache

Header always set Content-Security-Policy "default-src 'self'; script-src 'self' 'nonce-%{CSP_NONCE}e' 'strict-dynamic'; object-src 'none'; base-uri 'none'; form-action 'self'; frame-ancestors 'none'; upgrade-insecure-requests"

Node.js (Express + Helmet)

import crypto from "node:crypto"
import express from "express"
import helmet from "helmet"

const app = express()

app.use((req, res, next) => {
  res.locals.cspNonce = crypto.randomBytes(16).toString("base64")
  next()
})

app.use(
  helmet({
    contentSecurityPolicy: {
      useDefaults: false,
      directives: {
        defaultSrc: ["'self'"],
        scriptSrc: [
          "'self'",
          (_req, res) => `'nonce-${(res as express.Response).locals.cspNonce}'`,
          "'strict-dynamic'",
        ],
        objectSrc: ["'none'"],
        baseUri: ["'none'"],
        formAction: ["'self'"],
        frameAncestors: ["'none'"],
        upgradeInsecureRequests: [],
      },
    },
  }),
)

Tool-specific questions

What does a CSP checker test?

A CSP checker inspects the Content-Security-Policy header your site sends and evaluates it for risky directives like unsafe-inline, unsafe-eval, and wildcard sources. These allow injected scripts to run and are a primary target for XSS attacks. Barrion's free tool identifies gaps and provides guidance on switching to nonces, hashes, and strict-dynamic for a secure, modern CSP.

Should I use nonces or hashes?

For dynamic apps, prefer nonces with strict-dynamic. For static inline scripts, hashes are fine. Avoid unsafe-inline entirely.

Do I need object-src and base-uri even if unused?

Yes. Set object-src 'none' and base-uri 'none' to close legacy vectors and prevent base tag abuse.

Can I allow *.cdn.com wildcards?

Use precise hosts over broad wildcards. Prefer scheme+host allow‑lists to limit blast radius.

How often should CSP nonces rotate?

Per response/request. Never reuse nonces across requests.

How do I migrate from unsafe-inline to nonces?

Identify inline scripts, move logic to external files where possible, add per-response nonces to remaining inline scripts, and include the nonce in script-src with strict-dynamic. Remove unsafe-inline once all critical scripts are covered.

Why do third-party widgets get blocked?

Widgets load scripts, frames, or styles from external origins. Add only the required hosts to your CSP allow-list and prefer provider guidance on exact domains. Avoid broad wildcards.

Does Barrion detect CSP console errors?

Yes, Barrion detects CSP console errors that occur when your CSP policy blocks legitimate resources your website needs. These violations appear in the browser's developer console and can silently break website features, degrade user experience, or prevent third-party services (analytics, widgets, CDNs) from working. Our monitoring helps you identify and fix these issues while maintaining strong security.
Why Barrion

Built for the engineers who already have enough to fix.

Speed

Real-time results

Instant analysis with a detailed report. You see findings as the scan runs, not after.
Coverage

Comprehensive checks

35+ checks per scan covering TLS, headers, CORS, cookies, DNS, email auth, and more, in a single pass.
Action

Step-by-step fixes

Every finding ships with the exact remediation step for your framework. Hand it to the engineer who owns the surface.
FAQ

Frequently asked.

What is Barrion and how does it enhance website security?
Barrion is a security testing and monitoring platform for engineering teams, covering three products: passive DAST that continuously watches your live web apps and APIs, SAST via GitHub that scans your codebase for secrets, insecure patterns and vulnerable dependencies, and AI pentesting that runs active, agent-driven attacks with proof-of-exploit. Findings come with step-by-step fixes you can ship immediately.
How safe is Barrion to use for security testing?
Every default Barrion scan is 100% passive and read-only. We never submit forms, brute-force endpoints or interact with state-changing routes, so it's safe to run against production.
What types of security issues does Barrion identify?
Barrion is a security testing and monitoring platform, so coverage spans three surfaces. Passive DAST flags misconfigurations across TLS/HTTPS, security headers, cookie flags, CORS policy, DNS records, email authentication (SPF/DKIM/DMARC), network exposure and common web hygiene issues. SAST via GitHub finds secrets in code, insecure patterns and vulnerable dependencies. AI pentesting adds exploitable findings like SQL injection, XSS and broken access control with proof-of-exploit.
What specific security checks does Barrion perform?
Barrion checks TLS/HTTPS configuration, HTTP security headers, cookie flags, CORS policy, DNS and email authentication records, network exposure and common web hygiene issues, then prioritises them by severity with clear remediation.
What is Barrion's smart crawling?
Smart crawling automatically discovers the pages and endpoints of your app so scans cover the surface that matters, without you manually listing every URL.
How often does Barrion perform security scans?
Manual scans on demand. Continuous monitoring runs automatically on Essential (weekly+) and Business (daily), and alerts you the moment a new issue appears.
Is Barrion suitable for security testing of all business sizes?
Yes. Barrion is a security testing and monitoring platform, with passive DAST, SAST via GitHub and AI pentesting available to solo developers, startups, scale-ups and enterprise security teams alike, without adding headcount.
How does Barrion handle data security and privacy during security testing?
Scans are passive and read-only by default, and we never store or expose sensitive data from your application. Pentests are rate-limited and non-destructive, designed to confirm exploitability without altering data or affecting availability.
What if I'm not satisfied with Barrion's security testing service?
Paid plans start with a free trial, and you can cancel anytime. If something isn't right, contact us and we'll make it work for your team.
How does Barrion help with SOC 2, ISO 27001, NIS2, and other compliance frameworks?
Barrion produces audit-ready PDF and CSV reports suitable for SOC 2, ISO 27001, PCI DSS and NIS2, ready to share with auditors, customers and your board.

Anything else? Email contact@barrion.io.

Lock down your CSP, then keep it locked.

Run continuous CSP checks across releases. Catch unsafe-inline regressions before they ship.