本シリーズでは、ランタイム脅威検知のデファクトスタンダードであるFalcoの検知Ruleを、1つの記事で1つ簡単に紹介していきます。
ランタイムセキュリティやFalco自体の概要を知りたい方はこちらのブログ記事をご参照ください。
今回ご紹介する検知Ruleは「Directory traversal monitored file read」です。
Rule記述
- rule: Directory traversal monitored file read
desc: >
Web applications can be vulnerable to directory traversal attacks that allow accessing files outside of the web app's root directory (e.g. Arbitrary File Read bugs).
System directories like /etc are typically accessed via absolute paths. Access patterns outside of this (here path traversal) can be regarded as suspicious.
This rule includes failed file open attempts.
condition: (open_read or open_file_failed) and (etc_dir or user_ssh_directory or fd.name startswith /root/.ssh or fd.name contains "id_rsa") and directory_traversal and not proc.pname in (shell_binaries)
enabled: true
output: >
Read monitored file via directory traversal (username=%user.name useruid=%user.uid user_loginuid=%user.loginuid program=%proc.name exe=%proc.exepath
command=%proc.cmdline parent=%proc.pname file=%fd.name fileraw=%fd.nameraw parent=%proc.pname
gparent=%proc.aname[2] container_id=%container.id image=%container.image.repository returncode=%evt.res cwd=%proc.cwd)
priority: WARNING
tags: [filesystem, mitre_discovery, mitre_exfiltration, mitre_credential_access]
Rule概要
ディレクトリ・トラバーサル攻撃(公開ディレクトリから非公開ディレクトリへの移動)の試みを検知します。
Webアプリケーションは、Webアプリケーションのルートディレクトリ外のファイルへのアクセスを可能とするディレクトリ・トラバーサル攻撃(例:Arbitrary File Readバグ)に対して脆弱な場合があります。
また、/etc のようなシステムディレクトリは、通常、絶対パスでアクセスされるので、これ以外のアクセスパターン(ここではパストラバーサル)は疑わしいと見なすことができます。
このルールは、ファイルを開く試みに失敗した場合も含みます。
Condition(条件)
(open_read or open_file_failed) and
ファイルの読み込みに成功、または失敗し、
(etc_dir or user_ssh_directory or fd.name startswith /root/.ssh or fd.name contains "id_rsa") and
/etcディレクトリ、もしくはユーザーSSHディレクトリ、またはファイル名が/root/.sshで始まるか、ファイル名が"id_rsa"を含む場合で、
directory_traversal and
ディレクトリトラバーサルを行っていて、
かつ
not proc.pname in (shell_binaries)
プロセス名がシェルバイナリではない場合
directory_traversalマクロの内容は以下となります。
- macro: directory_traversal
condition: (fd.nameraw contains '../' and fd.nameraw glob '*../*../*')
(fd.nameraw contains '../' and fd.nameraw glob '*../*../*')
ファイル名が '../' を含み、globが '*../*../*' の場合
Output(出力)
監視しているファイルをディレクトリトラバーサルで読み込みました
%user.name
ユーザー名
%user.uid
ユーザーのUID
%user.loginuid
ユーザーのログインUID
%proc.name
プロセス名
%proc.exepath
プロセスの実行パス
%proc.cmdline
コマンドライン
%proc.pname
親プロセス名
%fd.name
ファイル名
%fd.nameraw
RAWファイル名
gparent=%proc.aname[2]
2世代前の親プロセス名
%container.id
コンテナID
%container.image.repository
コンテナイメージリポジトリ
%evt.res
イベントリターン値
%proc.cwd
カレントワーキングディレクトリ