Docker、Kubernetes、AWS ECS、AWS Fargate で動作する Java アプリのアプリケーションセキュリティを監視することができます。

In general, setting up Application Security Management (ASM) involves:

  1. Identifying services that are vulnerable or are under attack, which would most benefit from ASM. Find them on the Security tab of your Service Catalog.
  2. Updating to the latest Datadog library (the most recent APM tracing library).
  3. Enabling the library to collect the application security data from the services and send it to Datadog.
  4. Triggering security signals in your application and seeing how Datadog displays the resulting information.

Prerequisites

1-Click Enablement
If your service is running with an Agent with Remote Configuration enabled and a tracing library version that supports it, hover over the Not Enabled indicator in the ASM Status column and click Enable ASM. There's no need to re-launch the service with the DD_APPSEC_ENABLED=true or --enable-appsec flags.

詳細はこちら

  1. Datadog Java ライブラリをバージョン 0.94.0 以上 (Application Vulnerability Management の脆弱性検出機能についてはバージョン 1.1.4 以上) に更新してください

    wget -O dd-java-agent.jar 'https://github.com/DataDog/dd-trace-java/releases/latest/download/dd-java-agent.jar'
    

    サービスの言語やフレームワークのバージョンが ASM 機能に対応しているかどうかは、互換性をご参照ください。

  2. **ASM を有効にした状態で Java アプリケーションを実行します。**コマンドラインから

    java -javaagent:/path/to/dd-java-agent.jar -Ddd.appsec.enabled=true -Ddd.service=<MY SERVICE> -Ddd.env=<MY_ENV> -jar path/to/app.jar
    

    または、アプリケーションが実行される場所に応じて、以下の方法のいずれかを使用します。

    注: 読み取り専用ファイルシステムは現在サポートされていません。アプリケーションは書き込み可能な /tmp ディレクトリへのアクセス権を持っている必要があります。

    APM 用の構成コンテナを更新するには、docker run コマンドに以下の引数を追加します。

    docker run [...] -e DD_APPSEC_ENABLED=true [...]
    

    コンテナの Dockerfile に以下の環境変数の値を追加します。

    ENV DD_APPSEC_ENABLED=true
    

    APM 用のデプロイメント構成ファイルを更新し、ASM 環境変数を追加します。

    spec:
      template:
        spec:
          containers:
            - name: <CONTAINER_NAME>
              image: <CONTAINER_IMAGE>/<TAG>
              env:
                - name: DD_APPSEC_ENABLED
                  value: "true"
    

    以下を環境セクションに追加して、ECS タスク定義 JSON ファイルを更新します。

    "environment": [
      ...,
      {
        "name": "DD_APPSEC_ENABLED",
        "value": "true"
      }
    ]
    

    サービス起動時に -Ddd.appsec.enabled フラグまたは DD_APPSEC_ENABLED 環境変数を true に設定します。

    java -javaagent:dd-java-agent.jar \
         -Ddd.appsec.enabled=true \
         -jar <YOUR_SERVICE>.jar \
         <YOUR_SERVICE_FLAGS>
    

    After this configuration is complete, the library collects security data from your application and sends it to the Agent, which sends it to Datadog, where out-of-the-box detection rules flag attacker techniques and potential misconfigurations so you can take steps to remediate.

  3. To see Application Security Management 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 exercise it, threat information appears in the Application Signals Explorer and vulnerability information appears in the Vulnerability Explorer.

コードレベルの脆弱性検出の有効化

コードレベルの脆弱性検出のための Vulnerability Management をサポートするトレーシングライブラリのバージョンを実行しているサービスでは、DD_IAST_ENABLED=true 環境変数に設定してサービスを再起動することで機能を有効にしてください。

サービスのコードレベルの脆弱性を検出するには

  1. Datadog Agent をバージョン 7.41.1 以上に更新します。

  2. トレーシングライブラリを、コードレベルの脆弱性検出を有効にするために必要な最小限のバージョンに更新します。詳しくは、ASM 機能サポートを参照してください。

  3. アプリケーションの構成に DD_IAST_ENABLED=true 環境変数を追加します。

    コマンドラインから

    java -javaagent:/path/to/dd-java-agent.jar -Ddd.iast.enabled=true -Ddd.service=<MY SERVICE> -Ddd.env=<MY_ENV> -jar path/to/app.jar
    

    または、アプリケーションが実行される場所に応じて、以下の方法のいずれかを使用します。

    : 読み取り専用ファイルシステムはサポートされていません。アプリケーションは書き込み可能な /tmp ディレクトリへのアクセス権を持っている必要があります。

    APM 用の構成コンテナを更新するには、docker run コマンドに以下の引数を追加します。

    docker run [...] -e DD_IAST_ENABLED=true [...]
    

    コンテナの Dockerfile に以下の環境変数の値を追加します。

    DD_IAST_ENABLED=true
    

    APM 用のデプロイメント構成ファイルを更新し、IAST 環境変数を追加します。

    spec:
      template:
        spec:
          containers:
            - name: <CONTAINER_NAME>
              image: <CONTAINER_IMAGE>/<TAG>
              env:
                - name: DD_IAST_ENABLED
                  value: "true"
    

    以下を環境セクションに追加して、ECS タスク定義 JSON ファイルを更新します。

    "environment": [
      ...,
      {
        "name": "DD_IAST_ENABLED",
        "value": "true"
      }
    ]
    
  4. サービスを再起動します。

  5. コードレベルの脆弱性に対する Application Vulnerability Management を実際に見るには、サービスをブラウズすると、コードレベルの脆弱性が Vulnerability Explorer に表示されます。SOURCE 列には、Code の値が表示されます。

さらにサポートが必要な場合は、Datadog サポートにお問い合わせください。

その他の参考資料