mcpField
D
detecting-container-runtime-threats-with-falco

detecting-container-runtime-threats-with-falco

github.com/mukul975セキュリティ35.2k49 回インストール8 週間前に更新
リポジトリ

detecting-container-runtime-threats-with-falco について

コンテナや Kubernetes を扱うセキュリティ担当者向けの Falco スキルです。コンテナ脱出、名前空間の変更、特権マウント、リバースシェルなどを検出するルールの作成、導入、検証を扱います。

主な機能

  1. 01Falco ドライバーの導入と確認
  2. 02ルール、マクロ、リストの作成
  3. 03コンテナ脱出や異常動作の検出
  4. 04ルール検証とアラートの確認
  5. 05Falcosidekick によるアラート転送

活用シーン

  1. 01Kubernetes または Docker のランタイム検知構築
  2. 02紫チーム演習での脱出アラート検証
  3. 03新たに公開されたランタイム CVE 向けルール追加
  4. 04Falco アラートの SIEM 転送

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/mukul975/anthropic-cybersecurity-skills --skill detecting-container-runtime-threats-with-falco

インストール後、Claude Code で/detecting-container-runtime-threats-with-falcoを入力して読み込まれたか確認します。

同梱ファイル

SKILL.md と一緒にインストールされる参考資料やスクリプト。

LICENSE
references/
api-reference.md
standards.md
scripts/
agent.py

詳細

Falco によるコンテナランタイム脅威の検出

概要

Falco は CNCF の卒業済みランタイムセキュリティプロジェクト(当初は Sysdig が開発)です。ドライバーを通じて Linux カーネルの syscall と Kubernetes の監査イベントを取り込み、YAML ルールエンジンで評価して、リアルタイムにアラートを発行します。コンテナ内のランタイム脅威を検出するオープンソースツールのデファクトスタンダードであり、コンテナエスケープ(MITRE ATT&CK T1611, Escape to Host)、名前空間の操作(setns)、特権マウント、リバースシェル、想定外のアウトバウンド接続などを対象とします。

Falco は 3 種類のドライバーをサポートします。推奨のデフォルトである modern eBPF プローブ(カーネル >= 5.8 が必要で、Falco バイナリに直接組み込まれているため init コンテナは不要)、レガシー eBPF プローブ、およびカーネルモジュール(kmod)です。ドライバーの選択は falcoctl driver config --type {kmod|ebpf|modern_ebpf} または Helm チャートの driver.kind=modern_ebpf で行います。Kubernetes では Falco は DaemonSet として実行され、すべてのノードを監視します。また、falcoctl が Falco ルールレジストリからルールアーティファクトを自動的にインストールおよび更新します。

このスキルでは、本コレクションのブレイクアウト手法が生み出すコンテナエスケープの手段や異常動作のシグナルを検出するための、カスタム Falco ルールの作成とデプロイを扱います。各 Falco ルールは rule、desc、condition、output、priority、および任意の tags のフィールドを持ち、再利用可能なロジックは macro と list オブジェクトにまとめられます。出典:falco.org 公式ドキュメント、falcosecurity/rules リポジトリ、Sysdig の Falco 検出研究(例:CVE-2025-22224)。

使用するタイミング

  • Kubernetes または Docker 環境向けのランタイム検出を構築するとき
  • コンテナエスケープや横展開の試みがアラートを生成することを検証するとき(パープルチーム)
  • 新たに公開されたランタイム CVE への対応を追加するとき
  • SOC のコンテナテレメトリパイプライン(Falco -> Falcosidekick -> SIEM)を強化するとき

前提条件

  • modern eBPF を使用する場合はカーネル >= 5.8 の Linux ホスト、または管理権限を持つ Kubernetes クラスター
  • Falco のインストール:
    # Helm (Kubernetes, modern eBPF, JSON output for SIEM ingest)
    helm repo add falcosecurity https://falcosecurity.github.io/charts
    helm repo update
    helm install falco falcosecurity/falco \
      --namespace falco --create-namespace \
      --set driver.kind=modern_ebpf \
      --set collectors.containerd.enabled=true \
      --set falco.json_output=true \
      --set tty=true
    
    # Linux package install (Debian/Ubuntu)
    curl -fsSL https://falco.org/repo/falcosecurity-packages.asc | \
      sudo gpg --dearmor -o /usr/share/keyrings/falco-archive-keyring.gpg
    echo "deb [signed-by=/usr/share/keyrings/falco-archive-keyring.gpg] \
      https://download.falco.org/packages/deb stable main" | \
      sudo tee /etc/apt/sources.list.d/falcosecurity.list
    sudo apt-get update -y && sudo apt-get install -y falco
    
  • Falco のフィールド(evt.type、proc.name、container.id、fd.name)に関する基本的な理解

目的

  • modern eBPF ドライバーで Falco をインストールする
  • rule/macro/list のスキーマと主要な Falco フィルターフィールドを理解する
  • コンテナエスケープ、setns、特権マウント、機密ファイルの読み取り、リバースシェルを対象とするカスタムルールを作成する
  • カスタムルールを読み込み、構文を検証する
  • 検出をトリガーして確認する(パープルチームによる検証)
  • Falcosidekick 経由でアラートを SIEM に転送する

MITRE ATT&CK マッピング

Technique IDNameTactic
T1611Escape to HostPrivilege Escalation
T1059.004Command and Scripting Interpreter: Unix ShellExecution
T1610Deploy ContainerDefense Evasion / Execution
T1543Create or Modify System ProcessPersistence
T1071.001Application Layer Protocol: Web ProtocolsCommand and Control

ワークフロー

ステップ 1:Falco のインストールとドライバーの確認
# Kubernetes: confirm the DaemonSet is running on every node
kubectl get pods -n falco -o wide
kubectl logs -n falco -l app.kubernetes.io/name=falco | grep -i "driver"

# Linux host: configure driver and start
sudo falcoctl driver config --type modern_ebpf
sudo systemctl enable --now falco-modern-bpf.service
sudo systemctl status falco-modern-bpf.service
ステップ 2:rule、macro、list のスキーマを学ぶ

カスタムルールは /etc/falco/falco_rules.local.yaml または /etc/falco/rules.d/ に配置し、/etc/falco/falco.yaml の rules_files で参照します。

# /etc/falco/rules.d/custom-escape.yaml
- list: shell_binaries
  items: [bash, sh, zsh, dash, ash, ksh]

- macro: spawned_process
  condition: evt.type in (execve, execveat) and evt.dir = <

- macro: container
  condition: container.id != host
ステップ 3:コンテナエスケープ検出ルールを作成する(release_agent / cgroup)
- rule: Container Escape via cgroup release_agent
  desc: >
    Detect a process inside a container writing to a cgroup release_agent or
    notify_on_release file, a classic privileged-container breakout primitive.
  condition: >
    container
    and spawned_process
    and (evt.type in (open, openat, openat2) or evt.type=write)
    and (fd.name endswith "release_agent"
         or fd.name endswith "notify_on_release")
    and evt.is_open_write=true
  output: >
    Container escape attempt via cgroup release_agent
    (user=%user.name command=%proc.cmdline file=%fd.name
     container=%container.name image=%container.image.repository)
  priority: CRITICAL
  tags: [container, mitre_privilege_escalation, T1611]
ステップ 4:名前空間ブレイクアウトを検出する(setns / nsenter)
- rule: Namespace Change via setns to Host
  desc: >
    Detect setns/nsenter used to enter the host namespace (e.g. nsenter -t 1),
    a common container-to-host escape technique.
  condition: >
    evt.type = setns
    and container
    and proc.name in (nsenter, unshare)
  output: >
    Namespace breakout via setns/nsenter
    (user=%user.name proc=%proc.name cmd=%proc.cmdline
     container=%container.name image=%container.image.repository)
  priority: CRITICAL
  tags: [container, mitre_privilege_escalation, T1611]
ステップ 5:特権マウントと Docker ソケットの悪用を検出する
- rule: Mount Launched in Privileged Container
  desc: Detect the mount binary running inside a privileged container.
  condition: >
    spawned_process
    and container
    and container.privileged = true
    and proc.name = mount
  output: >
    Mount executed in privileged container
    (cmd=%proc.cmdline container=%container.name image=%container.image.repository)
  priority: WARNING
  tags: [container, mitre_privilege_escalation, T1611]

- rule: Docker Socket Accessed From Container
  desc: A container process reads/writes the host Docker daemon socket.
  condition: >
    container
    and (evt.type in (open, openat, openat2, connect))
    and fd.name = /var/run/docker.sock
  output: >
    Container touched docker.sock - possible daemon-API escape
    (proc=%proc.name cmd=%proc.cmdline container=%container.name)
  priority: CRITICAL
  tags: [container, mitre_execution, T1610]
ステップ 6:リバースシェルと機密ファイルの読み取りを検出する
- rule: Reverse Shell From Container
  desc: A shell in a container with stdin/stdout wired to a network socket.
  condition: >
    spawned_process
    and container
    and proc.name in (shell_binaries)
    and (fd.num in (0, 1, 2))
    and fd.type in (ipv4, ipv6)
  output: >
    Reverse shell detected in container
    (proc=%proc.cmdline connection=%fd.name container=%container.name)
  priority: CRITICAL
  tags: [container, mitre_execution, T1059.004]

- rule: Read Sensitive Host File From Container
  desc: Container reads /etc/shadow or similar after a likely escape.
  condition: >
    container
    and (evt.type in (open, openat, openat2))
    and evt.is_open_read=true
    and fd.name in (/etc/shadow, /etc/sudoers, /root/.ssh/id_rsa)
  output: >
    Sensitive file read from container (file=%fd.name proc=%proc.cmdline
     container=%container.name)
  priority: WARNING
  tags: [container, mitre_credential_access]
ステップ 7:ルール構文を検証して読み込む
# Dry-run validate a rules file without starting the engine
sudo falco --validate /etc/falco/rules.d/custom-escape.yaml

# Run Falco with only the custom rules to test
sudo falco -r /etc/falco/rules.d/custom-escape.yaml

# Helm: ship custom rules via values (mounted into /etc/falco/rules.d)
helm upgrade falco falcosecurity/falco -n falco --reuse-values \
  --set-file "customRules.custom-escape\.yaml"=./custom-escape.yaml
ステップ 8:トリガーして確認する(パープルチーム)
# In a test container, trigger the setns rule
kubectl run pwn --rm -it --image=alpine --overrides='
{"spec":{"hostPID":true,"containers":[{"name":"pwn","image":"alpine",
"securityContext":{"privileged":true},"stdin":true,"tty":true,
"command":["sh"]}]}}' -- sh -c 'nsenter -t 1 -m -u -i -n -p -- id'

# Confirm the alert fired
kubectl logs -n falco -l app.kubernetes.io/name=falco | grep -i "Namespace breakout"
ステップ 9:アラートを SIEM に転送する
# Deploy Falcosidekick to fan out alerts (Elastic, Slack, Splunk, etc.)
helm upgrade falco falcosecurity/falco -n falco --reuse-values \
  --set falcosidekick.enabled=true \
  --set falcosidekick.config.elasticsearch.hostport=https://elastic:9200 \
  --set falcosidekick.config.elasticsearch.index=falco

ツールとリソース

ToolPurposeSource
Falcoランタイムのシステムコール検知エンジンhttps://falco.org
falcoctlドライバーとルールのアーティファクトマネージャーhttps://github.com/falcosecurity/falcoctl
falcosecurity/rulesメンテナンスされているデフォルトのルールセットhttps://github.com/falcosecurity/rules
FalcosidekickSIEM/チャットへのアラートファンアウトhttps://github.com/falcosecurity/falcosidekick
Falco Helm chartKubernetes DaemonSet のデプロイhttps://github.com/falcosecurity/charts

主要な Falco フィルターフィールド

FieldMeaning
evt.typeシステムコール名 (execve, setns, open, connect)
evt.dirイベントの方向 (< exit, > enter)
proc.name / proc.cmdlineプロセス名 / 完全なコマンドライン
container.id / container.privilegedコンテナーの識別子 / privileged フラグ
container.image.repositoryイメージ名
fd.name / fd.typeファイル/ソケットのパス / タイプ (ipv4, ipv6)
evt.is_open_write / evt.is_open_readオープンの意図
user.name操作を行ったユーザー

検証基準

  • 最新の eBPF ドライバーで Falco をインストール済み (すべてのノードに DaemonSet として配置)
  • カスタムルールファイルを falco --validate で検証済み
  • release_agent / setns / privileged-mount / docker.sock のルールを読み込み済み
  • リバースシェルおよび機密ファイルの読み取りルールを読み込み済み
  • 各ルールをラボで発動させ、ログでアラートを確認済み
  • 優先度を適切に設定済み (エスケープの基本手段には CRITICAL)
  • Falcosidekick 経由で SIEM にアラートを転送済み
  • ルールのタグに関連する MITRE テクニック ID を含めている

コメント