100% 브라우저 메모리 연산 • 서버 로그 수집 제로 • 즉각적인 실행
Curious Techie개발자 툴박스
Web SecurityW3C Content Security Policy Level 3Verified Terminology

콘텐츠 보안 정책 (Content Security Policy: CSP)

핵심 요약 답변

웹 페이지에서 로드 및 실행할 수 있는 리소스(스크립트, 스타일, 이미지)의 신뢰할 수 있는 출처를 지정하여 XSS 공격을 방어하는 보안 표준.

Entity Relationships (GEO Conceptual Hierarchy)

Taxonomy Model
Relational Knowledge Graph Sequence
CSP→
XSS 방어→
암호화 논스→
script-src 지시문→
리소스 격리
CSP
•>XSS 방어
•>암호화 논스
•>script-src 지시문
•>리소스 격리

Technical Explanation & Operational Mechanics

CSP는 Content-Security-Policy HTTP 헤더를 통해 브라우저에 지시하는 보안 계층입니다. 허용되지 않은 인라인 스크립트 실행과 eval() 호출을 차단하고, 암호화 논스(nonce)를 검증하여 악의적인 XSS 인젝션을 무력화합니다.

Technical Example & Practical Implementation

암호화 논스(Nonce) 기반의 엄격한 CSP 설정

브라우저 단에서 임의의 외부 스크립트 실행을 완벽히 차단하는 헤더 구성

Content-Security-Policy: 
  default-src 'self';
  script-src 'self' 'nonce-rAnd0m12345' https://cdn.trusted.com;
  style-src 'self' 'unsafe-inline';
  img-src 'self' data: https://images.unsplash.com;
  connect-src 'self' https://api.curious-techie.com;
  font-src 'self' https://fonts.gstatic.com;
  object-src 'none';
  base-uri 'self';
  frame-ancestors 'none';
  upgrade-insecure-requests;