본문으로 건너뛰기
Skillpedia
보안75k · #2785

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가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/content-security-policy/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

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.

repo: thedaviddias/Front-End-Checklist

인기도

GitHub 스타
75k
순위
#2785
라이선스
MIT
업데이트
2026. 10. 31.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬