ファイル/フォルダの書き込み/削除に関して、私のサーバーは安全ですか?

ファイル/フォルダの書き込み/削除に関して、私のサーバーは安全ですか?

誰かが非ルートアカウントを使用して私のサーバーにアクセスした場合、どの程度の損害を与えることができるのかを知りたいです。

その後、su someuserこのコマンドを使用して、書き込み可能なすべてのファイルとフォルダーを検索しました。

find / -writable >> list.txt

結果はこちら. ほとんどは/dev/somethingと/proc/somethingで、これら

/var/lock
/var/run/mysqld/mysqld.sock
/var/tmp
/var/lib/php5

私のシステムは安全ですか? /var/tmp は理にかなっています。しかし、なぜこのユーザーがそれらのフォルダーへの書き込みアクセス権を持っているのかわかりません。変更すべきでしょうか?

stat /var/lib/php51733 という奇妙な値が表示されます。なぜ書き込みアクセスがあるのか​​? なぜ読み取りアクセスがないのか? これは、一時ファイルの奇妙な使用法なのでしょうか?

答え1

ユーザーは、特定のソフトウェアを実行するために、特定のシステム レベルの領域にアクセスする必要があります。たとえば、/var/run/mysqld/mysqld.sockデータベースと対話するには、アクセス可能である必要があります。

/var/run には通常、Unix ソケットや pid ファイルなどのランタイム データが格納されます。

/var/lock には、ソフトウェアが読み取り/書き込みの衝突などを防止し、ファイルの排他的オープン (ファイル ロックなど) を可能にするロック ファイルが含まれています。

/var/lib/php5 には非常に特殊なファイル アクセス モード (1733) があります。先頭の 1 が重要です。

からman chmod

       1000    (the sticky bit).  See chmod(2) and sticky(8).

したがって、次のようにman stickyなります:

STICKY DIRECTORIES
     A directory whose `sticky bit' is set becomes an append-only directory,
     or, more accurately, a directory in which the deletion of files is
     restricted.  A file in a sticky directory may only be removed or renamed
     by a user if the user has write permission for the directory and the user
     is the owner of the file, the owner of the directory, or the super-user.
     This feature is usefully applied to directories such as /tmp which must
     be publicly writable but should deny users the license to arbitrarily
     delete or rename each others' files.

つまり、これは、ユーザーがディレクトリ内にファイルを作成または編集できるが、ファイル自体の所有者だけがファイルを削除できる特別なセキュリティ モードです。

関連情報