Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
SUIDとスティッキービットの動作確認
Search
Tadashi KAWARAGI
September 11, 2019
Technology
0
110
SUIDとスティッキービットの動作確認
タイトル通り、SUIDとスティッキービットの簡単な動作確認をする手順をご紹介しています。
Tadashi KAWARAGI
September 11, 2019
Tweet
Share
More Decks by Tadashi KAWARAGI
See All by Tadashi KAWARAGI
【補足資料】メモリフォレンジック
ragi
0
230
【補足資料】デジタルフォレンジック基礎
ragi
0
120
いいやつ!systemd
ragi
0
140
Other Decks in Technology
See All in Technology
ランサムウェア対策としてのpnpm導入のススメ
ishikawa_satoru
0
220
コンテナセキュリティの最新事情 ~ 2026年版 ~
kyohmizu
6
1.4k
【Oracle Cloud ウェビナー】[Oracle AI Database + AWS] Oracle Database@AWSで広がるクラウドの新たな選択肢とAI時代のデータ戦略
oracle4engineer
PRO
2
180
Agent Skils
dip_tech
PRO
0
130
Greatest Disaster Hits in Web Performance
guaca
0
280
ClickHouseはどのように大規模データを活用したAIエージェントを全社展開しているのか
mikimatsumoto
0
270
予期せぬコストの急増を障害のように扱う――「コスト版ポストモーテム」の導入とその後の改善
muziyoshiz
1
2k
生成AIと余白 〜開発スピードが向上した今、何に向き合う?〜
kakehashi
PRO
0
140
~Everything as Codeを諦めない~ 後からCDK
mu7889yoon
3
490
Claude_CodeでSEOを最適化する_AI_Ops_Community_Vol.2__マーケティングx_AIはここまで進化した.pdf
riku_423
2
610
Frontier Agents (Kiro autonomous agent / AWS Security Agent / AWS DevOps Agent) の紹介
msysh
3
180
マーケットプレイス版Oracle WebCenter Content For OCI
oracle4engineer
PRO
5
1.6k
Featured
See All Featured
Done Done
chrislema
186
16k
The Limits of Empathy - UXLibs8
cassininazir
1
220
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
9.9k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
350
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.4k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
7.9k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
34k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.3k
Bash Introduction
62gerente
615
210k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.6k
Test your architecture with Archunit
thirion
1
2.2k
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
450
Transcript
SUIDとスティッキー ビットの動作確認 河原木忠司 KAWARAGI Tadashi
SUIDとスティッキービットの 概要 O SUID O 実行ファイルの実行を所有者の権限で行う O 一般ユーザーにコマンドを実行させる際、root権限 が必要な場合に利用 O
スティッキービット O ディレクトリに設定すると、書き込み権限があったと しても、ディレクトリ内のファイルやサブディレクトリ の削除ができなくなる O 所有者であれば削除は可能 O これ以降は、SUIDとスティッキービットの意味を動 作確認する手順を解説
SUIDの設定例 O passwdコマンド [testuser@instance-1 ~]$ ls -l /usr/bin/passwd -rwsr-xr-x. 1
root root 27832 Jun 10 2014 /usr/bin/passwd SUIDが有効 所有者はroot
SUIDを理解する上での前提 O rootユーザーはパーミッション上読み書きの制約を受け ない [root@instance-1 ~]# ls -l /etc/shadow ----------.
1 root root 1089 Jul 21 09:39 /etc/shadow [root@instance-1 ~]# cat /etc/shadow root:*::0:99999:7::: : パーミッション:000 誰も何もできない rootユーザーは制約を受 けずに読み書き可能
passwdコマンドの実行例 O passwdコマンド [testuser@instance-1 ~]$ ls -l /etc/shadow ----------. 1
root root 1089 Jul 21 09:39 /etc/shadow [testuser@instance-1 ~]$ cat /etc/shadow cat: /etc/shadow: Permission denied [testuser@instance-1 ~]$ passwd Changing password for user testuser. : passwd: all authentication tokens updated successfully. [testuser@instance-1 ~]$ ls -l /etc/shadow ----------. 1 root root 1089 Sep 11 19:17 /etc/shadow 一般ユーザーはパーミッショ ン設定通りの制約を受ける passwdコマンドにより、自身 のパスワードを更新= shadowファイルを更新
なぜ更新できたのか O passwdコマンドにはSUIDビットが有効になっ ているため、一般ユーザーで実行しても所有 者であるrootユーザーの権限で実行される。 O rootユーザーの権限を利用するとパーミッ ション上の制約を受けない
スティッキービットを理解す る上での前提 O Linuxにおいて、ファイルの削除はディレクトリ の書き込み権限が必要 O ファイルのパーミッションは無関係
前提となる動作確認 [root@instance-1 ~]# mkdir -m 777 /sampledir [root@instance-1 ~]# echo
root > /sampledir/root.txt [root@instance-1 ~]# chmod 600 /sampledir/root.txt [root@instance-1 ~]# ls -ld /sampledir drwxrwxrwx. 2 root root 22 Sep 11 13:35 /sampledir [root@instance-1 ~]# ls -l /sampledir total 4 -rw-------. 1 root root 5 Sep 11 13:35 root.txt • サンプル用のファイル(root.txt)は所有者であるroot ユーザーのみが読み書き権限を有する • ディレクトリ(/sampledir)はすべてのユーザーがす べての権限を有する
前提となる動作確認 [testuser@instance-1 ~]$ cat /sampledir/root.txt cat: /sampledir/root.txt: Permission denied [testuser@instance-1
~]$ rm /sampledir/root.txt rm: remove write-protected regular file ‘/sampledir/root.txt’? y [testuser@instance-1 ~]$ ls /sampledir/ 読み取れないファイルを削 除できている 何も表示されない=ディレ クトリは空 • このようにディレクトリに書き込み権限さえあればディ レクトリ内のファイルは削除できてしまう
/tmpディレクトリ O 一時ファイル用のディレクトリ O 既定でスティッキービットが有効になっている O 一般ユーザーに書き込み権限あり [root@instance-1 ~]# ls
-ld /tmp drwxrwxrwt. 9 root root 249 Sep 11 13:45 /tmp [root@instance-1 ~]# echo root > /tmp/root.txt スティッキービットが有効 サンプル用のファイルを作成
動作確認 [testuser@instance-1 ~]$ echo testuser > /tmp/testuser.txt [testuser@instance-1 ~]$ rm
/tmp/*.txt rm: remove write-protected regular file ‘/tmp/root.txt’? y rm: cannot remove ‘/tmp/root.txt’: Operation not permitted [testuser@instance-1 ~]$ ls /tmp/*.txt /tmp/root.txt もう1つサンプル用のファイル を作成 先に作成したファイルのみ 残っている 作成したファイルを削除する が先に作成したroot.txtは削 除不可 • 後から作成したtestuser.txtは所有者なので、削除で きる。所有者となっているファイル以外はスティッキー ビットが有効なディレクトリ内では削除不可
ちなみに・・ O 拙書「LinuC レベル1 合格教本」でも解説して います。 O p.197~198 O https://www.amazon.co.jp/dp/4297106590
/ref=cm_sw_r_tw_dp_U_x_3nZ.CbMKHM553