From application-security
Design and deploy Content-Security-Policy (CSP) to prevent XSS attacks and unauthorized resource loading.
How this skill is triggered — by the user, by Claude, or both
Slash command
/application-security:content-security-policyThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Design and deploy CSP to prevent XSS and unauthorized resource loading.
Design and deploy CSP to prevent XSS and unauthorized resource loading.
You are a senior security engineer implementing CSP for $ARGUMENTS. CSP is the browser's defense against XSS by controlling which scripts, styles, and resources can load. A well-designed CSP blocks inline scripts and restricts external resources to trusted domains, making XSS significantly harder to exploit.
default-src, script-src, style-src, img-src, font-src, connect-src, frame-src, form-action, base-uri'self' (same origin), 'none' (block all), domain whitelist, nonces (random tokens per request), hashes (SHA-256)report-uri or report-to for CSP violations; use to detect XSS attempts and policy issuesStart with Report-Only Mode:
Content-Security-Policy-Report-Only header firstreport-uri to collect violationsContent-Security-Policy header (report-only + enforcement can coexist)Design Base Policy:
default-src 'self' — allow same-origin resources by defaultscript-src 'self' — allow same-origin scripts only (no inline scripts)style-src 'self' — allow same-origin styles only (no inline styles)img-src 'self' data: https: — allow same-origin, data URIs, and HTTPS imagesfont-src 'self' — allow same-origin fonts onlyconnect-src 'self' — allow same-origin API calls onlyAllow Trusted External Resources:
script-src 'self' cdn.jsdelivr.netfont-src 'self' fonts.googleapis.com; style-src 'self' fonts.googleapis.comtrusted-cdn.com not *.example.com)Secure Inline Scripts & Styles:
<script nonce="abc123"> and CSP header
script-src 'nonce-abc123' — only that script with matching nonce executesscript-src 'sha256-hash' — only scripts matching hash execute'unsafe-inline' or 'unsafe-eval' unless absolutely necessary (defeats XSS protection)Monitor & Iterate:
default-src * or overly permissive policies; this provides no protection against XSS'unsafe-inline' to fix CSP violations; refactor code instead; inline scripts defeat CSP's purposenpx claudepluginhub sethdford/claude-skills --plugin security-application-securityRestricts what resources the browser may load or execute in a web application, reducing XSS risk. Useful for apps with user-generated content, third-party scripts, or inline JavaScript.
Audits HTTP security headers (CSP, HSTS, X-Frame-Options, Permissions-Policy), identifies overly permissive directives, and generates production-ready policies for web applications.
Implements secure frontend coding practices for XSS prevention, safe DOM manipulation, output sanitization, Content Security Policy, and client-side vulnerability fixes.