3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Falcoのイベント検知Ruleから特定の条件を除外設定をする

Last updated at Posted at 2021-01-08

以下の自分のブログ記事で書いているように、FalcoをEKSに入れてます。

Falcoとaws-for-fluent-bitを使ってCloudWatchにEKSノード上の危険なシステムコール情報を収集する(Proxy環境)

この記事では、デフォルトで定義されているルールから、特定のイベント検知を除外したい場合の例を書きます。

除外対象の例

例えば以下のようなイベントをFalcoが検知したとします。

02:05:21.813285480: Warning Sensitive file opened for reading by non-trusted program (user=root user_loginuid=-1 program=awsagent command=awsagent file=/etc/pam.d/config-util parent=systemd gparent= ggparent= gggparent= container_id=host image=) k8s.ns= k8s.pod= container=host k8s.ns= k8s.pod= container=host

このAWS Agentの処理を例外として設定したいとします。

除外設定

ルールの確認

まずは自身のインストールしているFalcoのバージョンのRuleを確認します。この記事では falco-1.5.7として書き進めます。

Githubなら以下のリンクです。

該当ルールの検索

Sensitive file opened for reading by non-trusted program で検索すると以下の部分が当てはまります。

- rule: Read sensitive file untrusted
  desc: >
    an attempt to read any sensitive file (e.g. files containing user/password/authentication
    information). Exceptions are made for known trusted programs.
  condition: >
    sensitive_files and open_read
    and proc_name_exists
    and not proc.name in (user_mgmt_binaries, userexec_binaries, package_mgmt_binaries,
     cron_binaries, read_sensitive_file_binaries, shell_binaries, hids_binaries,
     vpn_binaries, mail_config_binaries, nomachine_binaries, sshkit_script_binaries,
     in.proftpd, mandb, salt-minion, postgres_mgmt_binaries,
     google_oslogin_
     )
    and not cmp_cp_by_passwd
    and not ansible_running_python
    and not proc.cmdline contains /usr/bin/mandb
    and not run_by_qualys
    and not run_by_chef
    and not run_by_google_accounts_daemon
    and not user_read_sensitive_file_conditions
    and not perl_running_plesk
    and not perl_running_updmap
    and not veritas_driver_script
    and not perl_running_centrifydc
    and not runuser_reading_pam
    and not linux_bench_reading_etc_shadow
    and not user_known_read_sensitive_files_activities
    and not user_read_sensitive_file_containers
  output: >
    Sensitive file opened for reading by non-trusted program (user=%user.name user_loginuid=%user.loginuid program=%proc.name
    command=%proc.cmdline file=%fd.name parent=%proc.pname gparent=%proc.aname[2] ggparent=%proc.aname[3] gggparent=%proc.aname[4] container_id=%container.id image=%container.image.repository)
  priority: WARNING
  tags: [filesystem, mitre_credential_access, mitre_discovery]

注目するのは以下の部分です。Falcoのデフォルトのルールにはこういった除外対象を指定する部分があらかじめ準備されているものが多くあります。(無くても簡単に自分で足すことも可能です)

    and not user_known_read_sensitive_files_activities
    and not user_read_sensitive_file_containers

例えば user_known_read_sensitive_files_activities で検索してみると以下のマクロに行き当たります。 never_true と設定されてますが、ここに条件を書くことで除外対象とできます。

- macro: user_known_read_sensitive_files_activities
  condition: (never_true)

除外条件の記述

検索対象の例で挙げた program=awsagent で除外を設定したいと思います。

以下のoutputの項目を見るとprogramが proc.name で定義されているとわかります。

  output: >
    Sensitive file opened for reading by non-trusted program (user=%user.name user_loginuid=%user.loginuid program=%proc.name
    command=%proc.cmdline file=%fd.name parent=%proc.pname gparent=%proc.aname[2] ggparent=%proc.aname[3] gggparent=%proc.aname[4] container_id=%container.id image=%container.image.repository)

ということで、先程挙げた user_known_read_sensitive_files_activitiesnever_true となっていた部分に以下のように proc.name = awsagent と置き換えてデプロイすれば、このルールからawsagentの処理が除外されます。

シンプルにするためにプログラムを指定しましたが、ANDやOR条件を並べることもできるので、もし対象のファイル等も特定できるならファイルとかも指定して除外範囲を狭めると更に良いと思います。

- macro: user_known_read_sensitive_files_activities
  condition: (proc.name = awsagent)
3
0
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
3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?