LoginSignup
5
1

More than 5 years have passed since last update.

脆弱性スキャンツール vuls 〜リモートサーバスキャン編〜

Last updated at Posted at 2018-05-31

vuls稼働サーバの構築

AWS EC2
AMI: CentOS Linux 7 x86_64 HVM EBS ENA 1804_2-b7ee8a69-ee97-4a49-9e68-afaee216db2e-ami-55a2322a.4 (ami-3185744e)

selinux無効化

# sudo su -
# setenforce 0
/etc/selinux/config
SELINUX=enforcing
↓
SELINUX=disabled

ロケール、タイムゾーン変更

# localectl set-locale LANG=ja_JP.utf8
# timedatectl set-timezone Asia/Tokyo
# source /etc/locale.conf

必要なパッケージインストール

# yum -y install sqlite git gcc make wget yum-plugin-changelog
# wget https://dl.google.com/go/go1.10.2.linux-amd64.tar.gz
# tar -C /usr/local -xzf go1.10.2.linux-amd64.tar.gz
/etc/profile.d/goenv.sh
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
# source /etc/profile.d/goenv.sh

vuls用のユーザ作成

# useradd vulsuser
# passwd vulsuser
# visudo
visudo(最終行に追加)
Defaults:vuls !requiretty
vulsuser ALL=(root) NOPASSWD: ALL
Defaults:vuls env_keep="http_proxy https_proxy HTTP_PROXY HTTPS_PROXY"

vulsユーザにて環境設定

# su - vulsuser
$ mkdir $HOME/go
$ ssh-keygen -m pem -b 4096
$ sudo chmod 700 /home/vulsuser/.ssh
$ sudo chmod 400 /home/vulsuser/.ssh/id_rsa
$ cp -a  /home/vulsuser/.ssh/id_rsa.pub /home/vulsuser/.ssh/authorized_keys
$ sudo chmod 600 /home/vulsuser/.ssh/authorized_keys
$ sudo mkdir /var/log/vuls
$ sudo chown vulsuser /var/log/vuls
$ sudo chmod 700 /var/log/vuls

go-cve-dictionaryのインストール

$ mkdir -p $GOPATH/src/github.com/kotakanbe
$ cd $GOPATH/src/github.com/kotakanbe
$ git clone https://github.com/kotakanbe/go-cve-dictionary.git
$ cd go-cve-dictionary
$ make install
$ cd $HOME
$ for i in `seq 2013 $(date +"%Y")`; do go-cve-dictionary fetchnvd -years $i; done
$ for i in `seq 2013 $(date +"%Y")`; do go-cve-dictionary fetchjvn -years $i; done

goval-dictionaryのインストール

$ su - vulsuser
$ mkdir -p $GOPATH/src/github.com/kotakanbe
$ cd $GOPATH/src/github.com/kotakanbe
$ git clone https://github.com/kotakanbe/goval-dictionary.git
$ cd goval-dictionary
$ make install
$ cd $HOME
$ goval-dictionary fetch-redhat 7

vulsのインストール

$ mkdir -p $GOPATH/src/github.com/future-architect
$ cd $GOPATH/src/github.com/future-architect
$ git clone https://github.com/future-architect/vuls.git
$ cd vuls
$ make install

vulsの設定

~/config.toml
[slack]
hookURL      = "https://hooks.slack.com/services/xxxxxxx/xxxxxxx/xxxxxxxxx"
channel      = "#aws-vuls"
iconEmoji    = ":thinking_face:"
authUser     = "脆弱性監視"
notifyUsers  = ["@channel"]

[servers]

[servers.localhost]
host = "localhost" 
port = "local"

設定の確認

$ cd 
$ vuls configtest
[May 31 12:11:22]  INFO [localhost] Validating config...
[May 31 12:11:22]  INFO [localhost] Detecting Server/Container OS...
[May 31 12:11:22]  INFO [localhost] Detecting OS of servers...
[May 31 12:11:22]  INFO [localhost] (1/1) Detected: localhost: centos 7.5.1804
[May 31 12:11:22]  INFO [localhost] Detecting OS of containers...
[May 31 12:11:22]  INFO [localhost] Checking dependencies...
[May 31 12:11:22]  INFO [localhost] Dependencies ... Pass
[May 31 12:11:22]  INFO [localhost] Checking sudo settings...
[May 31 12:11:22]  INFO [localhost] sudo ... No need
[May 31 12:11:22]  INFO [localhost] Scannable servers are below...
localhost

ローカルサーバのスキャン

スキャンの確認

$ vuls scan  --deep
(略)
$ vuls report -format-short-text -cvedb-path=$PWD/cve.sqlite3 --lang=ja
[May 31 12:18:48]  INFO [localhost] Validating config...
[May 31 12:18:48]  INFO [localhost] cve-dictionary: /home/vulsuser/cve.sqlite3
[May 31 12:18:48]  INFO [localhost] oval-dictionary: /home/vulsuser/oval.sqlite3
[May 31 12:18:48]  INFO [localhost] Loaded: /home/vulsuser/results/2018-05-31T12:17:28+09:00
localhost (centos7.5.1804)
==========================
Total: 5 (High:0 Medium:0 Low:0 ?:5)    344 installed, 23 updatable

CVE-2018-1000199    0.0  (unknown)
                    The Linux Kernel version 3.18 contains a dangerous feature vulnerability in
                    modify_user_hw_breakpoint() that can result in crash and possibly memory
                    corruption. This attack appear to be exploitable via local code execution and
                    the ability to use ptrace. This vulnerability appears to have been fixed in git
                    commit f67b15037a7a50c57f72e69a6d59941ad90a0f0f.
                    ---
                    https://nvd.nist.gov/vuln/detail/CVE-2018-1000199
                    https://access.redhat.com/security/cve/CVE-2018-1000199 (RHEL-CVE)
                    https://nvd.nist.gov/vuln-metrics/cvss/v2-calculator?name=CVE-2018-1000199
                    Confidence: 95 / ChangelogExactMatch

CVE-2018-1087       0.0  (unknown)
                    kernel KVM before versions kernel 4.16, kernel 4.16-rc7, kernel 4.17-rc1, kernel
                    4.17-rc2 and kernel 4.17-rc3 is vulnerable to a flaw in the way the Linux
                    kernel's KVM hypervisor handled exceptions delivered after a stack switch
                    operation via Mov SS or Pop SS instructions. During the stack switch operation,
                    the processor did not deliver interrupts and exceptions, rather they are
                    delivered once the first instruction after the stack switch is executed. An
                    unprivileged KVM guest user could use this flaw to crash the guest or,
                    potentially, escalate their privileges in the guest.
                    ---
                    https://nvd.nist.gov/vuln/detail/CVE-2018-1087
                    https://access.redhat.com/security/cve/CVE-2018-1087 (RHEL-CVE)
                    https://nvd.nist.gov/vuln-metrics/cvss/v2-calculator?name=CVE-2018-1087
                    Confidence: 95 / ChangelogExactMatch

CVE-2018-1124       0.0  (unknown)
                    procps-ng before version 3.3.15 is vulnerable to multiple integer overflows
                    leading to a heap corruption in file2strvec function. This allows a privilege
                    escalation for a local attacker who can create entries in procfs by starting
                    processes, which could result in crashes or arbitrary code execution in proc
                    utilities run by other users.
                    ---
                    https://nvd.nist.gov/vuln/detail/CVE-2018-1124
                    https://access.redhat.com/security/cve/CVE-2018-1124 (RHEL-CVE)
                    https://nvd.nist.gov/vuln-metrics/cvss/v2-calculator?name=CVE-2018-1124
                    Confidence: 95 / ChangelogExactMatch

CVE-2018-3639       0.0  (unknown)
                    投機的実行機能を持つ CPU に対するキャッシュサイドチャネル攻撃
                    投機的実行機能を持つ CPU
                    はキャッシュサイドチャネル攻撃に対して脆弱性があります。"Variant 4" あるいは
                    "SpectreNG" と呼ばれています。  投機的実行機能を持つ CPU
                    に対してキャッシュタイミングサイドチャネル攻撃を行う下記の脆弱性が報告されてい...
                    * CVE-2018-3639 (Variant 4 "SpectreNG") : Speculative Store Bypass (SSB) *
                    CVE-2018-3640 (Variant 3a) : Rogue System Register Read (RSRE)
                    詳細については、Project Zero <a
                    href="https://bugs.chromium.org/p/project-zero/issues/detail?id=1528">bug
                    report</a>、Intel security advisory <a
                    href="https://www.intel.com/content/www/us/en/security-center/advisory/intel-...
                    および ARM <a
                    href="https://developer.arm.com/support/arm-security-updates/speculative-proc...
                    を参照してください。  本脆弱性は、過去に公表された<a
                    href="https://www.kb.cert.org/vuls/id/584653">脆弱性</a> CVE-2017-5753 (Variant
                    1 "Spectre")、 CVE-2017-5715 (Variant 2 "Spectre")、 CVE-2017-5754 (Variant 3
                    "Meltdown") と類似するため "SpectreNG" という名称で報じられています。
                    ---
                    https://jvndb.jvn.jp/ja/contents/2018/JVNDB-2018-003386.html
                    https://access.redhat.com/security/cve/CVE-2018-3639 (RHEL-CVE)
                    https://nvd.nist.gov/vuln-metrics/cvss/v2-calculator?name=CVE-2018-3639
                    Confidence: 95 / ChangelogExactMatch

CVE-2018-8897       0.0  (unknown)
                    Intel ハードウェアアーキテクチャのデバッグ例外を適切に処理していない問題
                    いくつかのオペレーティングシステムやハイパーバイザーでは、Intel
                    ハードウェアアーキテクチャにおけるデバッグ例外の発生を想定していない、あるいは...
                    例外的な状況に対する不適切なチェックまたは処理 (CWE-703) - CVE-2018-8897 Intel
                    Software Developer Manual (SDM) Vol. 3A section 6.8.3 によれば、MOV SS
                    命令および POP SS 命令は、次の命令の命令境界まで、NMIs
                    を含む割り込み、データブレークポイント、およびシングルステップトラップ例外を禁...
                    (MOV SS 命令や POP SS
                    命令自体によりアクセスされるメモリ上のデータブレークポイントが禁止されます)。
                    SDM Vol 3A section 2.3 によれば、デバッグ例外は EFLAGS レジスタの IF フラグ
                    (Interrupt Enable Flag) では禁止されません。  MOV SS 命令および POP SS
                    命令の後に置かれている命令が、SYSCALL、SYSENTER、INT 3
                    などのように、3より高い特権レベル (CPL, Current Privilege Level) の OS
                    処理に制御を移すものだった場合、デバッグ例外が配送されるのは、3
                    より高い特権レベルに制御が移った後になります。  そのため特定の状況では、特定の
                    Intel x86-64 アーキテクチャ向け命令を使用した後に、リングレベル 3
                    で実行されている OS コンポーネントから 、より高位のリングレベル (多くの OS
                    ではリングレベル0) のデータを指すデバッグ例外が使用可能になります。
                    これにより、攻撃者はオペレーティングシステムの API
                    を使用して、機微なメモリ情報にアクセスしたり、高い特権レベルのオペレーティング...
                    ---
                    https://jvndb.jvn.jp/ja/contents/2018/JVNDB-2018-003031.html
                    https://access.redhat.com/security/cve/CVE-2018-8897 (RHEL-CVE)
                    https://nvd.nist.gov/vuln-metrics/cvss/v2-calculator?name=CVE-2018-8897
                    Confidence: 95 / ChangelogExactMatch

スキャン結果をSlackに投げる

$ vuls report --lang=ja -to-slack

スクリーンショット 2018-05-31 12.18.11.png

リモートサーバのスキャン

スキャン対象リモートサーバでの作業

AMI: CentOS Linux 7 x86_64 HVM EBS ENA 1804_2-b7ee8a69-ee97-4a49-9e68-afaee216db2e-ami-55a2322a.4 (ami-3185744e)

$ sudo su -
# yum -y install yum-plugin-changelog
# useradd -s /bin/bash vulsuser
# passwd vulsuser
visudo(最終行に追加)
vulsuser ALL=(root) NOPASSWD: ALL
# su - vulsuser
$ mkdir ~/.ssh
$ chmod 700 ~/.ssh

vuls稼働サーバの/home/vulsuser/.ssh/id_rsa.pubの内容をスキャン対象サーバの/home/vulsuser/.ssh/authorized_keysにコピー

~/.ssh/authorized_keys
ssh-rsa XXXXXXXXXX()XXXXXXXXX vulsuser@ip-xx-xx-xx-xx.ap-northeast-1.compute.internal
$ chmod 600 ~/.ssh/authorized_keys

vuls稼働サーバでの作業

vulsの設定

# su - vulsuser

vulsの設定ファイルにスキャン対象サーバを追加

~/config.toml
[servers.remote_server]
host = "xx.xx.xx.xx"
port = "22"
user = "vulsuser"
keyPath = "/home/vulsuser/.ssh/id_rsa"

設定の確認

$ cd 
$ vuls configtest
[May 31 12:43:55]  INFO [localhost] Validating config...
[May 31 12:43:55]  INFO [localhost] Detecting Server/Container OS...
[May 31 12:43:55]  INFO [localhost] Detecting OS of servers...
[May 31 12:43:55]  INFO [localhost] (1/2) Detected: localhost: centos 7.5.1804
[May 31 12:43:56]  INFO [localhost] (2/2) Detected: remote_server: centos 7.5.1804
[May 31 12:43:56]  INFO [localhost] Detecting OS of containers...
[May 31 12:43:56]  INFO [localhost] Checking dependencies...
[May 31 12:43:56]  INFO [localhost] Dependencies ... Pass
[May 31 12:43:56]  INFO [remote_server] Dependencies ... Pass
[May 31 12:43:56]  INFO [localhost] Checking sudo settings...
[May 31 12:43:56]  INFO [remote_server] sudo ... No need
[May 31 12:43:56]  INFO [localhost] sudo ... No need
[May 31 12:43:56]  INFO [localhost] Scannable servers are below...
remote_server localhost
$ vuls scan  --deep
(略)
$ vuls report -format-short-text -cvedb-path=$PWD/cve.sqlite3 --lang=ja
(略)

スキャン結果をSlackに投げる

$ vuls report --lang=ja -to-slack

スクリーンショット 2018-05-31 12.47.11.png

5
1
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
5
1