- 漏洞詳情
VSFTP是一套基于GPL釋出的類Unix系統上使用的FTP伺服器軟體。該軟體支援虛拟使用者、支援兩種認證方式(PAP或xinetd/tcp_wrappers)、支援帶寬限制等。
VSFTP中存在安全漏洞,該漏洞源于程式沒有正确處理‘deny_file’選項。遠端攻擊者可利用該漏洞繞過通路限制。
以下産品及版本受到影響:VSFTP3.0.2及之前版本,opensuse13.1版本和13.2版本。
- 受影響的産品
Vsftpd Vsftpd 3.0.2
- FTP的登入一般有三種方式,分别是:
- 匿名使用者形式:預設安裝的情況下,系統隻提供匿名使用者通路,隻需要輸入使用者anonymous/ftp,并将自己的Email作為密碼即可登入。
- 本地使用者形式:以/etc/passwd中的使用者名為認證方式。
- 虛拟使用者形式:支援将使用者名和密碼儲存在檔案或資料庫中,将登入使用者映射到指定的系統賬号(/sbin/nologin)來通路資源,其中這些虛拟使用者是FTP的使用者。
-
實驗環境: CentOS 7.5 192.168.2.3
- firewalld、iptables 及 SElinux 均為關閉狀态
- 下面實驗采用基于PAM的虛拟使用者,需要先用yum來安裝PAM的元件:
- 需要使用 epel 源
- yum -y install epel-release && yum -y install pam pam-devel db4-utils
- 在預設配置下 vsftpd 需要使用 nobody 使用者
- 從官網上下載下傳 https://www.linuxfromscratch.org/blfs/view/svn/server/vsftpd.html
- wget https://security.appspot.com/downloads/vsftpd-3.0.3.tar.gz
- tar xf vsftpd-3.0.3.tar.gz
- cd vsftpd-3.0.3/
- vsftpd的源碼包裡并沒有configure檔案,直接編譯安裝
- make clean && make -j 4 && make install
- 如果編譯的時候報錯
- /usr/bin/ld: cannot find -lcap
- 查找該 .so 檔案
-
find / -name "*libcap.so*"
/usr/lib64/libcap.so.2.22
/usr/lib64/libcap.so.2
- ln -sv /usr/lib64/libcap.so.2 /usr/lib64/libcap.so
- 預設配置:
- 主程式檔案:/usr/local/sbin/vsftpd
- 主配置檔案:/etc/vsfptd.conf
- PAM認證檔案:/etc/pam.d/vsftpd
- 匿名使用者主目錄:/var/ftp
- 匿名使用者的下載下傳目錄:/var/ftp/pub
-
vsftpd的安全原則主要有兩個:
- 隻允許支援虛拟使用者登入,關閉本地使用者和匿名使用者。
- 不允許使用root權限運作。
- 建立配置檔案存放目錄
- mkdir /etc/vsftpd
- 拷貝新的配置檔案到 /etc/vsftpd 目錄
- 建立使用者以及共享目錄、目錄權限
- 建立虛拟使用者密碼明文檔案,使用前面安裝的db4-utils元件生成密碼認證檔案:
-
vim /etc/vsftpd/access.txt
zhangsan #使用者名
123456 #密碼
lisi
123456
- 使用前面安裝的db4-utils元件生成密碼認證檔案:
- db_load -T -t hash -f /etc/vsftpd/access.txt /etc/vsftpd/access.db
- 編輯vsftpd的PAM認證檔案:
-
vim /etc/pam.d/vsftpd
auth required /lib64/security/pam_userdb.so db=/etc/vsftpd/access
account required /lib64/security/pam_userdb.so db=/etc/vsftpd/access
- 編輯配置主檔案 /etc/vsftpd/vsftpd.conf
- cp /etc/vsftpd/vsftpd.conf{,.bak}
- vim /etc/vsftpd/vsftpd.conf
-
#禁止匿名使用者
anonymous_enable=NO
local_enable=YES
write_enable=YES
#不啟動鎖定使用者名單,所有的使用者都将被鎖定不允許通路上級目錄,隻允許通路其主目錄
chroot_local_user=YES
chroot_list_enable=NO
#啟動log
xferlog_enable=YES
xferlog_std_format=YES
xferlog_file=/etc/vsftpd/vsftpd.log
#開啟虛拟使用者
guest_enable=YES
#FTP虛拟使用者對應的系統使用者
guest_username=vsftpd
#PAM認證檔案/etc/pam.d/vsftpd
pam_service_name=vsftpd
virtual_use_local_privs=YES
- 編寫 vsftpd 啟動 腳本:
-
/etc/init.d/vsftpd
#!/bin/bash
#
# vsftpd This shell script takes care of starting and stopping
# standalone vsftpd.
#
# chkconfig: - 60 50
# description: Vsftpd is a ftp daemon, which is the program
# that answers incoming ftp service requests.
# processname: vsftpd
# config: /etc/vsftpd/vsftpd.conf
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
[ -x /usr/local/sbin/vsftpd ] || exit 0
RETVAL=0
prog="vsftpd"
start() {
# Start daemons.
if [ -d /etc/vsftpd ] ; then
for i in `ls /etc/vsftpddisable = yes/g' /etc/xinetd.d/vsftpd
- sed -in 's/disable.*=.*/disable = yes/g' /etc/xinetd.d/vsftpdn
- 啟動 vsftpd
- service vsftpd start
- 登陸測試
- 開機啟動,重新開機測試
- chkconfig vsftpd on