계: Encapsulation

캡슐화는 강력한 경계를 그리는 것입니다. 웹 브라우저에서는 사용자의 모바일 코드가 다른 모바일 코드에 의해 오용되지 않도록 하는 것을 의미합니다. 서버에서는 검증된 데이터와 검증되지 않은 데이터, 한 사용자의 데이터와 다른 사용자의 데이터, 데이터 사용자가 볼 수 있는 데이터와 볼 수 없는 데이터 간의 차별화를 의미할 수 있습니다.

HTML5: Misconfigured Content Security Policy

Abstract
CSP를 잘못 구성하면 응용 프로그램이 cross-site scripting, cross-frame scripting, cross-site request forgery를 포함한 클라이언트 쪽 위협에 노출될 수 있습니다.
Explanation
CSP(Content Security Policy)는 웹 브라우저에서 렌더링될 때 사이트에서 콘텐트를 로드하거나 연결을 시작할 수 있도록 허용된 도메인을 지정하는, 선언적 보안 헤더입니다. CSP는 코드의 허용 목록 검사 및 입력 확인 외에 Cross-Site Scripting, 클릭재킹(Clickjacking), Cross-Origin 접근 등의 중요한 취약점을 차단하기 위한 추가 보안 계층 역할을 합니다. 하지만 헤더를 잘못 구성하면 이러한 추가 보안 계층이 형성되지 않습니다. 정책은 15개의 지정자를 사용하여 정의하는데, 이 가운데 다음 8개는 리소스 접근을 제어합니다. script-src, img-src, object-src, style_src, font-src, media-src, frame-src, connect-src.

이러한 각 지정자는 사이트가 해당 지정자에서 관여하는 기능에 접근할 수 있는 도메인을 지정하는 값으로 소스 목록을 사용합니다. 개발자는 전체 또는 일부 소스를 나타내기 위해 와일드카드인 *를 사용할 수도 있습니다. 지정자를 반드시 사용해야 하는 것은 아닙니다. 브라우저는 목록에 나열되지 않은 지정자에 대해 모든 소스를 허용하기도 하고 선택적 default-src 지정자에서 값을 파생하기도 합니다. 또한, 이 헤더의 사양은 시간이 지남에 따라 발전해 왔습니다. Firefox(버전 23까지)와 IE(버전 10까지)에서는 X-Content-Security-Policy로 구현되어 있었으며 Chrome(버전 25까지)에서는 X-Webkit-CSP로 구현되어 있었습니다. 하지만 이제는 새 표준 이름인 Content Security Policy를 사용하기 위해 두 이름 모두 더 이상 사용되지 않습니다. 지정자의 수, 더 이상 사용되지 않는 2개의 대체 이름, 그리고 단일 헤더에서 여러 번 나타나는 동일한 헤더와 반복되는 지정자가 처리되는 방식을 감안하면 개발자가 이 헤더를 잘못 구성할 확률이 높습니다.

다음과 같은 구성 오류 시나리오를 살펴보십시오.

- unsafe-inline 또는 unsafe-eval이 포함된 지정자는 CSP를 사용하는 목적을 무효화합니다.
- script-src 지정자가 설정되어 있지만 nonce 스크립트는 구성되어 있지 않습니다.
- frame-src가 설정되어 있지만 sandbox는 구성되어 있지 않습니다.
- 동일한 응답에서 이 헤더의 여러 인스턴스가 허용됩니다. 개발 팀과 보안 팀이 모두 헤더를 설정한 상황에서 어느 한 팀이 더 이상 사용되지 않는 이름 중 하나를 사용할 수도 있습니다. 최신 이름(즉, Content Security Policy)이 지정된 헤더가 없는 경우에는 더 이상 사용되지 않는 헤더가 허용되지만 이름이 content-security-header로 지정된 정책이 있는 경우에는 이러한 헤더가 무시됩니다. 이전 버전에서는 더 이상 사용되지 않는 이름만 인식하므로 원하는 지원 수준을 확보하려면 응답에 포함된 동일한 정책에 3개의 이름이 모두 지정되어 있어야 합니다.
- 헤더의 동일한 인스턴스에서 지정자가 반복되는 경우 이후에 사용되는 지정자는 모두 무시됩니다.

예제 1: 다음 django-csp 구성에서는 안전하지 않은 unsafe-inlineunsafe-eval 지정자를 사용하여 인라인 스크립트 및 코드 평가를 허용합니다.


...
MIDDLEWARE_CLASSES = (
...
'csp.middleware.CSPMiddleware',
...
)
...
CSP_DEFAULT_SRC = ("'self'", "'unsafe-inline'", "'unsafe-eval'", 'cdn.example.net')
...
References
[1] OWASP Content Security Policy
[2] W3C Content Security Policy 1.1
[3] Mozilla django-csp
[4] Standards Mapping - CIS Azure Kubernetes Service Benchmark 2
[5] Standards Mapping - CIS Microsoft Azure Foundations Benchmark partial
[6] Standards Mapping - CIS Amazon Elastic Kubernetes Service Benchmark 5
[7] Standards Mapping - CIS Amazon Web Services Foundations Benchmark 1
[8] Standards Mapping - CIS Google Kubernetes Engine Benchmark integrity
[9] Standards Mapping - Common Weakness Enumeration CWE ID 942, CWE ID 1173
[10] Standards Mapping - Common Weakness Enumeration Top 25 2019 [3] CWE ID 020
[11] Standards Mapping - Common Weakness Enumeration Top 25 2020 [3] CWE ID 020
[12] Standards Mapping - Common Weakness Enumeration Top 25 2021 [4] CWE ID 020
[13] Standards Mapping - Common Weakness Enumeration Top 25 2022 [4] CWE ID 020
[14] Standards Mapping - Common Weakness Enumeration Top 25 2023 [6] CWE ID 020, [24] CWE ID 863
[15] Standards Mapping - DISA Control Correlation Identifier Version 2 CCI-001368, CCI-001414
[16] Standards Mapping - General Data Protection Regulation (GDPR) Indirect Access to Sensitive Data
[17] Standards Mapping - NIST Special Publication 800-53 Revision 4 AC-4 Information Flow Enforcement (P1)
[18] Standards Mapping - NIST Special Publication 800-53 Revision 5 AC-4 Information Flow Enforcement
[19] Standards Mapping - OWASP Top 10 2010 A6 Security Misconfiguration
[20] Standards Mapping - OWASP Top 10 2013 A5 Security Misconfiguration
[21] Standards Mapping - OWASP Top 10 2017 A6 Security Misconfiguration
[22] Standards Mapping - OWASP Top 10 2021 A05 Security Misconfiguration
[23] Standards Mapping - OWASP Application Security Verification Standard 4.0 5.1.3 Input Validation Requirements (L1 L2 L3), 5.1.4 Input Validation Requirements (L1 L2 L3), 14.4.6 HTTP Security Headers Requirements (L1 L2 L3), 14.5.3 Validate HTTP Request Header Requirements (L1 L2 L3)
[24] Standards Mapping - OWASP Mobile 2014 M1 Weak Server Side Controls
[25] Standards Mapping - OWASP Mobile 2024 M8 Security Misconfiguration
[26] Standards Mapping - Payment Card Industry Data Security Standard Version 1.1 Requirement 6.5.10
[27] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2 Requirement 6.5.6
[28] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2.1 Requirement 6.5.6
[29] Standards Mapping - Payment Card Industry Data Security Standard Version 3.1 Requirement 6.5.6
[30] Standards Mapping - Payment Card Industry Data Security Standard Version 4.0 Requirement 6.2.4
[31] Standards Mapping - Payment Card Industry Software Security Framework 1.0 Control Objective 4.2 - Critical Asset Protection
[32] Standards Mapping - Payment Card Industry Software Security Framework 1.1 Control Objective 4.2 - Critical Asset Protection
[33] Standards Mapping - Payment Card Industry Software Security Framework 1.2 Control Objective 4.2 - Critical Asset Protection
[34] Standards Mapping - Security Technical Implementation Guide Version 4.1 APSC-DV-000480 CAT II, APSC-DV-000490 CAT II
[35] Standards Mapping - Security Technical Implementation Guide Version 4.2 APSC-DV-000480 CAT II, APSC-DV-000490 CAT II
[36] Standards Mapping - Security Technical Implementation Guide Version 4.3 APSC-DV-000480 CAT II, APSC-DV-000490 CAT II
[37] Standards Mapping - Security Technical Implementation Guide Version 4.4 APSC-DV-000480 CAT II, APSC-DV-000490 CAT II
[38] Standards Mapping - Security Technical Implementation Guide Version 4.5 APSC-DV-000480 CAT II, APSC-DV-000490 CAT II
[39] Standards Mapping - Security Technical Implementation Guide Version 4.6 APSC-DV-000480 CAT II, APSC-DV-000490 CAT II
[40] Standards Mapping - Security Technical Implementation Guide Version 4.7 APSC-DV-000480 CAT II, APSC-DV-000490 CAT II
[41] Standards Mapping - Security Technical Implementation Guide Version 4.8 APSC-DV-000480 CAT II, APSC-DV-000490 CAT II
[42] Standards Mapping - Security Technical Implementation Guide Version 4.9 APSC-DV-000480 CAT II, APSC-DV-000490 CAT II
[43] Standards Mapping - Security Technical Implementation Guide Version 4.10 APSC-DV-000480 CAT II, APSC-DV-000490 CAT II
[44] Standards Mapping - Security Technical Implementation Guide Version 4.11 APSC-DV-000480 CAT II, APSC-DV-000490 CAT II
[45] Standards Mapping - Security Technical Implementation Guide Version 5.1 APSC-DV-000480 CAT II, APSC-DV-000490 CAT II
[46] Standards Mapping - Security Technical Implementation Guide Version 5.2 APSC-DV-000480 CAT II, APSC-DV-000490 CAT II
[47] Standards Mapping - Security Technical Implementation Guide Version 5.3 APSC-DV-000480 CAT II, APSC-DV-000490 CAT II
[48] Standards Mapping - Web Application Security Consortium Version 2.00 Application Misconfiguration (WASC-15)
desc.structural.python.html5_misconfigured_content_security_policy