Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
SELinuxで堅牢化する / selinux
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Mako
January 15, 2022
Technology
1.9k
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
SELinuxで堅牢化する / selinux
WASNight 2022 Kick-Off = OWASP x WASForum Night の Hardening Session での発表資料
Mako
January 15, 2022
More Decks by Mako
See All by Mako
マイナンバーカードの暗号技術とセキュリティ
tex2e
2
3.3k
TLS 1.3自作入門 / tls13
tex2e
0
1.3k
プロトコルの形式的安全性検証ツールProVerif / proverif
tex2e
0
1.5k
マイナンバーカードで署名する / mynumbercard
tex2e
2
3.6k
Other Decks in Technology
See All in Technology
AIに攻撃される前に、AIに攻撃させる
tsuchikazu
0
150
[2026-09-30]ロックンロールは鳴り止まないっ - 信頼性かまってちゃん - 「データ駆動を投げ捨ててまで。」追いかける信頼性改善に向けた取り組みの話
tosite
0
210
Google Cloud Next Tokyo 26登壇時のスクリプト
recruitengineers
PRO
0
200
AIアプリを使い分けるための共通ツール基盤を考えてみる#devio2026
osawa
0
260
BedrockとLambdaで作る リアルタイム進行型推理ゲーム
kawametho
0
190
生成AIで高い生産性を求められて、 悩み、乗り越えた話
mot_techtalk
2
130
調査タスクをAIと乗り切る 〜過去の調査をナレッジ化し 調査手順をスキルにする〜
mot_techtalk
1
120
Deep Data Security 機能解説
oracle4engineer
PRO
2
710
ログラスのマルチプロダクトを 支える認証基盤 〜テナントごとに異なる統制とどう向き合うか〜
dada4386
3
400
[AWS 秋のクラウドオペレーション祭り 2026]AWS DevOps Agentで変わるリリースと運用対応 ~リリース管理機能と Directed actions のご紹介~
furuton
3
940
雪かき部 #7 もう怖くない!SELECT文!
foursue
0
280
生成AIを使って「人が」考える技術 ― AI時代の人機共想と実践ノウハウ|UNITT AC2026
ishiirikie
0
560
Featured
See All Featured
Ethics towards AI in product and experience design
skipperchong
2
410
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
610
It's Worth the Effort
3n
188
29k
Color Theory Basics | Prateek | Gurzu
gurzu
1
480
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.8k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
The Spectacular Lies of Maps
axbom
PRO
1
1.1k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.7k
Designing Experiences People Love
moore
143
24k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3k
Utilizing Notion as your number one productivity tool
mfonobong
4
610
Transcript
SELinuxで堅牢化する H2021AF Team8, @tex2e 2022/1/14
SELinuxの検索上位ワード SELinuxと言えば...
通常のアクセス制御 (DAC) サブジェクト 参照:https://opensource.com/business/13/11/selinux-policy-guide オブジェクト アクション
通常のアクセス制御 (DAC) サブジェクト 参照:https://opensource.com/business/13/11/selinux-policy-guide オブジェクト アクション 誰でもアクセスできる と、 他人に食べられる (権限777などの設定ミス)
犬の着ぐるみを被った狼 だったら、 狼は不正にアクセスできる (管理者への権限昇格)
SELinuxのアクセス制御 (MAC) サブジェクト 参照:https://opensource.com/business/13/11/selinux-policy-guide オブジェクト ポリシー リファレンス モニター (RBAC; Role
Based Access Control) (TE; Type Enforcement) アクション 検証
TE (Type Enforcement) 「プロセス」に対してアクセス権限を割り当ててアクセス制御する 参照:https://opensource.com/business/13/11/selinux-policy-guide 「犬」が「キャットフード」を食べるのはポリシー違反
Log4j2のRCE脆弱性に対する緩和 参照:https://blogs.jpcert.or.jp/ja/2021/12/log4j-cve-2021-44228.html tomcat_t が *_port_t に tcp_socket name_connect (外部ポート接続) することは許可されているか?
↑ ※デフォルトは許可. TomcatのSecurityManagerを推奨 tomcat_t が tomcat_*_t 以外に file read/write/execute (ファイル書込/実行) することは許可されているか? 攻撃者 やられサーバ
Hardening競技環境での初期設定 SELinuxは無効化されている SELinux=disabled
Hardening競技環境での構成変更 SELinuxを有効化して運用するまで(競技用) ~]# sed -ie 's/^SELINUX=disabled/SELINUX=permissive/' /etc/selinux/config ~]# reboot ~]#
setenforce 1 ~]# setsebool -P httpd_can_network_connect_db On ~]# setsebool -P httpd_can_sendmail On ~]# tail -f /var/log/audit/audit.log | grep "denied" ※復旧できるように起動時は permissive、起動後にsetenforceで有効化 ※構成変更後は必要に応じて audit2allowコマンドでカスタムポリシーを作って適用
監査ログ:ファイル編集拒否 [srv05] 2021/11/19 11:30:26 type=AVC msg=audit(1637289026.349:218): avc: denied { write
} for pid=2006 comm="/usr/sbin/httpd" name="configure.php" dev="vda1" ino=139945 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:httpd_sys_content_t:s0 tclass=file permissive=0 httpd(Webサーバ) が configure.php という名前のファイルに書き込みを試みたので拒否した - Webサーバ経由でのファイルの改ざん • httpd_sys_content_t : 読み取りのみ • httpd_sys_rw_content_t : 読み書き • httpd_sys_script_exec_t : 実行
監査ログ:ファイル作成拒否 [srv03] 2021/11/19 12:04:10 type=AVC msg=audit(1637291050.436:129): avc: denied { write
} for pid=1540 comm="/usr/sbin/httpd" name="html" dev="vda1" ino=3018892 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:httpd_sys_content_t:s0 tclass=dir permissive=0 httpd(Webサーバ) が html という名前のディレクトリの更新を試みたので拒否した - /var/www/html直下にWebShellファイルを新規作成 1. dir write (ディレクトリの更新時間を編集) ← SELinuxはここで拒否した 2. dir add_name (見出し追加) 3. file create (新規作成) 4. file write (内容書き込み)
監査ログ:外部ポートへの接続拒否 [srv03] 2021/11/19 13:17:14 type=AVC msg=audit(1637295434.210:277): avc: denied { name_connect
} for pid=1538 comm="/usr/sbin/httpd" dest=3000 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:ntop_port_t:s0 tclass=tcp_socket permissive=0 httpd(Webサーバ) が 3000番ポートにTCPコネクションを試みたので拒否した - RCEによるcurlやwgetなど • 外部DB接続を許可したいときは、ブール値 httpd_can_network_connect_db を On にする
監査ログ:メール送信拒否 [srv06] 2021/11/19 11:43:15 type=AVC msg=audit(1637289795.813:393): avc: denied { read
} for pid=2971 comm="sendmail" name="main.cf" dev="vda1" ino=133340 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:postfix_etc_t:s0 tclass=file permissive=0 sendmail(Webサーバ経由) が main.cf (postfix設定情報) のファイル読み込みを試みたので拒否した - RCEによるsendmailコマンドの実行など • メール送信を許可したいときは、ブール値 httpd_can_sendmail を On にする
監査ログ:sshd改ざん後のログイン 1/2 [srv02] 2021/11/19 13:59:41(user10, user11のパスワード変更作業漏れが原因) type=USER_AVC msg=audit(1637297981.555:302): pid=1 uid=0
auid=4294967295 ses=4294967295 subj=system_u:system_r:kernel_t:s0 msg='avc: denied { start } for auid=n/a uid=0 gid=0 cmdline="/usr/lib/systemd/systemd-logind" scontext=system_u:system_r:kernel_t:s0 tcontext=system_u:system_r:kernel_t:s0 tclass=service exe="/usr/lib/systemd/systemd" sauid=0 hostname=? addr=? terminal=?' ユーザログインを管理するシステムサービス がkernet_tドメインのサービス起動を試みたので拒否 - システム改ざん • systemd_logind_exec_t : /usr/lib/systemd/systemd-logindファイルのデフォルトタイプ • ユニットファイルが systemd_logind_exec_t 以外の lib_t などだったから拒否した? • ドメインが systemd_logind_t 以外の kernel_t で動いていたから拒否した?
監査ログ:sshd改ざん後のログイン 2/2 [srv02] 2021/11/19 13:59:41(user10, user11のパスワード変更作業漏れが原因) type=AVC msg=audit(1637297981.609:312): avc: denied
{ transition } for pid=8132 comm="sshd" path="/usr/bin/bash" dev="vda3" ino=100664377 scontext=system_u:system_r:kernel_t:s0 tcontext=unconfined_u:unconfined_r:unconfined_t:s0 tclass=process permissive=0 sshd が /usr/bin/bash を使って制限なし(unconfied_t)のプロセスを生成しようとしたので拒否した - システム改ざん • /usr/bin/bash のタイプが shell_exec_t 以外の bin_t などだったから拒否した?
まとめ 初期設定でセキュリティを有効化する戦略 (Secure by Default) によって、 新しい技術には標準で組み込みセキュリティ (Built-In Security) が含まれている。
- IPv6 : IPsec - HTTP3 (QUIC) : TLS 1.3 - Windows 10 : Windows Defender (WDAC) - Windows 11 : TPM 2.0 + Secure Boot - Docker : Limit Kernel Capabilities - CentOS 4〜 : SELinux - Android 4.4〜 : SELinux 組み込みセキュリティを活用しよう! (SELinux無効化しないで使おう!)
Thank you!
A1. SELinuxで守れないもの - rootアカウントの保護 - 権限が奪取された場合はアクセス制限できるが、パスワードそのものが漏洩した場合はアクセス制限 できない - DoS攻撃 -
リソースの消費が激しいリクエストや内部エラーによるサービス停止は防げない - Webアプリケーション特有の問題 - SQLi, XSS, XSRF などは防げない
A2. unconfined_t(制限なしのタイプ) デフォルトでSELinuxはユーザを制限していないので、パスワードが漏洩すると大問題になる ~]# semanage login -l Login Name SELinux
User MLS/MCS Range Service __default__ unconfined_u s0-s0:c0.c1023 * root unconfined_u s0-s0:c0.c1023 *