Sudo 的全稱是“superuserdo”,它是Linux系統(tǒng)管理指令,允許用戶在不需要切換環(huán)境的前提下以其它用戶的權(quán)限運(yùn)行應(yīng)用程序或命令,通常是以 root 用戶身份運(yùn)行命令,以減少 root 用戶的登錄和管理時(shí)間,同時(shí)提高安全性。該漏洞是 sudo安全策略繞過問題,可導(dǎo)致惡意用戶或程序在目標(biāo) Linux 系統(tǒng)上以 root 身份執(zhí)行任意命令,即使 “sudoers configuration” 明確禁止該 root訪問權(quán)限也不例外。
但是有個(gè)Sudo bug 可導(dǎo)致 Linux和macOS 普通用戶獲得 root 權(quán)限,該漏洞存在于1.7.1至1.8.25p1版本中,但是1.8.26到1.8.30的版本可能會(huì)被濫用,因?yàn)樗鼈儼薊OF處理該漏洞的變化。Sudo 1.7.1是在2009年4月19日發(fā)布的,而第一個(gè)補(bǔ)丁版本(1.8.26)是在2019年9月17日發(fā)布的,所以這個(gè)bug大約存在了10年之久。
為此我們可以升級(jí)當(dāng)前sudo版本至sudo-1.8.31。
開始
1、查看最開始的版本為:
linuxidc@linuxidc:~/www.linuxidc.com$ sudo –version
Sudo 版本 1.8.21p2
Sudoers 策略插件版本 1.8.21p2
Sudoers 文件語法版本 46
Sudoers I/O plugin version 1.8.21p2
2、升級(jí)sudo的版本
下載最新安裝包(1.8.31)
linuxidc@linuxidc:~/www.linuxidc.com$ wget http://www.sudo.ws/dist/sudo-1.8.31.tar.gz
3、編譯升級(jí)sudo的版本
linuxidc@linuxidc:~/www.linuxidc.com/sudo-1.8.31$ sudo make install
linuxidc@linuxidc:~/www.linuxidc.com/sudo-1.8.31$ ./configure
configure: Configuring Sudo version 1.8.31
checking for gcc… gcc
checking whether the C compiler works… yes
checking for C compiler default output file name… a.out
checking for suffix of executables…
checking whether we are cross compiling… no
checking for suffix of object files… o
checking whether we are using the GNU C compiler… yes
checking whether gcc accepts -g… yes
checking for gcc option to accept ISO C89… none needed
checking how to run the C preprocessor… gcc -E
checking for grep that handles long lines and -e… /bin/grep
checking for egrep… /bin/grep -E
checking for ANSI C header files… yes
linuxidc@linuxidc:~/www.linuxidc.com/sudo-1.8.31$ make
for d in lib/util plugins/group_file plugins/sudoers plugins/system_group src include doc examples; do
(cd $d && exec make all) && continue;
exit $?;
done
make[1]: 進(jìn)入目錄“/home/linuxidc/www.linuxidc.com/sudo-1.8.31/lib/util”
/bin/bash ../../libtool –tag=disable-static –mode=compile gcc -c -o digest.lo -I../../include -I../.. -I. -I../.. -D_PATH_SUDO_CONF=”/etc/sudo.conf” -DZLIB_CONST -D_FORTIFY_SOURCE=2 -g -O2 -fvisibility=hidden -fPIE -fstack-protector-strong ./digest.c
4、安裝
linuxidc@linuxidc:~/www.linuxidc.com/sudo-1.8.31$ sudo make install
[sudo] linuxidc 的密碼:
if test -d ./.hg && cd .; then
if hg log –style=changelog -r “sort(branch(.) or follow(), -date)” > ChangeLog.tmp; then
mv -f ChangeLog.tmp ChangeLog;
else
rm -f ChangeLog.tmp;
fi;
elif test -d ./.git && cd .; then
./log2cl.pl -b master > ChangeLog;
else
echo “ChangeLog data not available” > ChangeLog;
fi
for d in lib/util plugins/group_file plugins/sudoers plugins/system_group src include doc examples; do
(cd $d && exec make pre-install) && continue;
exit $?;
done
5.查看升級(jí)后的版本
linuxidc@linuxidc:~/www.linuxidc.com$ sudo –version
Sudo 版本 1.8.31
Sudoers 策略插件版本 1.8.31
Sudoers 文件語法版本 46
Sudoers I/O plugin version 1.8.31
OK,就這樣。