LoginSignup
4
1

More than 1 year has passed since last update.

Falco Ruleを紹介するシリーズ - create_files_below_dev

Last updated at Posted at 2022-08-23

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

Rule記述

- rule: Create files below dev
  desc: creating any files below /dev other than known programs that manage devices. Some rootkits hide files in /dev.
  condition: >
    fd.directory = /dev and
    (evt.type = creat or (evt.type in (open,openat,openat2) and evt.arg.flags contains O_CREAT))
    and not proc.name in (dev_creation_binaries)
    and not fd.name in (allowed_dev_files)
    and not fd.name startswith /dev/tty
    and not user_known_create_files_below_dev_activities
  output: "File created below /dev by untrusted program (user=%user.name user_loginuid=%user.loginuid command=%proc.cmdline file=%fd.name container_id=%container.id image=%container.image.repository)"
  priority: ERROR
  tags: [filesystem, mitre_persistence]

Rule概要

/devディレクトリ配下に、ファイルが作成されたことを検知します。
/devはLinuxのデバイスファイルが配置されているディレクトリで、一般的にデバイス管理を行うプログラム以外によってファイルが作成されることはありません。
通常使用時には滅多にユーザーがアクセスしないディレクトリであるため、rootkitなどがファイルの隠し場所として利用することがありますが、このRuleを使うことで検知可能です。

Condition(条件)

fd.directory = /dev
/devディレクトリで、

and (evt.type = creat or (evt.type in (open,openat,openat2) and evt.arg.flags contains O_CREAT))
ファイルが作成、もしくはファイルが存在しない場合には作成する条件付きでオープンされ、

かつ

and not proc.name in (dev_creation_binaries)
プロセス名がデバイスを作成するバイナリーではなく、

and not fd.name in (allowed_dev_files)
ファイル名が許可されたデバイスファイル名ではなく、

and not fd.name startswith /dev/tty
ファイル名が/dev/ttyから始まらず、

and not user_known_create_files_below_dev_activities
/dev配下でのファイル作成の既知の条件にも合致しない場合

Output(出力)

信頼されていないプログラムによって/dev配下にファイルが作成されました。

%user.name
ユーザー名

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

%proc.cmdline
コマンドライン

%fd.name
ファイル名

%container.id
コンテナID

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

4
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
4
1