CSP:Content Security Policy

콘텐츠 보안정책

문서 (또는 웹 페이지)의 보안을 강화하기 위해 사용하는 HTTP 응답 헤더의 이름입니다. 

Content-Security-Policy 헤더를 사용하면 JavaScript, CSS 또는 브라우저가로드하는 거의 모든 리소스와 같은 리소스를 제한 할 수 있습니다.

 

쉽게말해 브라우저는 사이트에 접속하면 소스에 관계없이 페이지에서 요청하는 코드는 무엇이든지 다운로드하여 우리에게 보여준다. 그렇다보니 악성코드도 다운받게 되는데 이를 방지하기위해 우리가 신뢰하는사이트, 가져올 콘텐츠를 미리 정의 하는것을 말한다.

예시

 

Content-Security-Policy: script-src 'self' https://apis.google.com

 

apis.google.com에서 제공되는 자바스크립트를 충실히 다운로드하고 실행합니다.

하지만 브라우저가 다른 소스에서 스크립트를 로드하는 대신 그냥 오류를 발생시킵니다. 

 

 

Content-Security-Policy: default-src 'self' 'unsafe-inline' https://apis.google.com

 

default-src는 아래 지시문을 제외하고는 모두 적용됩니다.

  • base-uri
  • form-action
  • frame-ancestors
  • plugin-types
  • report-uri
  • sandbox

 

src 옵션 설정

  • http://www.test.com,example.com, example.com:443 ... 접근 허용 도메인
  • 'none'은 모든것을 차단(잠금)
  • 'self' 는 현재 도메인만 허용
  • 'unsafe-inline'은 소스코드 내 인라인 자바스크립트 및 CSS를 허용
  • 'nonce-암호화된문자'은 인라인 자바스크립트 및 CSS를 허용 (아래에서 설명)

 

 

 

출처:

부족하신분은 아래 출처들을 꼭 읽어보세요.

 

CSP 적용시키는 방법등 쉬운 예시

https://simjaejin.tistory.com/31

 

CSP 보안설정

콘텐츠 보안 정책 (CSP) CSP (Content-Security-Policy) : 이 정책은 Mozilla가 개발 한 표준으로, 실행 시점 인 브라우저에서 XSS (Cross Site Scripting) 공격을 막는 것을 목표로합니다. CSP는 인라인 스크립트..

simjaejin.tistory.com

 

CSP 개념 정리

https://developers.google.com/web/fundamentals/security/csp?hl=ko

 

Content-Security-Policy Header ⟶ CSP Reference & Examples

Content-Security-Policy is the name of a HTTP response header that modern browsers use to enhance the security of the document (or web page). The Content-Security-Policy header allows you to restrict how resources such as JavaScript, CSS, or pretty much an

content-security-policy.com

 

CSP 지시어

https://content-security-policy.com/#source_list

 

Content-Security-Policy Header ⟶ CSP Reference & Examples

Content-Security-Policy is the name of a HTTP response header that modern browsers use to enhance the security of the document (or web page). The Content-Security-Policy header allows you to restrict how resources such as JavaScript, CSS, or pretty much an

content-security-policy.com

 

 

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함