본문 바로가기
WIKI 기술 지식 베이스

CSP rules

원문 보기 위키 갱신

출처: 문서

본문

CSP 규칙

2.13에 도입됨 {: .label .label-purple }

Content Security Policy(CSP)는 교차 사이트 스크립팅(XSS), 클릭재킹 등 각종 코드 인젝션 공격을 막기 위한 보안 표준이에요. OpenSearch Dashboards는 페이지가 로드될 때마다 Content-Security-Policy 응답 헤더를 보내서 CSP를 강제해요.

설정

CSP를 설정하려면 opensearch_dashboards.yml에 다음 키를 추가하세요. allowed*Sources 값은 모두 해당 디렉티브의 엄격한 정책 기본값에 추가돼요:

# Enable strict CSP enforcement.
csp.enable: true

# Append trusted origins to frame-ancestors (controls iframe embedding).
csp.allowedFrameAncestorSources: ["https://portal.example.com"]

# Append trusted origins to connect-src (fetch/XHR calls from the browser).
csp.allowedConnectSources: ["https://api.example.com"]

# Append trusted origins to img-src.
csp.allowedImgSources: ["https://cdn.example.com"]

# Relax specific directives back to their non-strict defaults
# while keeping the rest of the policy strict.
csp.loosenCspDirectives: ["style-src"]

{% include copy.html %}

그런 다음 변경 사항이 적용되도록 OpenSearch를 재시작하세요.

CSP 설정

다음 표에서 사용할 수 있는 CSP 설정을 설명해요.

설정 타입 설명
csp.enable Boolean 엄격한 CSP 강제를 활성화해요. 기본값은 true예요.
csp.allowedFrameAncestorSources Array of strings frame-ancestors 디렉티브에 추가되는 오리진이에요. Dashboards를 iframe에 임베드할 수 있게 허용할 때 사용해요.
csp.allowedConnectSources Array of strings connect-src에 추가되는 오리진이에요. 브라우저가 외부 엔드포인트(fetch, XHR, WebSocket)로 보내는 요청을 허용할 때 사용해요.
csp.allowedImgSources Array of strings img-src에 추가되는 오리진이에요. 외부 CDN이나 타일 서버의 이미지를 허용할 때 사용해요.
csp.loosenCspDirectives Array of strings 비엄격 기본값으로 되돌려 완화할 디렉티브 이름이에요.

사이트 임베딩 활성화

OpenSearch Dashboards를 다른 사이트의 iframe에 임베드하려면 해당 사이트를 csp.allowedFrameAncestorSources에 추가하세요:

csp.allowedFrameAncestorSources: ["https://portal.example.com"]

{% include copy.html %}

그러면 응답 헤더에 다음과 같은 frame-ancestors 디렉티브가 만들어져요:

frame-ancestors 'self' https://portal.example.com

리포트 전용 모드

새 CSP 정책을 강제하지 않고 감사하려면 Content-Security-Policy-Report-Only 헤더를 활성화하세요. 위반 내용은 보고되지만 콘텐츠는 차단되지 않아요:

csp-report-only.isEmitting: true
csp-report-only.allowedFrameAncestorSources: ["https://portal.example.com"]
csp-report-only.allowedConnectSources: ["https://api.example.com"]
csp-report-only.allowedImgSources: ["https://cdn.example.com"]

{% include copy.html %}

applicationConfig를 사용한 CSP 규칙 설정(지원 중단)

지원 중단. OpenSearch Dashboards 2.13--2.16에서는 applicationConfig와 cspHandler 플러그인을 사용해 REST API를 통해 frame-ancestors 디렉티브를 동적으로 설정할 수 있었어요. 이 방식은 이제 동작하지 않아요. 대신 csp.* 설정을 사용하세요.

더 알아보기 (Learn more)