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
SUIDとスティッキービットの動作確認
Search
Tadashi KAWARAGI
September 11, 2019
Technology
110
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
SUIDとスティッキービットの動作確認
タイトル通り、SUIDとスティッキービットの簡単な動作確認をする手順をご紹介しています。
Tadashi KAWARAGI
September 11, 2019
More Decks by Tadashi KAWARAGI
See All by Tadashi KAWARAGI
【補足資料】メモリフォレンジック
ragi
0
240
【補足資料】デジタルフォレンジック基礎
ragi
0
120
いいやつ!systemd
ragi
0
160
Other Decks in Technology
See All in Technology
2026-09-09 【sigma_ucj#1】Sigma を IaC 管理したい! / IaC for Sigma
civitaspo
0
130
薬剤師(ドメインエキスパート)と一緒に育てる薬局向けAIアシスタント
kakehashi
PRO
2
160
銀行勘定系システムにおける開発プロセス刷新×AIによる環境モダナイゼーション / Development Process Transformation and AI-Driven Environment Modernization
muit
0
1.3k
AIオーケストレーションを活用した 開発ワークフローの設計と実践
bqnq
0
170
10Xに技術的負債をもたらした「2つの境界の歪み」その構造と解消への営み
10xinc
0
1.1k
積み重なった技術負債への挑戦 〜初手としての全社ゴト化〜
techtekt
PRO
0
370
ASTを使って影響範囲を特定する
nealle
0
180
Screen Lens - 今見てる画面を翻訳する
komagata
0
270
例外の正しい扱い方 そのエラー try-catchして大丈夫?
jinwatanabe
3
490
AIで仕事のやり方を変える
matsu7874
3
1.1k
Gitは怖い?共有ワークスペースから始めるSnowflakeチーム開発
coco_se
0
200
GoにおけるFFIのこれまでとこれから
goccy
5
2.6k
Featured
See All Featured
Exploring anti-patterns in Rails
aemeredith
3
500
30 Presentation Tips
portentint
PRO
1
390
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.6k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
500
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
390
Product Roadmaps are Hard
iamctodd
55
13k
Why Our Code Smells
bkeepers
PRO
340
58k
New Earth Scene 8
popppiees
3
2.6k
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
430
Accessibility Awareness
sabderemane
1
210
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.2k
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