Skip to main content
New: 190 SEO checks now available. See what's new
lowSecurityCSP_UNSAFE_INLINE

CSP allows unsafe-inline scripts — the fix

The Content-Security-Policy includes 'unsafe-inline' in the script-src directive, which significantly weakens CSP protection against cross-site scripting (XSS) attacks.

Where this fits: security in SEO

Security issues erode both rankings and trust. HTTPS has been a ranking signal since 2014, and browsers actively warn users away from insecure or mixed-content pages — a warning interstitial is a 100% bounce rate. Missing security headers rarely block indexing, but they widen your attack surface, and a hacked site (injected spam, malicious redirects) can be removed from results entirely. Security is the SEO work you do so you never have to do recovery work.

Why csp allows unsafe-inline scripts hurts your rankings

The primary purpose of CSP is to prevent XSS attacks by controlling which scripts can execute. Using 'unsafe-inline' negates most of this protection, as attackers who find an injection point can execute arbitrary inline scripts. This leaves your site nearly as vulnerable as having no CSP at all.

This is a low-severity issue: a polish item. Fix it in batches during scheduled maintenance; the win is cumulative quality, not a step change.

How to fix it

Replace 'unsafe-inline' with nonce-based or hash-based script allowlisting. Generate a unique nonce for each page load and add it to both the CSP header and each inline script tag. Alternatively, move inline scripts to external files.

# Use nonces instead of unsafe-inline
Content-Security-Policy: script-src 'self' 'nonce-abc123'

<script nonce="abc123">/* your code */</script>

Security best practices

  • Serve everything over HTTPS and redirect HTTP with a single 301.
  • Send HSTS, X-Content-Type-Options, and a Content-Security-Policy on every response.
  • Eliminate mixed content — one insecure asset breaks the padlock.
  • Keep dependencies and CMS plugins patched; most site hacks are known-CVE exploits.
  • Monitor Search Console's security section — Google often knows you're hacked before you do.

The full library: SEO best practices, by category.

Frequently asked questions

What does "CSP allows unsafe-inline scripts" mean?

The Content-Security-Policy includes 'unsafe-inline' in the script-src directive, which significantly weakens CSP protection against cross-site scripting (XSS) attacks.

Why does csp allows unsafe-inline scripts matter for SEO?

The primary purpose of CSP is to prevent XSS attacks by controlling which scripts can execute. Using 'unsafe-inline' negates most of this protection, as attackers who find an injection point can execute arbitrary inline scripts. This leaves your site nearly as vulnerable as having no CSP at all.

How do I fix csp allows unsafe-inline scripts?

Replace 'unsafe-inline' with nonce-based or hash-based script allowlisting. Generate a unique nonce for each page load and add it to both the CSP header and each inline script tag. Alternatively, move inline scripts to external files.

How serious is this issue?

This is a low-severity issue: a polish item. Fix it in batches during scheduled maintenance; the win is cumulative quality, not a step change. It belongs to the security family of checks.

How do I find every page affected by this on my site?

Run a free Dr Urls audit: it crawls your site, detects csp allows unsafe-inline scripts on every affected page, shows example URLs, and generates a ready-to-use fix task. Re-scan after fixing to verify the issue is gone.

Does your site have this issue?

A free Dr Urls audit crawls your site, finds every page affected by csp allows unsafe-inline scripts, and hands you a ready-made fix task.

Check my site free

Related security guides