LoginSignup
0
0

More than 3 years have passed since last update.

sudoの脆弱性対応

Last updated at Posted at 2021-03-04

2021年1月26日に発表されたsudoの脆弱性について対応した内容を以下に記述します。

■対象サーバー
CentOS6.5

/etc/sudoersの権限設定内容は以下の通り

[root@db01 ~]# grep -A 2 '## Allow root' /etc/sudoers
## Allow root to run any commands anywhere
root    ALL=(ALL)       ALL
oracle  ALL=(ALL)       ALL

UPDATE前のsudoバージョン

[root@db01 ~]# rpm -qa sudo
sudo-1.8.6p3-20.el6_7.x86_64

デフォルトのyum updateだとこのバージョンが最新となるが...

[root@db01 ~]# yum update sudo
読み込んだプラグイン:fastestmirror, refresh-packagekit, security
更新処理の設定をしています
Loading mirror speeds from cached hostfile
base                                                                                           | 3.7 kB
extras                                                                                         | 3.4 kB
updates                                                                                        | 3.4 kB
更新と設定されたパッケージがありません。

このバージョンだと脆弱性が解消されていない

[oracle@db01 ~]$ sudoedit -s /
[sudo] password for oracle:
sudoedit: /: 通常ファイルではありません

以下サイトによると、sudoのバージョンについて、上記コマンドを実行した際「usage:~」と表示されれば脆弱性が解消されており、「sudoedit:~」と表示されたら脆弱性が解消されていないとの事。

参考URL)https://www.jpcert.or.jp/at/2021/at210005.html

脆弱性対象バージョンは以下の通り。
- sudo バージョン 1.8.2 から 1.8.31p2
- sudo バージョン 1.9.0 から 1.9.5p1

sudo公式サイトより脆弱性対応バージョンのsudoをダウンロードする

[root@db01 tmp]# wget https://github.com/sudo-project/sudo/releases/download/SUDO_1_9_5p2/sudo-1.9.5-3.el6.x86_64.rpm
--2021-03-05 03:16:10--  https://github.com/sudo-project/sudo/releases/download/SUDO_1_9_5p2/sudo-1.9.5-3.el6.x86_64.rpm
github.com をDNSに問いあわせています... 13.114.40.48
github.com|13.114.40.48|:443 に接続しています... 接続しました。
HTTP による接続要求を送信しました、応答を待っています... 302 Found
場所: https://github-releases.githubusercontent.com/57972154/9bfacb80-5fc6-11eb-9a63-3f50d94d454f?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20210304%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210304T181610Z&X-Amz-Expires=300&X-Amz-Signature=ef43331dbb2d2e02e8b96691d691a0f4139e1452c987001a3d4c3a6ed5343254&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=57972154&response-content-disposition=attachment%3B%20filename%3Dsudo-1.9.5-3.el6.x86_64.rpm&response-content-type=application%2Foctet-stream [続く]
--2021-03-05 03:16:10--  https://github-releases.githubusercontent.com/57972154/9bfacb80-5fc6-11eb-9a63-3f50d94d454f?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20210304%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210304T181610Z&X-Amz-Expires=300&X-Amz-Signature=ef43331dbb2d2e02e8b96691d691a0f4139e1452c987001a3d4c3a6ed5343254&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=57972154&response-content-disposition=attachment%3B%20filename%3Dsudo-1.9.5-3.el6.x86_64.rpm&response-content-type=application%2Foctet-stream
github-releases.githubusercontent.com をDNSに問いあわせています... 185.199.108.154, 185.199.110.154, 185.199.109.154, ...
github-releases.githubusercontent.com|185.199.108.154|:443 に接続しています... 接続しました。
HTTP による接続要求を送信しました、応答を待っています... 200 OK
長さ: 2235944 (2.1M) [application/octet-stream]
`sudo-1.9.5-3.el6.x86_64.rpm.1' に保存中

100%[==========================================================================================>] 2,235,944   2.91M/s 時間 0.7s

2021-03-05 03:16:11 (2.91 MB/s) - `sudo-1.9.5-3.el6.x86_64.rpm.1' へ保存完了 [2235944/2235944]

拡張子がrpm.1でダウンロードされたのでrpmにリネームする

[root@db01 tmp]# mv sudo-1.9.5-3.el6.x86_64.rpm.1 sudo-1.9.5-3.el6.x86_64.rpm

インストールする

[root@db01 tmp]# yum install sudo-1.9.5-3.el6.x86_64.rpm
読み込んだプラグイン:fastestmirror, refresh-packagekit, security
インストール処理の設定をしています
sudo-1.9.5-3.el6.x86_64.rpm を調べています: sudo-1.9.5-3.el6.x86_64
次のリポジトリーへの更新として sudo-1.9.5-3.el6.x86_64.rpm を設定します: sudo-1.8.6p3-20.el6_7.x86_64
Loading mirror speeds from cached hostfile
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> Package sudo.x86_64 0:1.8.6p3-20.el6_7 will be 更新
---> Package sudo.x86_64 0:1.9.5-3.el6 will be an update
--> 依存性解決を終了しました。

依存性を解決しました

====================================================================================================================================
 パッケージ              アーキテクチャ            バージョン                     リポジトリー                                 容量
====================================================================================================================================
更新:
 sudo                    x86_64                    1.9.5-3.el6                    /sudo-1.9.5-3.el6.x86_64                    7.9 M

トランザクションの要約
====================================================================================================================================
アップグレード       1 パッケージ

合計容量: 7.9 M
これでいいですか? [y/N]y
パッケージをダウンロードしています:
rpm_check_debug を実行しています
トランザクションのテストを実行しています
トランザクションのテストを成功しました
トランザクションを実行しています
  更新                    : sudo-1.9.5-3.el6.x86_64                                                                             1/2
警告: /etc/sudoers は /etc/sudoers.rpmnew として作成されました。
  整理中                  : sudo-1.8.6p3-20.el6_7.x86_64                                                                        2/2
  Verifying               : sudo-1.9.5-3.el6.x86_64                                                                             1/2
  Verifying               : sudo-1.8.6p3-20.el6_7.x86_64                                                                        2/2

更新:
  sudo.x86_64 0:1.9.5-3.el6

完了しました!

sudoが修正版のバージョンに更新されたことを確認

[root@db01 tmp]# rpm -qa sudo
sudo-1.9.5-3.el6.x86_64

確認コマンドを実行し、「usage:~」と表示されることを確認

[oracle@db01 ~]$ sudoedit -s /
usage: sudoedit [-AknS] [-r role] [-t type] [-C num] [-D directory] [-g group] [-h host] [-p prompt] [-R directory] [-T timeout]
                [-u user] file ...

これでsudo脆弱性対応は完了しました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0