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
84
SUIDとスティッキービットの動作確認
タイトル通り、SUIDとスティッキービットの簡単な動作確認をする手順をご紹介しています。
Tadashi KAWARAGI
September 11, 2019
Tweet
Share
More Decks by Tadashi KAWARAGI
See All by Tadashi KAWARAGI
【補足資料】メモリフォレンジック
ragi
0
200
【補足資料】デジタルフォレンジック基礎
ragi
0
100
いいやつ!systemd
ragi
0
100
Other Decks in Technology
See All in Technology
Além do else! Categorizando Pokemóns com Pattern Matching no JavaScript
wmsbill
0
640
ワールドカフェI /チューターを改良する / World Café I and Improving the Tutors
ks91
PRO
0
120
競技としてのKaggle、役に立つKaggle
yu4u
3
1.8k
現代CSSフレームワークの内部実装とその仕組み
poteboy
7
3.6k
On Your Data を超えていく!
hirotomotaguchi
2
690
ChatworkのSRE部って実は 半分くらいPlatform Engineering部かもしれない
saramune
0
160
AOAI をきっかけに 社内の Azure 管理を見直した話
recruitengineers
PRO
1
300
Building a RAG-poweredAI chat appwith Python and VS Code
pamelafox
0
100
Delivering Millions of Messages within seconds @ Duolingo
pelelgrino
0
350
【NW X Security JAWS#3】L3-4:AWS環境のIPv6移行に向けて知っておきたいこと
shotashiratori
0
350
一生覚えておきたい「システム開発=コミュニケーション」〜初めての実務案件振り返りLT〜
maimyyym
1
160
MapLibreとAmazon Location Service
dayjournal
1
160
Featured
See All Featured
Designing Experiences People Love
moore
136
23k
Fontdeck: Realign not Redesign
paulrobertlloyd
76
4.9k
No one is an island. Learnings from fostering a developers community.
thoeni
16
2.1k
Keith and Marios Guide to Fast Websites
keithpitt
408
22k
The Brand Is Dead. Long Live the Brand.
mthomps
49
29k
Learning to Love Humans: Emotional Interface Design
aarron
267
39k
What the flash - Photography Introduction
edds
64
11k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
40
4.4k
Producing Creativity
orderedlist
PRO
337
39k
5 minutes of I Can Smell Your CMS
philhawksworth
199
19k
Building Better People: How to give real-time feedback that sticks.
wjessup
355
18k
Git: the NoSQL Database
bkeepers
PRO
422
63k
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