Spider AF /
Recursos /
Artículos /
What Is Content Security Policy? CSP Checks and Setup
Fraude de clics
Actualizado:
November 10, 2026

What Is Content Security Policy? CSP Checks and Setup

Learn what content security policy does, check your CSP header, and use Report-Only testing to help your developer review scripts before enforcing a policy.
Illustration of a blue rocker switch turned on, with a dashed outline showing its earlier test position, representing testing CSP rules before turning on blocking.

En este artículo

Resumen rápido · Versión de 30 segundos
  • Content Security Policy (CSP) tells browsers what a page may load or run and limits certain actions, such as where forms send information.
  • Look at the settings your site sends with each page (called response headers) for Content-Security-Policy or Content-Security-Policy-Report-Only. The second one only tests the rules: it reports what would be blocked but blocks nothing.
  • List your scripts (the code that runs in visitors’ browsers), have your developer set up and test the policy, and review it when your site changes.

You’ve been told your website has no Content Security Policy, and you need to know what to check. Content Security Policy (CSP) is a set of rules your site sends to browsers. The rules control what a page may load or run and limit certain actions.

Start by checking which CSP rules your pages send and listing the tools they load. You don’t need to write the rules yourself: your developer, web agency, or IT team makes and tests the changes. Your role is to explain which website features and marketing tools need to work. CSP is an extra safeguard, not a repair for weaknesses in your website’s code.

What is content security policy, and what does it do?

CSP controls which resources, such as scripts and images, a page may load or run. When a policy is enforced (turned on to block), the browser stops actions that break its rules. The W3C Content Security Policy Level 3 specification describes this behavior.

Diagram of how CSP works: your website sends a list of allowed sources to the visitor's browser, which loads your own scripts and an approved analytics tag but blocks a script from an unlisted site; in Report-Only test mode nothing is blocked and rule breaks are only reported

What CSP can and can’t do

CSP can help limit attacks that inject unwanted code into a page, often called cross-site scripting (XSS). It can also limit where forms send information and which other sites may show your page inside their own pages. That helps protect against clickjacking, where visitors are tricked into clicking something on your page while it’s hidden or disguised inside another site.

Treat CSP as a second layer of defense. It doesn’t fix weaknesses in your website’s code or problems on your server. You also can’t rely on it to stop harmful code from a place your rules already allow.

Website scripts are written in JavaScript, a programming language that runs in visitors’ browsers. CSP is only one part of keeping scripts safe; see JavaScript security practices beyond CSP for the rest.

How your website sends CSP rules

Response headers are settings your server sends alongside a page. A meta tag is a line of code inside the page’s HTML, the code that structures the page. It can also carry CSP rules.

Table A. Ways to deliver CSP: response header or meta tag

Delivery method What it does Main limitations or checks
Content-Security-Policy response headerBlocks actions that break its rules.This policy keeps blocking even when a Report-Only policy is also present.
Content-Security-Policy-Report-Only response headerReports what would be blocked, but blocks nothing.Cannot be delivered through a meta tag. Collecting reports requires a configured destination.
HTML meta tagApplies rules only to content after the tag and supports fewer features.Cannot use Report-Only testing, frame-ancestors (letting other sites show your page), sandbox (extra page restrictions), or the older report-uri (sends reports to a destination). MDN, Mozilla’s web developer documentation, also lists the newer report-to (which picks a destination listed in a separate header) as unsupported.

These limits are documented in W3C’s meta-tag rules and MDN’s report-to reference. Ask your developer to use response headers where possible.

How do you check your CSP header?

A CSP header is the Content-Security-Policy response header: a line your server sends with each page that lists the rules. Use your browser’s built-in developer tools to examine the page’s response headers. Check whether the page has rules that block actions, rules that are only being tested, or both.

1. Open the page’s response headers

Open the page, then open your browser’s developer tools. Find the panel that lists everything the browser requests to load the page (in Chrome, it’s called Network). Reload the page and select the entry for the page itself.

In Chrome, you may see a Headers tab and a Response headers section. Names and placement can differ by browser version; Chrome’s network inspection documentation provides the general workflow.

2. Identify blocking, test-only, and meta tag rules

Look for these two names:

  • Content-Security-Policy: the browser blocks anything that breaks these rules.
  • Content-Security-Policy-Report-Only: these rules are only tested; the browser reports problems but blocks nothing.

If both appear, the blocking policy still applies. MDN’s Report-Only reference explains how the two work together.

If neither appears, ask your developer to check for a meta-tag policy in the page’s code. Checking one page doesn’t tell you how CSP is set up across your entire website.

3. Review console messages and policy findings

The console in your developer tools is a message log, and it can show CSP problems. Tell your developer which page you were on and what you were doing. The wording of these messages varies.

Your developer can use CSP Evaluator to review policy weaknesses. It isn’t an official Google product or a guarantee of safety.

SiteScan checks whether your site has a CSP. It treats a site with only Report-Only rules as having no CSP, but it counts a CSP set in a meta tag. Ask your developer to review the policy itself. Having a CSP alone doesn’t mean your site is safe.

How do you set up CSP in four steps?

Start with the scripts your website needs, then have your developer draft, test, and apply the rules. Finding a script or connection on your site doesn’t automatically mean it should be allowed.

Diagram of four CSP setup steps on an arc: inventory scripts and destinations, draft a policy, test with Report-Only while nothing is blocked, and enforce the tested policy, with a loop to fix the policy and test again

1. Inventory scripts and agree on what the site needs

List the JavaScript, tools from other companies (third-party tools), and tags your pages load. Tags are small pieces of code that tools such as analytics platforms add to your pages. Record their purpose, where they send data, and who on your team can confirm they’re needed.

SiteScan supports this inventory, including where tags send data. For pages behind a login and other non-public pages, the SiteScan tag must be installed through Google Tag Manager (GTM), a tool for managing website tags.

Your team decides which tools to keep. For that discussion, see how to review third-party script risks.

2. Have your developer draft a policy

A CSP directive is an individual rule within the policy. The table below covers five common rules as a starting point for discussing requirements with your developer; MDN documents each rule.

Table B. Rules to discuss with your developer

Rule What it does What to check
default-srcSets default loading rules for scripts, images, and other content when no more specific rule is set. A few rules, such as frame-ancestors, form-action, and base-uri, don’t use these defaults.It does not replace every other rule.
script-srcControls which scripts may load or run.Have your developer consider the two ways to approve specific scripts described below the table.
connect-srcLimits destinations scripts can contact to send or receive data.Confirm required connections. It does not control every possible way data can leave a page.
form-actionLimits where forms may send information.Check the destinations your actual forms use.
frame-ancestorsControls which other sites may display your page inside theirs.Cannot be set through a meta tag. The permissions in default-src don’t apply to this rule.

Your developer should evaluate rules that use a nonce or a hash to approve specific scripts. A nonce is an unpredictable, one-time value your server creates each time it sends the page, so the browser can recognize approved scripts. A hash is a fingerprint calculated from a script’s exact contents.

MDN’s CSP guidance recommends these approaches. The same guide advises against 'unsafe-inline', which allows code written directly inside a page, because that weakens CSP protection.

The table isn’t a complete policy to copy into your site.

3. Test the policy with Report-Only

Report-Only is a test mode: the browser reports what would be blocked, but blocks nothing. Have your developer send the proposed rules through the Report-Only header and configure a destination for reports.

Test the website actions your business relies on. Any CSP rules already set to block keep blocking during this test.

4. Review the results and turn on blocking

Review reported problems with your developer and the people responsible for affected tools. Adjust the policy or site code as needed, then test again before turning on blocking.

When you brief your developer, cover these items:

Item What to provide or agree on
List of scriptsTools, purposes, data destinations, and team contacts.
What to testPages, forms, and marketing actions that must work.
ReportingWhere reports arrive and who reviews them.
Changes to CSP settingsWho applies the tested policy and checks it afterward.
Follow-upWho reviews CSP when scripts or tools change.

How do you test CSP with Report-Only?

Content Security Policy Report-Only testing shows which actions would break your proposed rules, without blocking anything. Collecting those reports requires a destination; the header alone isn’t enough.

Set up reporting destinations

A reporting endpoint is the web address that receives browser reports. Your developer needs to prepare that destination and connect it to the policy.

The Reporting-Endpoints header lists where reports can go, and the CSP rule report-to picks which one to use. MDN’s Reporting-Endpoints reference describes this relationship.

The older report-uri method is deprecated, meaning it’s being phased out. Even so, current reporting guidance recommends including both report-uri and report-to so reports arrive from more browsers. Your developer should check which methods work in the browsers your site needs to support.

Seeing a message in the browser’s console is different from collecting reports at a destination. Ask your developer to confirm that reports actually arrive during testing.

Read a violation report

A violation means an action breaks a policy rule. It doesn’t, by itself, prove that an attack occurred.

For reports sent through report-to, look for these labels:

  • documentURL: the page where the issue occurred.
  • blockedURL: the address of what was blocked, or would have been blocked in test mode. For code written directly inside the page, it shows the word inline instead of an address.
  • effectiveDirective: the name of the rule that was broken.
  • disposition: whether the report concerns blocking mode (enforce) or testing mode (report).

Reports sent the older way (report-uri format) use hyphenated names for the first three labels: document-uri, blocked-uri, and effective-directive. They mean the same things. The disposition label keeps its name.

Diagram explaining an example CSP violation report: documentURL is the page where it happened, blockedURL is what broke the rule, effectiveDirective is which rule it broke, and disposition shows whether it was only reported or blocked

Test the pages and tags your business relies on

Open key pages, submit your forms, and check that analytics and marketing tools still work. Your developer should also check the reports: a tool can work during Report-Only testing and still fail once blocking starts. Record what you did so your developer can repeat a failing action.

If you use GTM, include CSP considerations for Google Tag Manager in the review.

A report may reveal a legitimate tool that needs attention. Confirm its purpose before allowing its code or connections, then address the reported issues and test again.

How do you keep CSP useful as your site changes?

Review CSP whenever your team adds or changes scripts, tags, or third-party tools. Confirm that required features still work and that permissions still match what the business needs.

Review script changes and where tags send data

Compare the current script inventory with earlier versions. Review changes to both the code your pages load in the browser and the destinations that tags contact.

SiteScan supports version history (a record of how scripts change over time) and continuous monitoring of script changes. Review those changes with your developer to decide whether CSP needs updating.

Assign responsibility for policy reviews

Decide who confirms why a tool is needed, who reviews technical findings, and who changes the settings. Write the answers down so changes don’t fall through the cracks.

For that ongoing process, see how to maintain a script inventory and monitor changes.

SiteScan provides information for your review; your developer, web agency, or IT team changes the CSP settings.

See the scripts your pages load Check for a CSP with SiteScan

Frequently asked questions

You can check CSP and discuss how to add it without writing the rules yourself.

How can I check whether my website has a Content Security Policy (CSP)?

You can check in your browser’s developer tools, the built-in tools for inspecting a page. Response headers are the settings your server sends with the page. Look in these headers for Content-Security-Policy (rules that block) or Content-Security-Policy-Report-Only (rules that are only being tested). If neither appears, ask your developer whether the rules are written into the page’s code instead.

Can I test CSP before it blocks scripts or other content?

You can test it first. Your developer can run the rules in Report-Only, a test mode where the browser reports what the rules would block but blocks nothing. Blocking starts only when your developer switches the tested rules on, although any blocking rules your site already has keep working during the test. Problems also show up in the browser’s console, a message log in the developer tools. To collect reports from visitors, your developer sets up an address that receives them.

Can my developer set CSP with a meta tag in the page’s code?

Yes, but with limits. A meta tag is a line of code inside the page’s HTML, and rules written there only cover what comes after it. A meta tag also can’t run the rules in Report-Only test mode or control which other sites can show your page inside theirs. When possible, ask your developer to deliver CSP through response headers, the settings your server sends with each page.

Could CSP break my analytics or marketing tools?

Yes, the browser can stop a tool from working if the rules don’t allow its code or the places it sends data to. That’s why your developer should first run the rules in Report-Only and check key pages, forms, and analytics. This test mode reports problems without blocking anything. Before approving anything the test flags, confirm that your business actually needs that tool.

Can SiteScan set up a CSP for me?

No. SiteScan doesn’t create, configure, or enforce your CSP. It checks whether your site has a CSP and helps you inventory the scripts your pages load in the browser. Your developer, web agency, or IT team makes and tests the configuration changes.

Detén el fraude publicitario ahora

¿Tu presupuesto está siendo robado por bots?

Spider AF detecta y bloquea el tráfico inválido en tiempo real, antes de que desperdicie tu inversión.

Informe gratuito de fraude en 24 horas
No se requiere tarjeta de crédito
Funciona con Google Ads, Meta y más
Iniciar prueba gratuita
2026 Edición anual
White Paper sobre Fraude Publicitario
Periodo del estudio: 1 ene. 2025 - 31 dic. 2025
GRATIS

Crecimiento de MFA, riesgos de fraude impulsados por IA y cómo los principales anunciantes protegen sus presupuestos. PDF gratuito.

$84B
Perdidos globalmente
2026
Última edición
Gratis
PDF por email
Descargar ahora

Deja de perder presupuesto por culpa de bots. Empieza a proteger tus anuncios hoy.

Spider AF bloquea click farms, tráfico de bots y clics inválidos en tiempo real, para que cada yen de tu presupuesto publicitario rinda más.

Detecta fraude en Google, Meta y más
Bloqueo en tiempo real, no solo reportes
Configuración en menos de 10 minutos
Usado por más de 2,000 anunciantes en todo el mundo