Design and deploy Content-Security-Policy (CSP) to prevent XSS attacks and unauthorized resource loading.
From application-securitynpx claudepluginhub sethdford/claude-skills --plugin security-application-securityThis skill uses the workspace's default tool permissions.
Designs and optimizes AI agent action spaces, tool definitions, observation formats, error recovery, and context for higher task completion rates.
Enables AI agents to execute x402 payments with per-task budgets, spending controls, and non-custodial wallets via MCP tools. Use when agents pay for APIs, services, or other agents.
Compares coding agents like Claude Code and Aider on custom YAML-defined codebase tasks using git worktrees, measuring pass rate, cost, time, and consistency.
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 purpose