Envoy Gateway용 App and API Protection 활성화
Envoy Gateway에서 관리하는 트래픽에 대해 Datadog App and API Protection을 활성화하여 인프라 에지에서 트래픽을 검사하고 보호할 수 있습니다.
전제 조건
Kubernetes용 App and API Protection을 사용한 자동화된 구성
자동화된 구성은 보안 프로세서 배포 및 EnvoyExtensionPolicy 생성을 처리합니다. 대부분의 사용자에게 권장되는 방식입니다.
설정
보안 프로세서를 아래 Datadog 보안 프로세서 서비스 배포에 표시된 배포 매니페스트를 사용하여 배포합니다.
자동 구성을 Datadog Operator 또는 Helm을 사용하여 활성화합니다.
DatadogAgent 리소스에 주석을 추가합니다. 서비스 이름 주석은 필수이며 보안 프로세서 서비스와 일치해야 합니다.
apiVersion: datadoghq.com/v2alpha1
kind: DatadogAgent
metadata:
name: datadog
annotations:
agent.datadoghq.com/appsec.injector.enabled: "true"
agent.datadoghq.com/appsec.injector.processor.service.name: "datadog-aap-extproc-service" # Required
agent.datadoghq.com/appsec.injector.processor.service.namespace: "datadog"
spec:
override:
clusterAgent:
env:
- name: DD_CLUSTER_AGENT_APPSEC_INJECTOR_MODE
value: "external"
다음 구성을 적용합니다.
kubectl apply -f datadog-agent.yaml
다음 내용을 values.yaml에 추가합니다.
datadog:
appsec:
injector:
enabled: true
mode: "external"
processor:
service:
name: datadog-aap-extproc-service # Required: must match your security processor service name
namespace: datadog # Must match the namespace where the service is deployed
Datadog Helm 차트를 설치하거나 업그레이드합니다.
helm upgrade -i datadog-agent datadog/datadog -f values.yaml
이를 활성화하면 Datadog Cluster Agent는 다음을 수행합니다.
- Envoy Gateway 설치를 감지합니다
- 각 Gateway에 대해
EnvoyExtensionPolicy 리소스를 생성합니다 - 보안 프로세서로 트래픽을 라우팅하도록 정책을 구성합니다
생성된 정책을 확인하여 구성을 검증합니다.
kubectl get envoyextensionpolicy -A
구성 옵션 및 문제 해결에 대한 내용은 Kubernetes용 App and API Protection를 참조하세요.
수동 구성(대안)
특정 게이트웨이를 세부적으로 제어하려면 수동 설정을 사용하세요.
- 클러스터에 Datadog Security Processor 서비스를 배포합니다.
- 해당 서비스를 가리키는
EnvoyExtensionPolicy를 구성합니다.
1단계: Datadog 보안 프로세서 서비스 배포
이 gRPC 서버는 App and API Protection 분석을 위해 Envoy로부터 요청과 응답을 수신합니다.
Envoy Gateway에서 액세스할 수 있는 네임스페이스에 배포하세요. Docker 이미지는 Datadog Go tracer GitHub 레지스트리에 있습니다.
매니페스트 예(datadog-aap-extproc-service.yaml):
apiVersion: apps/v1
kind: Deployment
metadata:
name: datadog-aap-extproc-deployment
namespace: <your-preferred-namespace> # Change to your preferred namespace, ensure it's resolvable by the Envoy Gateway
labels:
app: datadog-aap-extproc
spec:
replicas: 1 # Adjust replica count based on your load
selector:
matchLabels:
app: datadog-aap-extproc
template:
metadata:
labels:
app: datadog-aap-extproc
spec:
containers:
- name: datadog-aap-extproc-container
image: ghcr.io/datadog/dd-trace-go/service-extensions-callout:v2.4.0 # Replace with the latest released version
ports:
- name: grpc
containerPort: 443 # Default gRPC port for the security processor
- name: health
containerPort: 80 # Default health check port
env:
# Optional: Agent Configuration
# If you enabled the Cluster Agent Admission Controller, you can skip this section as the Agent host information is automatically injected.
# Otherwise, configure the address of your Datadog Agent for the security processor
- name: DD_AGENT_HOST
value: "<your-datadog-agent-service>.<your-datadog-agent-namespace>.svc.cluster.local"
- name: DD_TRACE_AGENT_PORT # Optional if your Agent's trace port is the default 8126
value: "8126"
# Disable TLS for communication between Envoy Gateway and the security processor. Default is true.
# Cannot be enabled for now
- name: DD_SERVICE_EXTENSION_TLS
value: "false"
readinessProbe:
httpGet:
path: /
port: health
initialDelaySeconds: 5
periodSeconds: 10
livenessProbe:
httpGet:
path: /
port: health
initialDelaySeconds: 15
periodSeconds: 20
---
apiVersion: v1
kind: Service
metadata:
name: datadog-aap-extproc-service # This name will be used in the EnvoyExtensionPolicy configuration
namespace: <your-preferred-namespace> # Change to your preferred namespace, ensure it's resolvable by the Envoy Gateway
labels:
app: datadog-aap-extproc
spec:
ports:
- name: grpc
port: 443
targetPort: grpc
protocol: TCP
selector:
app: datadog-aap-extproc
type: ClusterIP
보안 프로세서 구성 옵션
Datadog Security Processor는 다음과 같은 설정을 제공합니다.
| 환경 변수 | 기본값 | 설명 |
|---|
DD_SERVICE_EXTENSION_HOST | 0.0.0.0 | gRPC 서버 수신 주소입니다. |
DD_SERVICE_EXTENSION_PORT | 443 | gRPC 서버 포트입니다. |
DD_SERVICE_EXTENSION_HEALTHCHECK_PORT | 80 | 서비스 상태 점검을 위한 HTTP 서버 포트입니다. |
DD_SERVICE_EXTENSION_TLS | true | gRPC TLS 계층을 활성화합니다. |
DD_SERVICE_EXTENSION_TLS_KEY_FILE | localhost.key | 기본 gRPC TLS 계층 키를 변경합니다. |
DD_SERVICE_EXTENSION_TLS_CERT_FILE | localhost.crt | 기본 gRPC TLS 계층 인증서를 변경합니다. |
DD_APPSEC_BODY_PARSING_SIZE_LIMIT | 10485760 | 처리할 본문의 최대 크기(바이트)입니다. 0으로 설정하면 본문이 처리되지 않습니다. 권장 값은 10485760(10MB)입니다. (본문 처리를 완전히 활성화하려면 External Processing 필터 구성에서 allowModeOverride 옵션도 설정해야 합니다.) |
DD_SERVICE | serviceextensions | Datadog UI에 표시되는 서비스 이름입니다. |
다음 환경 변수를 사용하여 보안 프로세서에서 Datadog Agent로의 연결을 구성하세요.
| 환경 변수 | 기본값 | 설명 |
|---|
DD_AGENT_HOST | localhost | Datadog Agent의 호스트 이름 또는 IP입니다. |
DD_TRACE_AGENT_PORT | 8126 | 트레이스 수집용 Datadog Agent 포트입니다. |
보안 프로세서는 Datadog Go Tracer를 기반으로 구축되었으며 해당 환경 변수를 모두 상속합니다. Go SDK 구성 및 App and API Protection 라이브러리 구성을 참조하세요.
Datadog 보안 프로세서는 Datadog Go 트레이서를 기반으로 구축되었으므로 일반적으로 트레이서와 동일한 릴리스 프로세스를 따르며, Docker 이미지에는 해당 트레이서 버전 태그가 지정됩니다(예: v2.2.2). 경우에 따라 공식 트레이서 릴리스 사이에 초기 릴리스 버전이 게시될 수 있으며, 해당 이미지에는 다음과 같은 접미사가 태그로 지정됩니다. -docker.1.
EnvoyExtensionPolicy를 사용하여 Envoy Gateway가 Datadog 보안 프로세서를 호출하도록 지시합니다. 정책을 Gateway 또는 특정 HTTPRoute/GRPCRoute 리소스에 연결할 수 있습니다.
이렇게 하면 선택한 Gateway의 모든 트래픽이 Datadog 보안 프로세서로 전송됩니다. 매니페스트 예(datadog-aap-extproc-eep.yaml):
apiVersion: gateway.envoyproxy.io/v1alpha1
kind: EnvoyExtensionPolicy
metadata:
name: datadog-aap-extproc-eep
namespace: <your-preferred-namespace> # same namespace as the Gateway
spec:
targetRefs:
# Target the entire Gateway
- group: gateway.networking.k8s.io
kind: Gateway
name: <your-gateway-name> # update to your specific gateway name
# Target specific HTTPRoutes/GRPCRoutes
#- group: gateway.networking.k8s.io
# kind: HTTPRoute
# name: <your-http-route-name>
extProc:
- backendRefs:
- group: ""
kind: Service
name: datadog-aap-extproc-service
namespace: <your-preferred-namespace> # namespace of the security processor Service
port: 443
# Optional: Enable fail open mode. Default is false.
# Normally, if the security processor fails or times out, the filter fails and Envoy
# returns a 5xx error to the downstream client. Setting this to true allows requests
# to continue without error if a failure occurs.
failOpen: true
# Optional: Set a timeout by processing message. Default is 200ms.
# There is a maxium of 2 messages per requests with headers only and 4 messages maximum
# with body processing enabled.
# Note: This timeout also includes the data communication between Envoy and the security processor.
# The timeout should be adjusted to accommodate the additional possible processing time.
# Larger payloads will require a longer timeout.
messageTimeout: 200ms
processingMode:
# The security processor can dynamically override the processing mode as needed, instructing
# Envoy to forward request and response bodies to the security processor.
allowModeOverride: true
# Only enable the request and response header modes by default.
request: {}
response: {}
교차 네임스페이스 참조
보안 프로세서 Service가 정책과 다른 네임스페이스에 있는 경우, 프로세서의 네임스페이스에 ReferenceGrant를 추가합니다. 예를 들어, datadog-aap-eep-rg.yaml과 같은 매니페스트를 사용하여 이 작업을 수행할 수 있습니다.
apiVersion: gateway.networking.k8s.io/v1beta1
kind: ReferenceGrant
metadata:
name: datadog-aap-eep-rg
namespace: <your-extproc-namespace> # namespace of the security processor Service
spec:
from:
- group: gateway.envoyproxy.io
kind: EnvoyExtensionPolicy
namespace: <your-policy-namespace> # namespace of the EnvoyExtensionPolicy (and the Gateway)
to:
- group: ""
kind: Service
name: datadog-aap-extproc-service
3단계: 유효성 검사
정책을 적용한 후, 대상 게이트웨이/경로를 통과하는 트래픽은 App and API Protection에 의해 검사됩니다.
After this configuration is complete, the library collects security data from your application and sends it to the Agent. The Agent sends the data to Datadog, where out-of-the-box detection rules flag attacker techniques and potential misconfigurations so you can take steps to remediate.
To see App and API Protection threat detection in action, send known attack patterns to your application. For example, trigger the Security Scanner Detected rule by running a file that contains the following curl script:
for ((i=1;i<=250;i++));
do
# Target existing service's routes
curl https://your-application-url/existing-route -A dd-test-scanner-log;
# Target non existing service's routes
curl https://your-application-url/non-existing-route -A dd-test-scanner-log;
done
Note: The dd-test-scanner-log value is supported in the most recent releases.
A few minutes after you enable your application and send known attack patterns to it, threat information appears in the Application Signals Explorer and vulnerability information appears in the Vulnerabilities explorer.
제한 사항
관측 가능성 모드(비동기 분석)는 Envoy Gateway에서 사용할 수 없습니다.
Envoy Gateway 통합 호환성에 대한 자세한 내용은 Envoy Gateway 통합 호환성 페이지를 참조하세요.
추가 자료