Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Firejailを触ってみよう

 Firejailを触ってみよう

Ubuntu 16.04 LTSリリース記念オフラインミーティング16.06で話した内容です(若干修正あり)。

Avatar for Toshiharu KUDOH

Toshiharu KUDOH

July 02, 2016
Tweet

More Decks by Toshiharu KUDOH

Other Decks in Technology

Transcript

  1. About Me  工藤 寿晴 (twitter id: toshi_kd) ➢ Project Vine

    メンバー ➔ セキュリティチーム ➔ パッケージャー & メンテナー • フォント(日本語及び多言語) • LXDE • デスクトップ GTK+/Qt アプリケーション and more.. Vine Linux Vine Linux
  2. Introduction - 概要 - Firejail is a SUID program that

    reduces the risk of security breaches by restricting the running environment of untrusted applications using Linux namespaces, seccomp-bpf and Linux capabilities. - Firejail (1) より引用- Vine Linux Vine Linux
  3. Introduction 現状日本での注目度は低い。 言及は Linux Daily Topics (「2016 年 5 月

    13 日 ヤバめのアプリはまず"火の檻"で ―サンドボックス「Firejail」が X11 に対応へ」) がほぼ唯一の模様。 (他情報源として ArchWiki 日本語版にページがある程度) Vine Linux Vine Linux
  4. Usage toshi@localhost:~$ firejail Reading profile /etc/firejail/generic.profile Reading profile /etc/firejail/disable-mgmt.inc Reading

    profile /etc/firejail/disable-secret.inc Reading profile /etc/firejail/disable-common.inc ** Note : you can use --noprofile to disable generic.profile ** Parent pid 2733, child pid 2734 Child process initialized [toshi@localhost ~]$ Vine Linux Vine Linux
  5. Usage この状態では、サンドボックスの中で bash が動いている状態。 [toshi@localhost ~]$ ps -ef UID PID

    PPID C STIME TTY TIME CMD 65534 1 0 0 02:22 pts/0 00:00:00 firejail toshi 2 0 0 02:22 pts/0 00:00:00 /bin/bash toshi 3 2 0 02:22 pts/0 00:00:00 ps -ef [toshi@localhost ~]$ Vine Linux Vine Linux
  6. Usage この状態は Linux Kernel の 各種名前空間機能(mount, PID 等) に加え、 /etc/firejail

    以下にある profile で 設定されている。 Vine Linux Vine Linux
  7. Usage generic.profile(snip) include /etc/firejail/disable-mgmt.inc     ← include する file の指定 include

    /etc/firejail/disable-secret.inc include /etc/firejail/disable-common.inc blacklist ${HOME}/.pki/nssdb         ← blacklist の指定 blacklist ${HOME}/.lastpass blacklist ${HOME}/.keepassx blacklist ${HOME}/.password-store caps.drop all                 ← フィルタの指定 seccomp protocol unix,inet,inet6 Vine Linux Vine Linux
  8. Usage disable-common.inc(snip) # History files in $HOME blacklist-nolog ${HOME}/.history ←

    --debug 指定時ログ出力抑止 read-only ${HOME}/.local/share/applications ← read-only 指定 # var blacklist /var/spool/cron # system management blacklist ${PATH}/mount blacklist ${PATH}/sudo Vine Linux Vine Linux
  9. Usage 用意されている profile には、 以下のようなもの(一部)がある。 • audacious • chromium •

    dropbox • firefox • gnome-mplayer • google-chrome • hexchat • steam • unbound • wine - added in 0.9.40 - • ubuntu snap application • openbox Vine Linux Vine Linux
  10. Usage オプションは非常に豊富に 用意されている(以下は一部)。 • profile デバッグ: --debug, --debug-blacklists, etc.. •

    環境変数設定: --env=name=value • ログ出力: --output=log_filename • profile 位置指定: --profile-path=directory Vine Linux Vine Linux
  11. Usage • ホスト名指定: --hostname=name • ネットワーク系指定: {--defaultgw, --dns, --ip}=address, --net={bridge,

    ethernet}_interface, etc.. • 監視用途: --netstats, --list, --top, etc.. • blacklist 指定: --blacklist=dirname or filename • Linux capabilities 指定: --caps.{drop, keep}=hoge • Read-only 指定: --read-only=dirname or filename • (参考)--X11, --appimage Vine Linux Vine Linux
  12. Usage toshi@localhost:~$ sudo firejail --net=enp3s0 --ip=192.168.0.10 /usr/sbin/apache2ctl start Reading profile

    /etc/firejail/server.profile Reading profile /etc/firejail/disable-mgmt.inc ** Note : you can use --noprofile to disable server.profile ** Parent pid 4152, child pid 4153 The new log disrectory is /proc/4153/root/var/log Interface    MAC     IP     Mask     Status lo             127.0.0.1 255.0.0.0 UP eth0-4152 1a:2b:3c:4d 192.168.0.10 255.255.255.0 UP Default gateway 192.168.0.1 Child process initialized * Starting Apache httpd web server apache2 Vine Linux Vine Linux
  13. Usage ホスト(192.168.0.2) とは 別 IP を割り当て、apache を 起動させている。 (なお、systemctl から起動させる場合

    Unit を override し、 firejail を呼び出すよう設定することが必要とされる) Vine Linux Vine Linux