LoginSignup
6
1

More than 1 year has passed since last update.

Falco Ruleを紹介するシリーズ - Terminal shell in container

Last updated at Posted at 2022-08-22

本シリーズでは、ランタイム脅威検知のデファクトスタンダードであるFalcoの検知Ruleを、1つの記事で1つ紹介していきます。
Falco自体の概要を知りたい方はこちらのブログ記事をご参照ください。
今回ご紹介する検知Ruleは「Terminal shell in container」です。

Rule記述

- rule: Terminal shell in container
  desc: A shell was used as the entrypoint/exec point into a container with an attached terminal.
  condition: >
    spawned_process and container
    and shell_procs and proc.tty != 0
    and container_entrypoint
    and not user_expected_terminal_shell_in_container_conditions
  output: >
    A shell was spawned in a container with an attached terminal (user=%user.name user_loginuid=%user.loginuid %container.info
    shell=%proc.name parent=%proc.pname cmdline=%proc.cmdline terminal=%proc.tty container_id=%container.id image=%container.image.repository)
  priority: NOTICE
  tags: [container, shell, mitre_execution]

Rule概要

コンテ内でターミナルシェルが使用されたことを検知します。
コンテナはイミュータブル(変更不可)として取り扱うことが望ましいため、一般的にコンテナ内でターミナルシェルを起動することはありません(もちろん例外もあり、構成管理ソフトウェアなどがシェルを起動するのは予期された動作となります)。
コンテナの設定変更やアップデートを行う場合には、新たにコンテナイメージを作成し、デプロイする運用が一般的です。
そのため、コンテナ内でシェルが起動した場合、攻撃者が何らかの不正行為を行う目的でシェルを起動させた可能性があり、このRuleを使うことで検知可能です。

Condition(条件)

spawned_process and container and shell_procs and proc.tty != 0 and container_entrypoint
ノードではなくコンテナ内で、シェルのプロセスがエントリーポイントとして新たにターミナルで起動された場合で

かつ

and not user_expected_terminal_shell_in_container_conditions
あらかじめユーザーが定義した、予期されたコンテナ内でのターミナルシェル起動の条件には合致しない場合

Output(出力)

コンテナ内のターミナルでシェルが起動されました。

%user.name
ユーザー名

%user.loginuid
ユーザーのログインUID

%container.info
コンテナ情報

%proc.name
プロセス名

%proc.pname
親プロセス名

%proc.cmdline
コマンドライン

%proc.tty
ターミナル

%container.id
コンテナID

%container.image.repository
コンテナイメージリポジトリ

6
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
1