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
コールドスタンバイ構成でCDは可能か
hiramax
0
130
複雑さを受け入れるか、拒むか? - 事業成長とともに育ったモノリスを前に私が考えたこと #RSGT2026
murabayashi
1
1.5k
re:Invent2025 セッションレポ ~Spec-driven development with Kiro~
nrinetcom
PRO
2
170
【Agentforce Hackathon Tokyo 2025 発表資料】みらいシフト:あなた働き方を、みらいへシフト。
kuratani
0
110
Introduction to Bill One Development Engineer
sansan33
PRO
0
340
マーケットプレイス版Oracle WebCenter Content For OCI
oracle4engineer
PRO
5
1.5k
モノタロウ x クリエーションラインで実現する チームトポロジーにおける プラットフォームチーム・ ストリームアラインドチームの 効果的なコラボレーション
creationline
0
570
ハッカソンから社内プロダクトへ AIエージェント ko☆shi 開発で学んだ4つの重要要素
leveragestech
0
600
AI との良い付き合い方を僕らは誰も知らない (WSS 2026 静岡版)
asei
1
250
Next.js 16の新機能 Cache Components について
sutetotanuki
0
220
Cloud WAN MCP Serverから考える新しいネットワーク運用 / 20251228 Masaki Okuda
shift_evolve
PRO
0
140
Contract One Engineering Unit 紹介資料
sansan33
PRO
0
12k
Featured
See All Featured
We Have a Design System, Now What?
morganepeng
54
8k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.6k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
94
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
40
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
330
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
1.8k
Context Engineering - Making Every Token Count
addyosmani
9
590
Leo the Paperboy
mayatellez
1
1.3k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
420
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