This product is not supported for your selected Datadog site. ().

Envoy Gateway によって管理されるトラフィックに対して Datadog App and API Protection を有効にすることで、インフラストラクチャーのエッジでトラフィックを検査および保護できます。

前提条件

  • Envoy Gateway がインストールされた Kubernetes クラスターが実行中であること。
  • Kubernetes クラスターに Datadog Agent がインストールされ、構成されていること。
    • Datadog UI を使用して攻撃者をブロックできるように、Remote Configuration を有効化して構成します。
    • セキュリティプロセッサーサービスが独自のトレースを Agent に送信できるように、Agent で APM を有効化します。
      • 必要に応じて、Cluster Agent Admission Controller を有効にして、Datadog Agent のホスト情報を App and API Protection セキュリティプロセッサーサービスに自動的に注入できるようにします。

Kubernetes 向け App and API Protection による自動構成

自動構成では、セキュリティプロセッサーのデプロイと、 EnvoyExtensionPolicy 作成が行われます。これは、ほとんどのユーザーに推奨されるアプローチです。

セットアップ

  1. 以下の「Datadog セキュリティプロセッサーサービスをデプロイする」に示されているデプロイマニフェストを使用して、セキュリティプロセッサーをデプロイします。

  2. 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 のインストールを検出します。
    • 各ゲートウェイの EnvoyExtensionPolicy リソースを作成します。
    • トラフィックをセキュリティプロセッサーにルーティングするようにポリシーを構成します。
  3. 作成されたポリシーを確認して、構成を検証します。

    kubectl get envoyextensionpolicy -A
    

構成オプションおよびトラブルシューティングについては、「Kubernetes 向け App and API Protection」を参照してください。

手動構成 (代替方法)

特定のゲートウェイをきめ細かく制御する場合は、手動セットアップを使用します。

  1. クラスターに Datadog セキュリティプロセッサーサービスをデプロイします。
  2. このサービスを指す EnvoyExtensionPolicy を構成します。

ステップ 1: Datadog セキュリティプロセッサーサービスをデプロイする

この gRPC サーバーは、Envoy からのリクエストとレスポンスを受信し、App and API Protection の分析を行います。

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 セキュリティプロセッサーでは、以下の設定が公開されます。

環境変数デフォルト値説明
DD_SERVICE_EXTENSION_HOST0.0.0.0gRPC サーバーのリスニングアドレス。
DD_SERVICE_EXTENSION_PORT443gRPC サーバーのポート。
DD_SERVICE_EXTENSION_HEALTHCHECK_PORT80ヘルスチェック用の HTTP サーバーポート。
DD_SERVICE_EXTENSION_TLStruegRPC TLS レイヤーを有効にします。
DD_SERVICE_EXTENSION_TLS_KEY_FILElocalhost.keyデフォルトの gRPC TLS レイヤーキーを変更します。
DD_SERVICE_EXTENSION_TLS_CERT_FILElocalhost.crtデフォルトの gRPC TLS レイヤー証明書を変更します。
DD_APPSEC_BODY_PARSING_SIZE_LIMIT10485760処理されるボディの最大サイズ (バイト単位)。0 に設定した場合、ボディは処理されません。推奨値は 10485760 (10MB) です。(ボディの処理を完全に有効にするには、[External Processing] (外部処理) フィルター設定で allowModeOverride オプションも設定する必要があります。)
DD_SERVICEserviceextensionsDatadog UI に表示されるサービス名。

以下の環境変数を使用して、セキュリティプロセッサーから Datadog Agent への接続を構成します。

環境変数デフォルト値説明
DD_AGENT_HOSTlocalhostDatadog Agent のホスト名または IP。
DD_TRACE_AGENT_PORT8126トレース収集用の Datadog Agent のポート。

セキュリティプロセッサーは Datadog Go Tracer 上に構築されており、そのすべての環境変数を継承します。「Go SDK の構成」および「App and API Protection ライブラリの構成」を参照してください。

Datadog セキュリティプロセッサーは Datadog Go Tracer 上に構築されているため、通常は Tracer と同じリリースプロセスに従い、その Docker イメージには対応する Tracer バージョンのタグが付けられます (v2.2.2など)。場合によっては、Tracer の公式リリースの合間に早期リリースバージョンが公開されることがあり、これらのイメージには次のようなサフィックスがタグ付けされます ( -docker.1)。

ステップ 2: EnvoyExtensionPolicy を構成する

EnvoyExtensionPolicy を使用して、Datadog セキュリティプロセッサーを呼び出すよう Envoy Gateway に指示します。このポリシーは、ゲートウェイまたは特定の HTTPRoute/GRPCRoute リソースにアタッチできます。

これにより、選択したゲートウェイ上のすべてのトラフィックがセキュリティプロセッサーに送信されます。マニフェストの例 (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.

  1. 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 インテグレーションの互換性ページ」を参照してください。

参考資料