🧩

security-headers-csp

security-headers-csp · v
作者 workspace-templates 公开目录收录

简介

Adds a Content Security Policy and the other protective HTTP headers, starting in report-only mode so nothing breaks before you tighten it.

通过你的 Agent 添加

安装目录:security-headers-csp/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。

点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。

或者手动安装

Claude Code~/.claude/skills/security-headers-csp/
Codex CLI~/.codex/skills/security-headers-csp/
DeepSeek Harness~/.agents/skills/security-headers-csp/

包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可; 目录名不用换,也不要把包直接解压到 skills 根目录。 技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。

技能正文


name: security-headers-csp description: Adds a Content Security Policy and the other protective HTTP headers, starting in report-only mode so nothing breaks before you tighten it.

Security headers and CSP

Roll out in stages. Never enforce a new CSP before you have seen its reports.

Steps

  1. Inventory what the pages load: scripts, styles, fonts, images, frames, fetch and websocket targets, analytics and widgets. Note every inline script and style.
  2. Remove inline code where it is cheap. For what remains, use a per-response nonce (script-src 'nonce-...' 'strict-dynamic') or hashes. Do not rely on 'unsafe-inline' or 'unsafe-eval' for scripts.
  3. Draft the policy: default-src 'self', then explicit script-src, style-src, img-src, connect-src, font-src, plus object-src 'none', base-uri 'none', frame-ancestors 'self' and form-action 'self'.
  4. Ship it as Content-Security-Policy-Report-Only with a report-to endpoint or a log of violations. Run through the main user journeys and read the reports. Fix or allow each legitimate source narrowly. Wait for a representative period.
  5. Switch to enforcing Content-Security-Policy only when reports are clean. Keep a report-only copy of the next stricter version.
  6. Add the companions through the framework's middleware or server config:
    • Strict-Transport-Security: max-age=31536000; includeSubDomains (add preload only after confirming every subdomain serves HTTPS)
    • X-Content-Type-Options: nosniff
    • Referrer-Policy: strict-origin-when-cross-origin
    • Permissions-Policy turning off unused features
  7. Test with a header scanner and a browser console check.

Rules

  • Do not paste a policy found online; build it from what the pages actually load.
  • Keep policy in one place, in config.

Report

The policy, the sources allowed and why, where it is set, and the steps remaining to enforce it.

正文来自原始仓库, 版权归作者所有,许可:MIT。 权利人认为有不妥,可申请下架。

原始仓库

作者的项目地址:https://github.com/workspace-templates/ai-agent-templates

标签

没有标签

同类 Skill