使用Yassp工具包安裝安全的Solaris系統 (三)
2024-07-26 00:29:35
供稿:網友
7、補丁
系統在安裝時會自動安裝推薦補丁包,但是它并不包含所有的安全補丁。定期檢查最新的補丁,
安裝了最新安全補丁的系統要比沒有安裝的系統可靠的多。
補丁通常有標準補丁(Standard patches)、推薦補丁(Recommended patches)、安全補丁(
Security patches)、2000年補丁(Y2K patches),patch clusters是以上補丁的集成包。單點
補丁(Point patches)是針對特定問題的補丁。
通過下列方法,了解已知的漏洞及相應的補丁程序:
1. 訂閱相關組織及公司(如CERT/First、SUN、Bugtraq)的郵件列表。
2. 訂閱有關漏洞及補丁的郵件列表,如Security Portal(Solaris Digest)、
SecurityFocus(Sunr的部分)或者SANS。
3. 定期使用工具,檢查服務器上安裝的補丁是否與Sun發布的最新補丁列表相一致。
4. 一至兩月檢查一次Sun推薦的補丁包,需要注意的是安裝推薦補丁包時,如果對內核打補丁可
能會導致一些應用的不正常。
5. 某些第三方的應用的補丁也需要加以關注。
注:安裝補丁可能會改動Yassp的配置,因此在安裝完補丁重啟系統后,要仔細檢查是否啟動了不
需要的進程。
針對補丁的工具
* GetApplyPatch和CheckPatches是兩個管理Solaris補丁的Bshell的腳本工具。
1.CheckPatches使用showrev命令查看已經安裝的補丁,并與Solaris的補丁報告相比較,列出需
要安裝的推薦及安全補丁。補丁報告SolarisX.PatchReport通常在當前目錄下,也可以使用-f參
數通過FTP下載最新的補丁報告
>./CheckPatches -f
2.GetApplyPatch:用來獲得并安裝最新的補丁,使用補丁號碼作為執行腳本時的參數。運行時,
會提示是否下載,顯示補丁的README文件,安裝補丁后,刪除安裝目錄。使用'-b'參數以"batch
mode"運行,則不做提示。
>./GetApplyPatch 108875-07
CheckPatches.cron是一個自動運行的腳本,并將結果mail給管理員。
3.同時使用這兩個腳本文件,獲得需要的補丁并進行安裝。
>./CheckPatches | ./GetApplyPatch
GetApplyPatch.cron可以用來自動執行,取得補丁并進行安裝,但是關鍵任務的服務器上不推薦
使用它。
4.其它的特點:
* 帶有man幫助文件
* 支持Solaris Intel及Sparc,通過測試
* 可以設置ftp代理
* CheckPatches可以忽略無需安裝的補丁。比如,在Solaris8 x86系統中,運行CheckPatches后
,提示需要下面的補丁:
109897-03 SunOS 5.8_x86: USB patch
109952-01 SunOS 5.8_x86: jserver buffer overflow
110417-02 SunOS 5.8_x86: ATOK12 patch
對于這些補丁,我們并不想安裝。創建Solaris8_x86.PatchReport.Except,在文件中加入上面三
行,在次運行CheckPatches腳本時會將它們忽略。
* 也可以對CheckPatches的命令輸出做過濾,如:
./CheckPatches | egrep -v "109897|109952|110417"
* Sunsolve提供的Patchdiag工具,與最新的Patchdiag.xref一起,可以檢查系統缺少哪些補丁,
然后下載并安裝這些補丁。
* 使用SecurityFocus的vulnerability calculator工具,運行下面的命令
(http://securityfocus.com/focus/sun/form.html)
>showrev -p |cut -f2 -d' ' | xargs
將結果粘貼到窗囗中,然后選擇操作系統。在得出結果的中選擇與自己主機上的應用相關的內容
進行修補。
* FastPatch可以用來替代patchadd命令,它的執行速度更快。
* Patchreport是另外一個用perl語言編寫的非常全面的補丁檢查工具。
8、RPC
在關鍵任務主機,避免使用RPC服務。RPC使用動態分配的端囗及非標準的存取控制方法。但是,
確有一些應用需要使用RPC,如CDE、Open Windows、Disksuite及Legato Networker。
如何提高Disksuite的安全性
Disksuite是系統內置的工具,用來做磁盤鏡象及設置RAID。它需要RPC的支持(在inetd中運行的
rpc.metamhd和rpc.metad)。
1. 盡量不運行Disksuite
* 硬件RAID的好處在于不需要特殊的軟件支持。這對于對安全性要求較高的系統十分有利。而且
當出現問題時,你會發現Disksuite并不是太容易使用的。
* 對于象是系統盤等,數據并不會頻繁變動的系統盤,作鏡像(cold mirroring)就足夠了,使用
腳本mirror_boot.sh可以完成此項工作。
2. 運行Disksuite,但是停止RPC服務。停止inetd.conf中的'metad'服務會引起以下結果:
* 'metatool'將不會工作,但是命令行工具還可以運行。為了應付系統盤的災難性錯誤,最好了
解這些命令行工具。
* Disksets-系統間共享的metadevices將不能使用。
3. 如果使用Disksuite和RPC,使用Wietse Venema的RPCBIND。
* Solaris8系統自帶的Sunscreen EFS Lite Firewall可以用來對rpc服務的存取進行限制。
* ipfilter也可以用來做限制RPC服務訪問的本地防火墻。
* IPfilter可以在8以前的老版本的Solaris上運行,并且是免費的。
* It's doesn't have an RPC state based engine though(so it can't filter on RPC
PRogram names or allow RPC to specific destinations)。
* But it can be used to allow all localhost RPC traffic(enough for some RPC
applications such as Disksuite or CDE)and deny all remote traffice except,say,HTTP or
whatever service is provided to remote hosts。
* 使用Wietse Venema的rpcbind(包含在Yassp的tarball里),可以提供類似tcp wrapper的訪問控
制和日志記錄。Rpcbind是一種“目錄”服務用來定位某一種服務(通過RPC名或者RPC號)。因為
它并不是連接服務的中介,因此它并不能真正為RPC程序提供訪問控制。用端囗掃描器可以檢測激
活的RPC服務,除非內核被定制成過濾這些連接,否則并不能防止對服務的訪問。
9、日志、Cron、許可
配置日志及pruning:
* Syslog日志:Yassp使用修改過的/etc/syslog.conf配置,開啟了更多的日志記錄保存在
/var/adm/messages中。同時也安裝了一個可選的/etc/syslog.conf.server,是為loGhosts設計
的并將不同的服務存在分開的log文件中。
* Yassp關閉了root帳號cron中有關log的條目。添加了運行'daily'腳本。
配置Syslog
Syslog客戶端:在/etc/hosts文件中指定log服務器。
* 測試log服務器是否正常
logger -p auth.warn "test of syslog",檢查是否記錄在log服務器里。
* 在log服務器及本地同時記錄日志,取消/etc/syslog.conf中的下一行注釋:
*.err;auth.info;kern.debug /var/adm/messages
* 如果日志記錄不能正常工作,可以參照syslog.conf中的例子及提示。
Syslog服務器(loghost):
* log服務器需要一塊大的磁盤用來保存日志文件。
* 在Solaris8系統中,Yassp將以"-t"參數啟動syslog,因此它將不接受其它主機的記錄日志的請
求。如果想要設置集中的log服務器,需要在/etc/yassp.conf中設置SYSLOGFLAGS=""。
* Yassp還安裝了一個/etc/syslog.conf.server配置文件,是針對log服務器并將不同的服務產生
的日志存于/var/log目錄下不同的文件中。用它覆蓋配置文件并重新啟動syslog:
mv /etc/syslog.conf /etc/syslog.conf.client
cp /etc/syslog.conf.server /etc/syslog.conf
kill -l `cat /etc/syslog.pid`
* 使用rotate_log工具對日志進行管理和壓縮,在root的cron中加入:
##Prune syslog logs weekly,keeping the last 6 months or so:
55 23 * * 6 /secure/rotate_log -n 40 alertlog
55 23 * * 6 /secure/rotate_log -n 40 authlog
55 23 * * 6 /secure/rotate_log -n 40 cronlog
55 23 * * 6 /secure/rotate_log -n 40 daemonlog
55 23 * * 6 /secure/rotate_log -n 40 kernlog
55 23 * * 6 /secure/rotate_log -n 40 local0log
55 23 * * 6 /secure/rotate_log -n 40 local2log
55 23 * * 6 /secure/rotate_log -n 40 local5log
55 23 * * 6 /secure/rotate_log -n 40 newslog
55 23 * * 6 /secure/rotate_log -n 40 userlog
55 23 * * 6 /secure/rotate_log -n 40 lprlog
55 23 * * 6 /secure/rotate_log -n 40 maillogd
在root的cron中加入每年清理日志文件的條目
##Empty login/logout records at year end
0 0 31 12 * /secure/wtrim.pl wtmp 20
0 0 31 12 * /secure/wtrim.pl wtmpx 20
#
#Solaris 2.x logs
0 4 * * 6 /secure/totate_log -L /var/adm -n 30 loginlog
0 4 * * 6 /secure/rotate_log -L /var/adm -n 30 sulog
0 4 * * 6 /secure/rotate_log -L /var/adm -n 2 vold.log
0 4 * * 6 /secure/rotate_cron
其它的需要在root的cron設置條目:
每天與可靠的時間源進行時間同步,使用rdate(NTP會更加精確,但會帶來相應的風險)
##Synchronise the time:
0 * * * * /usr/bin/rdate YOURTIMEHOST >/dev/null 2>&1
安裝檢查重要進程是否運行的腳本,monitor_processes.pl并在root的cron中加入:
##Check that important processes are running during office hours:
##[If you run 7x24,modify accordingly]
0,30 8-19 * *1-5 /secure/monitor_processes.pl sshd httpd
每次安裝新的程序后,最好在文件中記錄下來,如:
cat >/etc/mods<15.10.00 james New install of Solaris8 and tools
EOF
10、限制SUID文件
設置SUID位的文件,允許用戶以文件所有者的權限執行此程序。常用來讓普通用戶執行只有root
能運行的程序,但是存在緩存溢出的風險。
* Solaris有很多“SUID root”的執行程序,每一個都會帶來風險,因此盡可能多的停止SUID程
序。
* 閱讀SUID的參考文件
發現系統中的SUID文件
使用find命令:
find / -perm -u+s -ls
find / -perm -g+s -ls 查找GUID程序
如何處理SUID文件:
* 直接刪除
* 關閉程序(chmod 000 FILENAME)
* 移去SUID位(chmod ug-s FILENAME)
* 對文件回以組限制(首先移去所有人的權限 chmod o-rwx),允許組訪問(chgrp MYGROUP
MYFILE)。
哪些SUID文件需要回以限制
* 在一些具有用戶帳號的敏感服務器上或者關鍵的進程由非root用戶運行,應盡可能地減少SUID
文件。
* 對于可靠性要求非常高的系統,建議除"pt_chmod","utmp_update"和"su"以外,其余全停。
* Reg Quinton解釋了每一個SolarisSUID程序,并給出配置建議。
* 例子:
* 象uucp這樣的工具,基本無用,可以刪除
pkgrm SUNWbnuu
chmod ug-s /usr/bin/cu /usr/bin/uu* /usr/lib/uucp/*
* 另一個沒有用處的工具包是kcms(Kodak Color Management System)
pkgrm SUNWkcspf SUNWcspx SUNWkcspg SUNWkcsrt
chmod ug-s /usr/openwin/bin/kcms*
* 如果不使用打印機
chmod ug-s /usr/lib/lp/bin/netpr /usr/sbin/lpmove /usr/bin/lp /usr/bin/lpset
/usr/bin/lpstat /usr/bin/cancel /etc/lp/alerts/printer
* 只允許root使用r命令
chmod ug-s /usr/bin/rcp /usr/bin/rlogin /usr/bin/rsh
* 只允許root對網絡進行偵聽及列出進程列表
chmod ug-s /usr/sbin/snoop /usr/sbin/devinfo /bin/rdist /usr/bin/netstat
/usr/local/bin/top /usr/sbin/traceroute /usr/local/bin/lsof /usr/bin/*/ps
/usr/ucb/*/ps /usr/sbin/*/whodo /usr/bin/*/uptime /usr/bin/*/w
* 只允許root做備份和恢復
chmod ug-s /usr/lib/fs/ufs/ufsdump /ufs/ib/fs/ufs/ufsrestore
* 假設不使用YP、NIS+
chmod ug-s /usr/bin/chkey
* 只允許root使用cron和at
chmod ug-s /usr/bin/at /usr/bin/atq /usr/bin/atrm /usr/bin/crontab
* 只允許root管理系統
chmod ug-s /usr/bin/admintool /usr/lib/fs/ufs/quota /usr/bin/tip /usr/bin/fdformat
/usr/bin/eject /usr/bin/volcheck /usr/bin/volrmmount /usr/bin/rmformat
* 不使用Openwindows和CDE
chmod ug-s /usr/dt/bin/* /usr/openwin/*/*
* Sendmail:不做email服務器的主機不需要sendmail設置SUID位
chmod u-s /usr/lib/sendmail
* 進行以上的操作后,以“最終用戶”模式安裝的Solaris8系統中,SUID文件列表如下:
usr/lib/pt_chmod /usr/lib/utmp_update /usr/bin/login /usr/bin/newgrp /usr/bin/newtask
/usr/bin/pfexec /usr/bin/su /usr/bin/passwd /usr/sbin/allocate /usr/sbin/mkdevalloc
/usr/sbin/mkdevmaps /usr/sbin/ping /usr/sbin/sacadm /usr/sbin/deallocate
/usr/sbin/list_devices /usr/sbin/pmconfig /opt/local/bin/ssh /usr/bin/yppasswd
/usr/bin/nispasswd are also SUID, but they are links to /usr/bin/passwd.
* 在package數據庫中仍然保留有末被改變的SUID文件
find / -perm -u+s -exec pkgchk -l -p {} /; |more
* 列出所有的SUID文件及屬于哪一個包
find / -perm -u+s -exec pkgchk -l -p {} /; | more