Sudo 的全稱是“superuserdo”,它是Linux系統管理指令,允許用戶在不需要切換環境的前提下以其它用戶的權限運行應用程序或命令,通常是以 root 用戶身份運行命令,以減少 root 用戶的登錄和管理時間,同時提高安全性。該漏洞是 sudo安全策略繞過問題,可導致惡意用戶或程序在目標 Linux 系統上以 root 身份執行任意命令,即使 “sudoers configuration” 明確禁止該 root訪問權限也不例外。
但是有個Sudo bug 可導致 Linux和macOS 普通用戶獲得 root 權限,該漏洞存在于1.7.1至1.8.25p1版本中,但是1.8.26到1.8.30的版本可能會被濫用,因為它們包含了EOF處理該漏洞的變化。Sudo 1.7.1是在2009年4月19日發布的,而第一個補丁版本(1.8.26)是在2019年9月17日發布的,所以這個bug大約存在了10年之久。
為此我們可以升級當前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、升級sudo的版本
下載最新安裝包(1.8.31)
linuxidc@linuxidc:~/www.linuxidc.com$ wget http://www.sudo.ws/dist/sudo-1.8.31.tar.gz

3、編譯升級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]: 進入目錄“/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.查看升級后的版本
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,就這樣。
站長資訊網