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
CDK対応したAWS DevOps Agentを試そう_20260201
masakiokuda
1
400
マーケットプレイス版Oracle WebCenter Content For OCI
oracle4engineer
PRO
5
1.6k
Cloud Runでコロプラが挑む 生成AI×ゲーム『神魔狩りのツクヨミ』の裏側
colopl
0
140
会社紹介資料 / Sansan Company Profile
sansan33
PRO
15
400k
pool.ntp.orgに ⾃宅サーバーで 参加してみたら...
tanyorg
0
590
OCI Database Management サービス詳細
oracle4engineer
PRO
1
7.4k
Bill One急成長の舞台裏 開発組織が直面した失敗と教訓
sansantech
PRO
2
400
AIエージェントに必要なのはデータではなく文脈だった/ai-agent-context-graph-mybest
jonnojun
1
240
登壇駆動学習のすすめ — CfPのネタの見つけ方と書くときに意識していること
bicstone
3
130
コンテナセキュリティの最新事情 ~ 2026年版 ~
kyohmizu
6
1.4k
20260204_Midosuji_Tech
takuyay0ne
1
160
Codex 5.3 と Opus 4.6 にコーポレートサイトを作らせてみた / Codex 5.3 vs Opus 4.6
ama_ch
0
200
Featured
See All Featured
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
52
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
77
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Become a Pro
speakerdeck
PRO
31
5.8k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
97
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
260
Crafting Experiences
bethany
1
50
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Making the Leap to Tech Lead
cromwellryan
135
9.7k
We Are The Robots
honzajavorek
0
170
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
196
71k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.4k
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