Wiki / Security headers
Risk: Content-Security-Policy (CSP)
The browser runs any script on your pages wherever it comes from, so injected foreign code works unhindered. It is a second line of defence, not a hole: there is no rush, and switching it on carelessly is risky.
What it does not mean. It does not mean the site has an XSS flaw or has been hacked. CSP only limits the damage if such a flaw appears.
- In our report
- Risk (red), category weight 1.0 of 2.0
- Time to fix
- 10 minutes for report-only mode; weeks to reach a strict policy
- Can it break things
- Yes. A strict policy without testing stops analytics, maps, payment frames
How to fix it
Start with two things that cannot break anything: frame-ancestors (protection against framing) and the monitoring header Content-Security-Policy-Report-Only, which only shows violations in the browser console and blocks nothing.
nginx (tested on 1.26.3)
add_header Content-Security-Policy "frame-ancestors 'self'" always;
add_header Content-Security-Policy-Report-Only "default-src 'self'" always;Apache (tested on 2.4.59, also works in .htaccess)
Header always set Content-Security-Policy "frame-ancestors 'self'"
Header always set Content-Security-Policy-Report-Only "default-src 'self'"Next: from monitoring to blocking
Content-Security-Policy: default-src 'self'; script-src 'self' https://www.googletagmanager.com; img-src 'self' data: https:; frame-ancestors 'self'Open the site, collect every violation message in the browser console (F12) and add each source you need to the policy. When the console stays empty on every page type (home, product, cart, checkout), move the policy from Report-Only to Content-Security-Policy. The source in the example is an illustration: your list will differ.

How to check
curl -sI https://example.com | grep -i content-security-policyExpected
content-security-policy: frame-ancestors 'self'
content-security-policy-report-only: default-src 'self'The header alone proves little: whether the policy fits is shown only by the browser console on real pages.
What can break
- A strict policy switched on without the monitoring stage silently turns off whatever loads from elsewhere: Google Analytics, the Facebook pixel, a map, a chat widget, a bank's payment frame. The visitor sees no error, a button just does nothing.
- Several CSP headers (one from the server, another from a plugin or Cloudflare) do not merge: the strictest value of each directive applies. Loosening one leaves the other still blocking.
- In a
<meta>tag,frame-ancestors,report-uri,sandboxand the wholeReport-Onlyheader do not work. They can only be sent by the server.
Possible values
| Value | What it does | Note |
|---|---|---|
default-src 'self' | Fallback rule for all resources: own domain only | On its own it already disables inline scripts and eval() |
script-src | Where scripts may come from | The most important directive |
'unsafe-inline' | Allows inline scripts and styles again | Removes most of the benefit of CSP; WordPress with plugins often does not work without it |
'nonce-…' | Allows only scripts carrying the same one-time value | The safest way; the value must change with every response |
frame-ancestors | Who may show your page in a frame | Overrides X-Frame-Options; does not work in <meta> |
report-uri | Where violation reports are sent | Deprecated; replaced by report-to |
Our data
69.68%
of 73,386 inspected .lt websites (51,135) have no CSP header. It is the most common finding in the whole dataset. Dataset, 16 November 2026
Sources
- W3C: Content Security Policy Level 3
- MDN (Mozilla): Content-Security-Policy header
- nginx documentation: add_header
- Apache documentation: mod_headers
- AGuard: security dataset of Lithuanian websites, DOI 10.5281/zenodo.24282573
Changes
- Page published; nginx and Apache lines tested on a test server.
