Envoy で App and API Protection を有効にする
This product is not supported for your selected
Datadog site. (
).
Envoy プロキシで App and API Protection を有効にできます。Datadog Envoy インテグレーションは、脅威の検出とブロックをサポートしています。
前提条件
脅威検知の有効化
始める
App and API Protection Envoy インテグレーションは、Envoy 外部処理フィルターを使用します。
Datadog External Processor Docker イメージを使用して新しいコンテナをデプロイします。このイメージは Datadog GitHub Registry で入手できます。
このサービスは、Envoy がリクエストとレスポンスを App and API Protection で分析させるために通信を行う gRPC サーバーです。
Datadog External Processor は、いくつかの設定を公開しています。
| 環境変数 | デフォルト値 | 説明 |
|---|
DD_SERVICE_EXTENSION_HOST | 0.0.0.0 | gRPC サーバーのリスニングアドレス。 |
DD_SERVICE_EXTENSION_PORT | 443 | gRPC サーバーのポート。 |
DD_SERVICE_EXTENSION_HEALTHCHECK_PORT | 80 | ヘルスチェック用の HTTP サーバーポート。 |
DD_APPSEC_BODY_PARSING_SIZE_LIMIT | 0 | 処理されるボディの最大サイズ(バイト単位)。0 に設定されている場合、ボディは処理されません。推奨値は 10000000 (10MB) です。(ボディ処理を完全に有効にするには、External Processing フィルター設定で allow_mode_override オプションも設定する必要があります) |
DD_SERVICE_EXTENSION_OBSERVABILITY_MODE | false | 非同期分析を有効にします。これにより、ブロッキング機能も無効になります。(オブザーバビリティモードを完全に有効にするには、このオプションを外部処理フィルターの構成でも設定する必要があります) |
DD_SERVICE | serviceextensions | Datadog UI に表示されるサービス名。 |
以下の環境変数を使用して、外部プロセッサからトレースを受信するように Datadog Agent を構成してください。
| 環境変数 | デフォルト値 | 説明 |
|---|
DD_AGENT_HOST | localhost | Datadog Agent のホスト名または IP。 |
DD_TRACE_AGENT_PORT | 8126 | トレース収集用の Datadog Agent のポート。 |
Envoy 構成を更新して 外部処理フィルター を http_filters リストに追加し、対応する gRPC クラスターを clusters セクションで定義してください。たとえば、以下のとおりです。
HTTP フィルターセクション
http_filters:
# This filter should be the first filter in the filter chain
- name: envoy.filters.http.ext_proc
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.ext_proc.v3.ExternalProcessor
grpc_service:
envoy_grpc:
cluster_name: datadog_aap_ext_proc_cluster
## Mandatory: Correctly show the service as an Envoy proxy in the UI.
initial_metadata:
- key: x-datadog-envoy-integration
value: '1'
## A timeout configuration for the grpc connection exist but is not useful in our case.
## This timeout is for all the request lifetime. A timeout on the route is preferred.
#timeout: 0s
## Optional: Enable fail open mode. Default is false.
## Normally, if the external 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.
failure_mode_allow: true # It won't cause 5xx error if an error occurs.
## Mandatory: Only enable the request and response header modes.
## If you want to enable body processing, please see the section below.
processing_mode:
request_header_mode: SEND
response_header_mode: SEND
## Optional for headers analysis only but **mandatory** for body processing.
## The external processor can dynamically override the processing mode as needed instructing
## Envoy to forward request and response bodies to the external processor. Body processing is
## enabled when DD_APPSEC_BODY_PARSING_SIZE_LIMIT is set on the external processor container.
allow_mode_override: 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 external processor.
## Optional: When the body processing is enabled, the timeout should be adjusted to accommodate
## the additional possible processing time. Larger payloads will require a longer timeout.
#message_timeout: 200ms
## Optional: Enable asynchronous mode analysis. Default is false.
## This mode will disable all blocking capabilities. The external processor should also be
## configured with the DD_SERVICE_EXTENSION_OBSERVABILITY_MODE environment variable.
## Beware, there is no flow control implemented in Envoy
## (cf https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/filters/http/ext_proc/v3/ext_proc.proto#envoy-v3-api-field-extensions-filters-http-ext-proc-v3-externalprocessor-observability-mode)
#observability_mode: true
## Optional: When in asynchronous mode, the message_timeout is not used. This deferred
## timeout starts when the http request is finished, to let the External Processor
## process all processing messages. Default is 5s.
#deferred_close_timeout: 5s
# ... other filters
クラスターセクション
clusters:
# ... other clusters
- name: datadog_aap_ext_proc_cluster
type: STRICT_DNS
lb_policy: ROUND_ROBIN
http2_protocol_options: {}
transport_socket:
name: envoy.transport_sockets.tls
typed_config:
"@type": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext
sni: "localhost"
load_assignment:
cluster_name: datadog_aap_ext_proc_cluster
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: 12.0.0.1 # Replace with the host address of the Datadog External Processor docker image (configured in the next step)
port_value: 443
注: 提供されている構成例を注意深く読み、ご自身のインフラストラクチャーと環境に合わせて調整してください。利用可能なその他の構成オプションについては、Envoy 外部プロセッサのドキュメントを参照してください。
検証。
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.
Datadog Go Tracer と Envoy のインテグレーション
外部プロセッサは Datadog Go Tracer 上に構築されており、トレーサーのすべての環境変数を継承します。Go SDK の構成およびアプリと API 保護ライブラリの構成を参照してください。
注: Datadog 外部プロセッサは Datadog Go Tracer 上に構築されているため、通常はトレーサーと同じリリースプロセスに従い、その Docker イメージには対応するトレーサーのバージョンがタグ付けされます(例:v2.2.2).場合によっては、公式のトレーサーリリースの間に早期リリースバージョンが公開されることがあり、これらのイメージには次のようなサフィックスがタグ付けされます。 -docker.1.
制限事項
Envoy インテグレーションには、以下の制限があります。
- Datadog External Processor イメージバージョン
v2.2.2 以降を使用する場合、リクエストボディおよびレスポンスボディの検査がサポートされます。
Envoy インテグレーションの互換性に関する詳細については、Envoy インテグレーション互換性ページを参照してください。
参考資料