content-security-policy
하는 일
이 스킬은 승인되지 않은 코드와 리소스를 막는 브라우저 규칙 집합인 콘텐츠 보안 정책(CSP)을 확인하고 만듭니다. 교차 사이트 스크립팅에 대한 추가 보호막을 원하는 개발자를 위한 스킬입니다.
사용하는 경우
- ✓사이트에 콘텐츠 보안 정책 헤더가 없을 때.
- ✓인라인 스크립트나 안전하지 않은 설정이 쓰이고 있을 때.
- ✓앱이 사용자가 제공한 HTML을 페이지에 삽입할 때.
스킬 링크
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/content-security-policy/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“사이트에 콘텐츠 보안 정책을 설정해 알 수 없는 스크립트를 막고, 강제하기 전에 테스트해 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
에이전트가 보고 전용 모드로 시작하는 정책을 제안하고, 인라인 스크립트에는 nonce나 해시를 쓰며, 안전하지 않은 설정을 피하고, 신뢰할 수 없는 HTML에는 살균 처리를 추가합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
Implement a content security policy
Content Security Policy prevents cross-site scripting (XSS), clickjacking, and data injection attacks by controlling which resources can be loaded and executed on your pages. It reduces blast radius, but it does not replace output encoding and sanitization.
Quick Reference
- Start with Content-Security-Policy-Report-Only to test without breaking your site
- Use nonces or hashes for inline scripts instead of unsafe-inline
- Avoid unsafe-eval unless absolutely necessary
- Set strict default-src then allow specific sources
- Monitor CSP reports to catch violations
- Sanitize untrusted HTML before rendering it into the DOM
- Use Trusted Types in larger apps as defense in depth for DOM XSS sinks
Check
Check if this website implements a Content Security Policy header and analyze its directives. Also review any use of innerHTML, dangerouslySetInnerHTML, HTML template injection, and Trusted Types enforcement for large applications.
Fix
Implement a strict Content Security Policy to prevent XSS attacks and control resource loading. Sanitize untrusted HTML before rendering and add Trusted Types enforcement where the application has enough DOM injection surface to benefit from it.
Explain
Explain how CSP provides a security layer that helps detect and mitigate XSS and data injection attacks, and why sanitization is still required before rendering untrusted HTML.
Code Review
Review server config, headers, forms, and integration points related to Implement a content security policy. Flag exact responses, cookies, or browser behaviors that violate the rule, and verify them against the effective production-like response. Inspect HTML injection sinks and note whether Trusted Types or sanitization protects them.
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.
Rule page: https://frontendchecklist.io/rules/security/content-security-policy
자주 묻는 질문
정책을 바로 강제 적용해야 하나요?
아니요. 사이트를 깨뜨리지 않고 테스트하려면 보고 전용 모드로 시작하라고 스킬은 권장합니다.
콘텐츠 보안 정책이 살균 처리를 대신하나요?
아니요. 공격의 영향을 줄여 주지만, 출력 인코딩과 살균 처리를 대체하지는 않는다고 스킬은 설명합니다.
Trusted Types는 무엇인가요?
HTML을 페이지에 삽입하는 큰 앱을 위한 추가 방어 장치라고 스킬은 설명합니다.
상세 정보
작성자의 원본 설명
Use when reviewing headers, forms, cookies, or third-party integrations related to Implement a content security policy. Validate the effective browser and HTTP behavior in a production-like environment.
인기도
- GitHub 스타
- 75k
- 순위
- #2785
- 라이선스
- MIT
- 업데이트
- 2026. 10. 31.
댓글
- …
이 저장소의 다른 스킬
frontendchecklist
75k명령줄 도구를 사용해 380개가 넘는 규칙으로 프런트엔드 코드와 실시간 페이지를 접근성, 속도, SEO, 보안 측면에서 점검합니다.
frontend-checklist-global
75kFront-End Checklist의 386개 규칙 전체로 프런트엔드 프로젝트를 감사하고, 발견한 문제마다 구체적인 해결 방법을 제시합니다.
404-page
75k없는 페이지 화면에 도움이 되는 링크가 있고 실제 404 상태 코드를 반환하는지 확인해, 길을 잃은 방문자를 돕습니다.
about-page
75k사이트를 운영하는 사람을 설명하는 명확한 소개 페이지가 있는지 검토해, 방문자와 검색 엔진의 신뢰를 높입니다.