3
4

More than 1 year has passed since last update.

脆弱性対応の確認方法

Last updated at Posted at 2021-12-26

はじめに

サーバーの運用管理を行っている場合、サーバーやソフトウェアの脆弱性情報を受信し対応を行うと思います。その際、どのように対応すればよいかコマンドを含めまとめます。
基本的には、各組織において対応ポリシーがあると思いますが、ある程度容易かつスピード感を維持できる対応方法を記載します。
厳密に行うのであれば、脆弱性のターゲットとなっているモジュールやライブラリが使われているか詳細に確認するべきですが、開発元への確認や詳細な調査に時間がかかります。

0.実行環境

console
[marseille@hogehoge ~]$ hostnamectl 
   Static hostname: hogehoge
         Icon name: computer-vm
           Chassis: vm
        Machine ID: ********************************
           Boot ID: ********************************
    Virtualization: kvm
  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-1127.el7.x86_64
      Architecture: x86-64

[marseille@hogehoge ~]$ cat /etc/redhat-release 
CentOS Linux release 7.9.2009 (Core)

1.コマンドに脆弱性がある場合

対象となるコマンドがインストールされているか確認します。
今回は、CVE-2021-3621を事例とします。

A flaw was found in SSSD, where the sssctl command was vulnerable to shell command injection via the logs-fetch and cache-expire subcommands. This flaw allows an attacker to trick the root user into running a specially crafted sssctl command, such as via sudo, to gain root access. The highest threat from this vulnerability is to confidentiality, integrity, as well as system availability.

1-1. コマンドからパッケージの検索

コマンドに脆弱性があると判明しているため、コマンドを提供しているパッケージを検索します。
すべて同じファイル名であり、差分はパッケージのバージョンだけであることがわかります。

console
[marseille@hogehoge ~]$ yum provides */sssctl
読み込んだプラグイン:changelog, fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.cat.net
 * epel: mirrors.nipa.cloud
 * extras: mirrors.cat.net
 * updates: mirrors.cat.net
sssd-tools-1.16.5-10.el7.x86_64 : Userspace tools for use with the SSSD
リポジトリー        : base
一致          :
ファイル名    : /usr/sbin/sssctl

〜〜〜(省略)〜〜〜

sssd-tools-1.16.5-10.el7_9.11.x86_64 : Userspace tools for use with the SSSD
リポジトリー        : updates
一致          :
ファイル名    : /usr/sbin/sssctl

1-2.インストール状況の確認

1-1でパッケージ名が判明したため、パッケージのインストール状況を確認します。
確認する項目は「リポジトリー」の部分です。インストール済みならば「installed」と表示されますが、リポジトリ情報が表示される場合は未インストール状況となります。今回は未インストール状況であることがわかります。よって、今回は脆弱性に該当しないと判断できます。

console
[marseille@hogehoge ~]$ yum info sssd-tools
読み込んだプラグイン:changelog, fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.cat.net
 * epel: mirrors.nipa.cloud
 * extras: mirrors.cat.net
 * updates: mirrors.cat.net
利用可能なパッケージ
名前                : sssd-tools
アーキテクチャー    : x86_64
バージョン          : 1.16.5
リリース            : 10.el7_9.11
容量                : 437 k
リポジトリー        : updates/7/x86_64
要約                : Userspace tools for use with the SSSD
URL                 : https://pagure.io/SSSD/sssd/
ライセンス          : GPLv3+
説明                : Provides userspace tools for manipulating users, groups, and nested groups in
                    : SSSD when using id_provider = local in /etc/sssd/sssd.conf.
                    : 
                    : Also provides several other administrative tools:
                    :     * sss_debuglevel to change the debug level on the fly
                    :     * sss_seed which pre-creates a user entry for use in kickstarts
                    :     * sss_obfuscate for generating an obfuscated LDAP password
                    :     * sssctl -- an sssd status and control utility

2.パッケージ自体に脆弱性がある場合

対象となるコマンドがインストールされているか確認します。詳細な確認としてモジュールの活用状況も確認します。
今回は、CVE-2021-44790を事例とします。

A carefully crafted request body can cause a buffer overflow in the mod_lua multipart parser (r:parsebody() called from Lua scripts). The Apache httpd team is not aware of an exploit for the vulnerabilty though it might be possible to craft one. This issue affects Apache HTTP Server 2.4.51 and earlier.

2-1. キーワードからパッケージの検索

プロダクト名が判明しているため、愚直に検索キーワードとして「apache http server」とキーワード検索します。
もし検索に該当しない場合、キーワードを減らして再検索し出てこない場合はグーグル検索等でパッケージ名を探し出しましょう。

console
[marseille@hogehoge ~]$ yum search apache http server
読み込んだプラグイン:changelog, fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.cat.net
 * epel: mirrors.nipa.cloud
 * extras: mirrors.cat.net
 * updates: mirrors.cat.net
======================================================== N/S matched: apache, http, server ========================================================
apache-cimprov.x86_64 : Microsoft CIM management interface for Apache HTTP Server
httpd.x86_64 : Apache HTTP Server
httpd-devel.x86_64 : Development interfaces for the Apache HTTP server
httpd-itk.x86_64 : MPM Itk for Apache HTTP Server
httpd-manual.noarch : Documentation for the Apache HTTP server
httpd-tools.x86_64 : Tools for use with the Apache HTTP Server
sympa-httpd.x86_64 : Sympa with Apache HTTP Server
mod_auth_mellon.x86_64 : A SAML 2.0 authentication module for the Apache Httpd Server
mod_auth_openidc.x86_64 : OpenID Connect auth module for Apache HTTP Server
mod_dav_svn.x86_64 : Apache httpd module for Subversion server
mod_flvx.x86_64 : FLV progressive download streaming for the Apache HTTP Server
mod_geoip.x86_64 : GeoIP module for the Apache HTTP Server
mod_gnutls.x86_64 : GnuTLS module for the Apache HTTP server
mod_ldap.x86_64 : LDAP authentication modules for the Apache HTTP Server
mod_log_post.x86_64 : Module for the Apache web server to log all HTTP POST messages
mod_nss.x86_64 : SSL/TLS module for the Apache HTTP server
mod_perl.x86_64 : An embedded Perl interpreter for the Apache HTTP Server
mod_proxy_html.x86_64 : HTML and XML content filters for the Apache HTTP Server
mod_revocator.x86_64 : CRL retrieval module for the Apache HTTP server
mod_security.x86_64 : Security module for the Apache HTTP Server
mod_session.x86_64 : Session interface for the Apache HTTP Server
mod_speedycgi.x86_64 : SpeedyCGI module for the Apache HTTP Server
mod_ssl.x86_64 : SSL/TLS module for the Apache HTTP Server

  Full name and summary matches only, use "search all" for everything.

2-2.インストール状況の確認

2-1でパッケージ名が判明したため、パッケージのインストール状況を確認します。

console
[marseille@hogehoge ~]$ yum info httpd
読み込んだプラグイン:changelog, fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.cat.net
 * epel: mirrors.nipa.cloud
 * extras: mirrors.cat.net
 * updates: mirrors.cat.net
インストール済みパッケージ
名前                : httpd
アーキテクチャー    : x86_64
バージョン          : 2.4.6
リリース            : 97.el7.centos.2
容量                : 9.4 M
リポジトリー        : installed
提供元リポジトリー  : updates
要約                : Apache HTTP Server
URL                 : http://httpd.apache.org/
ライセンス          : ASL 2.0
説明                : The Apache HTTP Server is a powerful, efficient, and extensible
                    : web server.

パッケージ管理システムではインストール済みであり、バージョンが2.4.6と記載されています。
しかし独自でコンパイルしてインストールしていないかわからない場合は、念の為コマンドによるバージョン確認を行いましょう。

console
[marseille@hogehoge ~]$ apachectl -v
Server version: Apache/2.4.6 (CentOS)
Server built:   Nov 10 2021 14:26:31

2-3.モジュール利用状況の確認

コマンドを使ってモジュールを利用しているか確認します。「-M」オプションを利用するとロードするモジュールを確認できます。今回は該当のモジュールを利用しているため、パッケージのバージョンアップが必要となります。

console
[marseille@hogehoge ~]$ apachectl -h
Usage: /usr/sbin/httpd [-D name] [-d directory] [-f file]
                       [-C "directive"] [-c "directive"]
                       [-k start|restart|graceful|graceful-stop|stop]
                       [-v] [-V] [-h] [-l] [-L] [-t] [-T] [-S] [-X]
Options:
  -D name            : define a name for use in <IfDefine name> directives
  -d directory       : specify an alternate initial ServerRoot
  -f file            : specify an alternate ServerConfigFile
  -C "directive"     : process directive before reading config files
  -c "directive"     : process directive after reading config files
  -e level           : show startup errors of level (see LogLevel)
  -E file            : log startup errors to file
  -v                 : show version number
  -V                 : show compile settings
  -h                 : list available command line options (this page)
  -l                 : list compiled in modules
  -L                 : list available configuration directives
  -t -D DUMP_VHOSTS  : show parsed vhost settings
  -t -D DUMP_RUN_CFG : show parsed run settings
  -S                 : a synonym for -t -D DUMP_VHOSTS -D DUMP_RUN_CFG
  -t -D DUMP_MODULES : show all loaded modules 
  -M                 : a synonym for -t -D DUMP_MODULES
  -t                 : run syntax check for config files
  -T                 : start without DocumentRoot(s) check
  -X                 : debug mode (only one worker, do not detach)

[marseille@hogehoge ~]$ sudo apachectl -M | grep lua
 lua_module (shared)
3
4
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
3
4