Skip to main content

Overview

CSP controls which resources the browser can load. Misconfigured CSP allows XSS, data exfiltration, and script injection despite having a policy in place.

Check CSP

Browser DevTools

Console shows CSP violations when blocked.

Online Analyzer


Key Directives

default-src does NOT cover frame-ancestors, form-action, or base-uri — these must be set explicitly.
CSP via <meta> tag cannot enforce frame-ancestors, sandbox, or reporting directives. Use HTTP header instead.

Source Values

'unsafe-inline' is ignored when a nonce or hash is present (CSP2+).

Dangerous Configurations

unsafe-inline (XSS Possible)

Inline <script> tags and event handlers work:

unsafe-eval

Wildcard

Load scripts from any domain.

Missing Directives

No script-src → falls back to default-src. No default-src → no restriction.

Bypass Techniques

JSONP Endpoints

If CSP allows a domain with JSONP:

CDN / Whitelisted Domain

If CSP allows a CDN you can upload to:

Angular + unsafe-eval

base-uri Missing

Nonce Reuse / Prediction

If nonce is static or predictable:

object-src Missing

Data URI (If data: Allowed)

Exfiltration via Allowed Destinations

If connect-src or img-src allows external:

CSP Report-Only

Logs violations but does NOT block. Not a security control.

Quick Reference


Sources