Docker、Kubernetes、Amazon ECS、AWS Fargate で実行されている .NET アプリのアプリケーションセキュリティを監視することができます。

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 .NET ライブラリをバージョン 2.2.0 以上 (Application Vulnerability Management の脆弱性検出機能についてはバージョン 2.16.0 以上) に更新してください

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

  2. 環境変数 DD_APPSEC_ENABLEDtrue に設定することで、ASM を有効にします。例えば、Windows のセルフホストでは、アプリケーションの起動スクリプトの一部として、次の PowerShell スニペットを実行します。

    $target=[System.EnvironmentVariableTarget]::Process
    [System.Environment]::SetEnvironmentVariable("DD_APPSEC_ENABLED","true",$target)
    

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

Windows コンソールで:

rem Set environment variables
SET CORECLR_ENABLE_PROFILING=1
SET CORECLR_PROFILER={846F5F1C-F9AE-4B07-969E-05C26BC060D8}
SET DD_APPSEC_ENABLED=true

rem Start application
dotnet.exe example.dll

管理者として以下の PowerShell コマンドを実行し、レジストリ HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment に必要な環境変数を構成して、IIS を再起動します。

$target=[System.EnvironmentVariableTarget]::Machine
[System.Environment]::SetEnvironmentVariable("DD_APPSEC_ENABLED","true",$target)
net stop was /y
net start w3svc

または、IIS サービスのみの場合、Powershell がある WAS と W3SVC で管理者権限で以下を実行します。


$appsecPart = "DD_APPSEC_ENABLED=true"
[string[]] $defaultvariable = @("CORECLR_ENABLE_PROFILING=1", "CORECLR_PROFILER={846F5F1C-F9AE-4B07-969E-05C26BC060D8}", $appsecPart)

function Add-AppSec {

    param (
        $path
    )
    $v = (Get-ItemProperty -Path $path).Environment
    If ($v -eq $null) {
        Set-ItemProperty -Path $path -Name "Environment" -Value $defaultvariable
    }
    ElseIf (-not ($v -match $appsecPart)) {
        $v += " " + $appsecPart;
        Set-ItemProperty -Path $path -Name "Environment" -Value $v
    }
}
Add-AppSec -path "HKLM:SYSTEM\CurrentControlSet\Services\WAS\"
Add-AppSec -path "HKLM:SYSTEM\CurrentControlSet\Services\W3SVC\"

net stop was /y
net start w3svc

または、レジストリキーの編集を避けるため、アプリケーションの設定を web.config ファイルで編集します。

<configuration>
  <appSettings>
        <add key="DD_APPSEC_ENABLED" value="true"/>
  </appSettings>
</configuration>

これは、IIS アプリケーションプールレベルで、applicationHost.config ファイル (通常、C:\Windows\System32\inetsrv\config\ にあります) で行うこともできます。

<system.applicationHost>

    <applicationPools>
        <add name="DefaultAppPool">
            <environmentVariables>
                <add name="DD_APPSEC_ENABLED" value="true" />
            </environmentVariables>
            (...)

アプリケーションの構成に以下を追加します。

DD_APPSEC_ENABLED=true

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"
  }
]

コンテナの Dockerfile に以下の行を追加します。

ENV DD_APPSEC_ENABLED=true
  1. 完全に停止してから起動することで、アプリケーションを再起動します。

    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.

  2. 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.

その他の参考資料