AI-assisted

CSP Builder and Evaluator

Paste a Content Security Policy. See the ways around it, and get a stricter policy written for you.

· Nothing you paste is stored.

What a CSP is for

A Content Security Policy is a header that tells the browser which scripts, styles and connections a page is allowed to use. Its main job is to make cross-site scripting harmless: if an attacker manages to inject a script, the browser refuses to run it. That only works if the policy is strict. Most policies in the wild contain an entry that lets injected script run anyway, which makes them decoration.

What the evaluator looks for

Fixed rules parse each directive and test for the known ways around a policy: unsafe-inline without a nonce or hash, unsafe-eval, wildcards and whole schemes such as https:, the data: scheme for scripts, hosts that serve user-uploaded code or JSONP, and missing object-src, base-uri and frame-ancestors. The AI then writes a stricter policy based on yours, using the nonce-based approach browsers now recommend.

Rolling out a stricter policy

A new policy can break a working site, because every inline script and third-party tag has to be accounted for. Send it first as Content-Security-Policy-Report-Only with a reporting endpoint, watch what would have been blocked for a week or two, fix the page, then enforce. The suggested policy uses a placeholder for the nonce, which your server must generate fresh for every response.

How this tool works

  1. Rules run first. Fixed checks produce the findings, each with the evidence that triggered it, so you can verify every one.
  2. AI explains. An AI advisor reads the findings and writes the fix plan. That section is labelled, so you always know which part is which.
  3. Nothing is kept. Your input is used for the check and then discarded.

Questions and answers

What is wrong with unsafe-inline?

It allows any inline script to run, including one an attacker injects. That removes the main protection a CSP gives. Use a nonce or hash instead.

What is a nonce?

A random value generated for each page load. The header lists it and each legitimate script tag carries it. An injected script does not know it, so the browser blocks it.

Why is allowing a CDN risky?

Many public CDNs host thousands of libraries, some with features that run attacker-chosen code. Allowing the whole host allows all of them.

What does strict-dynamic do?

It lets a script you trust by nonce load further scripts, and makes the browser ignore host allowlists. It is the simplest way to a strong policy for modern sites.

Does CSP replace fixing XSS?

No. It is a second line of defence. Escape output and validate input first.

Where do I find my current policy?

Open your site, open the browser developer tools, choose the Network tab, click the page request and look for the content-security-policy response header.

Keep going