LoginSignup
2
0

More than 1 year has passed since last update.

Falco Ruleを紹介するシリーズ - Unexpected outbound connection destination

Last updated at Posted at 2022-09-06

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

Rule記述

- rule: Unexpected outbound connection destination
  desc: Detect any outbound connection to a destination outside of an allowed set of ips, networks, or domain names
  condition: >
    outbound and not
    ((fd.sip in (allowed_outbound_destination_ipaddrs)) or
     (fd.snet in (allowed_outbound_destination_networks)) or
     (fd.sip.name in (allowed_outbound_destination_domains)))
  enabled: false
  output: Disallowed outbound connection destination (command=%proc.cmdline connection=%fd.name user=%user.name user_loginuid=%user.loginuid container_id=%container.id image=%container.image.repository)
  priority: NOTICE
  tags: [network]

Rule概要

予期しない宛先に対するアウトバウンド接続を検知します。
マルウェアや侵入した攻撃者は、外部のサーバに対して疑わしい接続や悪意のあるバイナリのダウンロードを実行することがあります。
たとえば、こちらのブログ記事で紹介しているTsunamiマルウェアは、攻撃者が感染したシステムを完全に制御できるようにするバックドアで、一度感染するとIRCサーバーと通信し、新しいコマンドの実行を待ちます。
あらかじめ許可された接続先以外に対するアウトバンド接続が行われた場合には、このRuleを使うことで検知可能です。

Condition(条件)

outbound and
アウトバウンド接続で、

かつ

not ((fd.sip in (allowed_outbound_destination_ipaddrs)) or
サーバーIPアドレスが許可された宛先IPアドレスではない、もしくは

(fd.snet in (allowed_outbound_destination_networks)) or
サーバーIPネットワークが許可された宛先IPネットワークではない、もしくは

(fd.sip.name in (allowed_outbound_destination_domains))
ドメイン名が許可された宛先ドメイン名ではない場合


outboundマクロの内容は以下となります。

- macro: outbound
  condition: >
    (((evt.type = connect and evt.dir=<) or
      (evt.type in (sendto,sendmsg) and evt.dir=< and
       fd.l4proto != tcp and fd.connected=false and fd.name_changed=true)) and
     (fd.typechar = 4 or fd.typechar = 6) and
     (fd.ip != "0.0.0.0" and fd.net != "127.0.0.0/8" and not fd.snet in (rfc_1918_addresses)) and
     (evt.rawres >= 0 or evt.res = EINPROGRESS))

(evt.type = connect and evt.dir=<) or
イベント名がconnectのexitイベント、もしくは

(evt.type in (sendto,sendmsg) and evt.dir=< and
イベント名がsendto、sendmsdgのどちらかのexitイベントで、

fd.l4proto != tcp and fd.connected=false and fd.name_changed=true)) and
プロトコルがTCPではなく、ソケットが接続済みではなく、イベントがファイルディスクリプタ名を変更する場合で(UDP接続の場合など)、

(fd.typechar = 4 or fd.typechar = 6)) and
ファイルディスクリプタがIPv4もしくはIPv6ソケットで、

(fd.ip != "0.0.0.0" and fd.net != "127.0.0.0/8" and not fd.snet in (rfc_1918_addresses)) and
IPアドレスが"0.0.0.0"ではなく、IPネットワークが"127.0.0.0/8"ではなく、サーバーIPネットワークがRFC 1918のアドレス(プライベートアドレス)でもなく、

(evt.rawres >= 0 or evt.res = EINPROGRESS)
イベントが成功もしくは進行中の場合


サンプルとしての、デフォルトのリストの内容は以下となります。

- list: allowed_outbound_destination_ipaddrs
  items: ['"127.0.0.1"', '"8.8.8.8"']

- list: allowed_outbound_destination_networks
  items: ['"127.0.0.1/8"']

- list: allowed_outbound_destination_domains
  items: [google.com, www.yahoo.com]

Output(出力)

許可されていない宛先に対するアウトバンド接続

%proc.cmdline
コマンドライン

%fd.name
接続名

%user.name
ユーザー名

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

%container.id
コンテナID

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

2
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
2
0