文件/資料夾寫入/刪除明智,我的伺服器安全嗎?

文件/資料夾寫入/刪除明智,我的伺服器安全嗎?

我想知道如果有人使用非 root 帳戶訪問我的伺服器,他會造成多大的損害?

在 i 之後,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/php5給我 1733 這很奇怪。為什麼要寫訪問?為什麼不讀?這是臨時檔案的某種奇怪用法嗎?

答案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.

這意味著它是一種特殊的安全模式,允許使用者在目錄中建立或編輯文件,但只有文件本身的擁有者才能刪除它。

相關內容