Update README

This commit is contained in:
kota kanbe
2017-08-07 05:57:09 +09:00
parent 2887dc0d36
commit d3014025b0
4 changed files with 536 additions and 541 deletions

View File

@@ -10,6 +10,8 @@ Vulnerability scanner for Linux/FreeBSD, agentless, written in golang.
[README in English](https://github.com/future-architect/vuls/blob/master/README.md)
Slackチームは[こちらから](http://goo.gl/forms/xm5KFo35tu)参加できます。(日本語でオッケーです)
![Vuls-Abstract](img/vuls-abstract.png)
[![asciicast](https://asciinema.org/a/bazozlxrw1wtxfu9yojyihick.png)](https://asciinema.org/a/bazozlxrw1wtxfu9yojyihick)
![Vuls-slack](img/vuls-slack-ja.png)
@@ -18,90 +20,7 @@ Slackチームは[こちらから](http://goo.gl/forms/xm5KFo35tu)参加でき
# TOC
- [Vuls: VULnerability Scanner](#vuls-vulnerability-scanner)
- [TOC](#toc)
- [Abstract](#abstract)
- [Main Features](#main-features)
- [What Vuls Doesn't Do](#what-vuls-doesnt-do)
- [Setup Vuls](#setup-vuls)
- [Tutorial: Local Scan Mode](#tutorial-local-scan-mode)
* [Step1. Launch Amazon Linux](#step1-launch-amazon-linux)
* [Step2. Install requirements](#step2-install-requirements)
* [Step3. Deploy go-cve-dictionary](#step3-deploy-go-cve-dictionary)
* [Step4. Deploy Vuls](#step4-deploy-vuls)
* [Step5. Config](#step5-config)
* [Step6. Check config.toml and settings on the server before scanning](#step6-check-configtoml-and-settings-on-the-server-before-scanning)
* [Step7. Start Scanning](#step7-start-scanning)
* [Step8. Reporting](#step8-reporting)
* [Step9. TUI](#step9-tui)
* [Step10. Web UI](#step10-web-ui)
- [Tutorial: Remote Scan Mode](#tutorial-remote-scan-mode)
* [Step1. Launch Another Amazon Linux](#step1-launch-another-amazon-linux)
* [Step2. Install Dependencies on the Remote Server](#step2-install-dependencies-on-the-remote-server)
* [Step3. Enable to SSH from Localhost](#step3-enable-to-ssh-from-localhost)
* [Step4. Config](#step4-config)
* [Step5. Check config.toml and settings on the server before scanning](#step5-check-configtoml-and-settings-on-the-server-before-scanning)
* [Step6. Start Scanning](#step6-start-scanning)
* [Step7. Reporting](#step7-reporting)
- [Architecture](#architecture)
* [A. Scan via SSH Mode (Remote Scan Mode)](#a-scan-via-ssh-mode-remote-scan-mode)
* [B. Scan without SSH (Local Scan Mode)](#b-scan-without-ssh-local-scan-mode)
* [go-cve-dictionary](#go-cve-dictionary)
* [Vuls](#vuls)
- [Performance Considerations](#performance-considerations)
- [Use Cases](#use-cases)
* [Scan all servers](#scan-all-servers)
* [Scan a single server](#scan-a-single-server)
- [Support OS](#support-os)
- [Usage: Automatic Server Discovery](#usage-automatic-server-discovery)
* [Example](#example)
- [Configuration](#configuration)
- [Usage: Configtest](#usage-configtest)
* [Dependencies on Target Servers](#dependencies-on-target-servers)
* [Check /etc/sudoers](#check-etcsudoers)
- [Usage: Scan](#usage-scan)
* [-ssh-native-insecure option](#-ssh-native-insecure-option)
* [-ask-key-password option](#-ask-key-password-option)
* [Example: Scan all servers defined in config file](#example-scan-all-servers-defined-in-config-file)
* [Example: Scan specific servers](#example-scan-specific-servers)
* [Example: Scan via shell instead of SSH.](#example-scan-via-shell-instead-of-ssh)
+ [cronで動かす場合](#cron%E3%81%A7%E5%8B%95%E3%81%8B%E3%81%99%E5%A0%B4%E5%90%88)
* [Example: Scan containers (Docker/LXD)](#example-scan-containers-dockerlxd)
+ [Docker](#docker)
+ [LXDコンテナをスキャンする場合](#lxd%E3%82%B3%E3%83%B3%E3%83%86%E3%83%8A%E3%82%92%E3%82%B9%E3%82%AD%E3%83%A3%E3%83%B3%E3%81%99%E3%82%8B%E5%A0%B4%E5%90%88)
- [Usage: Report](#usage-report)
* [How to read a report](#how-to-read-a-report)
+ [Example](#example-1)
+ [Summary part](#summary-part)
+ [Detailed Part](#detailed-part)
+ [Changelog Part](#changelog-part)
* [Example: Send scan results to Slack](#example-send-scan-results-to-slack)
* [Example: Put results in S3 bucket](#example-put-results-in-s3-bucket)
* [Example: Put results in Azure Blob storage](#example-put-results-in-azure-blob-storage)
* [Example: IgnoreCves](#example-ignorecves)
* [Example: Add optional key-value pairs to JSON](#example-add-optional-key-value-pairs-to-json)
* [Example: Use MySQL as a DB storage back-end](#example-use-mysql-as-a-db-storage-back-end)
* [Example: Use PostgreSQL as a DB storage back-end](#example-use-postgresql-as-a-db-storage-back-end)
* [Example: Use Redis as a DB storage back-end](#example-use-redis-as-a-db-storage-back-end)
- [Usage: Scan vulnerability of non-OS package](#usage-scan-vulnerability-of-non-os-package)
- [Usage: Integrate with OWASP Dependency Check to Automatic update when the libraries are updated (Experimental)](#usage-integrate-with-owasp-dependency-check-to-automatic-update-when-the-libraries-are-updated-experimental)
- [Usage: TUI](#usage-tui)
* [Display the latest scan results](#display-the-latest-scan-results)
* [Display the previous scan results](#display-the-previous-scan-results)
- [Display the previous scan results using peco](#display-the-previous-scan-results-using-peco)
- [Usage: go-cve-dictionary on different server](#usage-go-cve-dictionary-on-different-server)
- [Usage: Update NVD Data](#usage-update-nvd-data)
- [レポートの日本語化](#%E3%83%AC%E3%83%9D%E3%83%BC%E3%83%88%E3%81%AE%E6%97%A5%E6%9C%AC%E8%AA%9E%E5%8C%96)
* [fetchnvd, fetchjvnの実行順序の注意](#fetchnvd-fetchjvn%E3%81%AE%E5%AE%9F%E8%A1%8C%E9%A0%86%E5%BA%8F%E3%81%AE%E6%B3%A8%E6%84%8F)
* [スキャン実行](#%E3%82%B9%E3%82%AD%E3%83%A3%E3%83%B3%E5%AE%9F%E8%A1%8C)
- [Update Vuls With Glide](#update-vuls-with-glide)
- [Misc](#misc)
- [Related Projects](#related-projects)
- [Data Source](#data-source)
- [Authors](#authors)
- [Contribute](#contribute)
- [Change Log](#change-log)
- [License](#license)
TODO
----
@@ -130,13 +49,29 @@ Vulsは上に挙げた手動運用での課題を解決するツールであり
- Linuxサーバに存在する脆弱性をスキャン
- Ubuntu, Debian, CentOS, Amazon Linux, RHEL, Raspbianに対応
- クラウド、オンプレミス、Docker
- 高精度なスキャン
- Vulsは複数の脆弱性データベースを使っている
- OVAL
- RHSA/ALAS/ELSA/FreeBSD-SA
- Changelog
- FastスキャンとDeepスキャン
- Fastスキャン
- root権限必要なし
- スキャン対象サーバの負荷ほぼなし
- Deepスキャン
- Changelogの差分を取得し、そこに含まれる脆弱性を検知
- スキャン対象サーバに負荷がかかる場合がある
- リモートスキャンとローカルスキャン
- リモートスキャン
- スキャン対象サーバにSSH接続可能なマシン1台にセットアップするだけで動作
- ローカルスキャン
- もし中央のサーバから各サーバにSSH接続できない環境の場合はローカルスキャンモードでスキャン可能
- OSパッケージ管理対象外のミドルウェアをスキャン
- プログラミング言語のライブラリやフレームワーク、ミドルウェアの脆弱性スキャン
- CPEに登録されているソフトウェアが対象
- エージェントレスアーキテクチャ
- スキャン対象サーバにSSH接続可能なマシン1台にセットアップするだけで動作
- 非破壊スキャン(SSHでコマンド発行するだけ)
- AWSでの脆弱性/侵入テスト事前申請は必要なし
- 毎日スケジュール実行すれば新規に公開された脆弱性にすぐに気付くことができる
- 設定ファイルのテンプレート自動生成
- CIDRを指定してサーバを自動検出、設定ファイルのテンプレートを生成
- EmailやSlackで通知可能日本語でのレポートも可能
@@ -159,7 +94,19 @@ Vulsのセットアップは以下の2パターンがある
see https://github.com/future-architect/vuls/tree/master/setup/docker
- 手動でセットアップ
Hello Vulsチュートリアルでは手動でのセットアップ方法で説明する
チュートリアルでは手動でのセットアップ方法で説明する
----
# Tutorial
1. Tutorial: Local Scan Mode
- Launch CentOS on AWS
- Deploy Vuls
- Scan localhost, Reporting
1. Tutorial: Remote Scan Mode
- Launch Ubuntu Linux on AWS
- このUbuntuを先程セットアップしたVulsからスキャンする
----
@@ -168,9 +115,10 @@ Hello Vulsチュートリアルでは手動でのセットアップ方法で説
本チュートリアルでは、Amazon EC2にVulsをセットアップし、自分に存在する脆弱性をスキャンする方法を説明する。
手順は以下の通り
1. Amazon Linuxを新規作成
1. CentOSを新規作成
1. 必要なソフトウェアをインストール
1. go-cve-dictionaryをデプロイ
1. goval-dictionaryをデプロイ
1. Vulsをデプロイ
1. 設定
1. 設定ファイルと、スキャン対象サーバの設定のチェック
@@ -179,9 +127,9 @@ Hello Vulsチュートリアルでは手動でのセットアップ方法で説
1. TUI(Terminal-Based User Interface)で結果を参照する
1. Web UI([VulsRepo](https://github.com/usiusi360/vulsrepo))で結果を参照する
## Step1. Launch Amazon Linux
## Step1. Launch CentOS7
- 今回は説明のために、脆弱性を含む古いAMIを使う (amzn-ami-hvm-2015.09.1.x86_64-gp2 - ami-383c1956)
- 今回は説明のために、脆弱性を含む古いAMIを使う
- EC2作成時に自動アップデートされるとVulsスキャン結果が0件になってしまうので、cloud-initに以下を指定してEC2を作成する。
```
@@ -199,14 +147,14 @@ Vulsセットアップに必要な以下のソフトウェアをインストー
- git
- gcc
- GNU Make
- go v1.7.1 or later (The latest version is recommended)
- go v1.8.3 or later (The latest version is recommended)
- https://golang.org/doc/install
```bash
$ ssh ec2-user@52.100.100.100 -i ~/.ssh/private.pem
$ sudo yum -y install sqlite git gcc make
$ wget https://storage.googleapis.com/golang/go1.7.1.linux-amd64.tar.gz
$ sudo tar -C /usr/local -xzf go1.7.1.linux-amd64.tar.gz
$ ssh centos@52.100.100.100 -i ~/.ssh/private.pem
$ sudo yum -y install sqlite git gcc make wget
$ wget https://storage.googleapis.com/golang/go1.8.3.linux-amd64.tar.gz
$ sudo tar -C /usr/local -xzf go1.8.3.linux-amd64.tar.gz
$ mkdir $HOME/go
```
/etc/profile.d/goenv.sh を作成し、下記を追加する。
@@ -228,7 +176,7 @@ $ source /etc/profile.d/goenv.sh
```bash
$ sudo mkdir /var/log/vuls
$ sudo chown ec2-user /var/log/vuls
$ sudo chown centos /var/log/vuls
$ sudo chmod 700 /var/log/vuls
$
$ mkdir -p $GOPATH/src/github.com/kotakanbe
@@ -238,7 +186,7 @@ $ cd go-cve-dictionary
$ make install
```
バイナリは、`$GOPATH/bin`以下に生成される
もしもインストールプロセスが途中で止まる場合は、Out of memory errorが発生している可能性があるので、インスタンスタイプを大きくして再実行してみてください。
NVDから脆弱性データベースを取得する。
環境によって異なるが、AWS上では10分程度かかる。
@@ -251,14 +199,34 @@ $ ls -alh cve.sqlite3
-rw-r--r-- 1 ec2-user ec2-user 7.0M Mar 24 13:20 cve.sqlite3
```
日本語化したい場合は、JVNから脆弱性データベースを取得する。
脆弱性レポートを日本語化したい場合は、JVNから脆弱性データベースを取得する。
```bash
$ cd $HOME
$ for i in `seq 1998 $(date +"%Y")`; do go-cve-dictionary fetchjvn -years $i; done
```
## Step4. Deploy Vuls
## Step4. Deploy goval-dictionary
[goval-dictionary](https://github.com/kotakanbe/goval-dictionary)
```bash
$ 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
```
The binary was built under `$GOPATH/bin`
もしもインストールプロセスが途中で止まる場合は、Out of memory errorが発生している可能性があるので、インスタンスタイプを大きくして再実行してみてください。
今回はCentOSがスキャン対象なので、RedHatが公開しているOVAL情報を取り込む. [README](https://github.com/kotakanbe/goval-dictionary#usage-fetch-oval-data-from-redhat)
```bash
$ goval-dictionary fetch-redhat 5 6 7
```
## Step5. Deploy Vuls
新規にターミナルを起動し、先ほど作成したEC2にSSH接続する。
```
@@ -268,8 +236,10 @@ $ git clone https://github.com/future-architect/vuls.git
$ cd vuls
$ make install
```
The binary was built under `$GOPATH/bin`
もしもインストールプロセスが途中で止まる場合は、Out of memory errorが発生している可能性があるので、インスタンスタイプを大きくして再実行してみてください。
## Step5. Config
## Step6. Config
Vulsの設定ファイルを作成するTOMLフォーマット
@@ -279,104 +249,101 @@ $ cat config.toml
[servers]
[servers.localhost]
host = "localhost"
port = "local"
host = "localhost"
port = "local"
```
Root権限が必要なディストリビューションもあるので、スキャン対象サーバの/etc/sudoersを変更する。
パスワードありのsudoはセキュリティ上の理由からサポートしていないので、スキャンに必要なコマンドは、`NOPASSAWORD`として、remote host上の`etc/sudoers`に定義しておく。
See [Usage: Configtest#Check /etc/sudoers](#check-etcsudoers)
## Step6. Check config.toml and settings on the server before scanning
## Step7. Check config.toml and settings on the server before scanning
```
$ vuls configtest
```
詳細は [Usage: configtest](#usage-configtest) を参照
## Step7. Start Scanning
## Step8. Start Scanning
```
$ vuls scan
... snip ...
Scan Summary
============
localhost amazon 2015.09 94 CVEs 103 updatable packages
One Line Summary
================
localhost centos7.3.1611 31 updatable packages
```
## Step8. Reporting
## Step9. Reporting
View one-line summary
```
$ vuls report -format-one-line-text -cvedb-path=$PWD/cve.sqlite3
$ vuls report -lang=ja -format-one-line-text -cvedb-path=$PWD/cve.sqlite3 -ovaldb-path=$PWD/oval.sqlite3
One Line Summary
================
localhost Total: 94 (High:19 Medium:54 Low:7 ?:14) 103 updatable packages
localhost Total: 101 (High:35 Medium:50 Low:16 ?:0) 31 updatable packages
```
View short summary.
```
$ vuls report -format-short-text -cvedb-path=$PWD/cve.sqlite3 --lang=ja
$ vuls report -lang=ja -format-short-text |less
localhost (amazon 2015.09)
===========================
Total: 94 (High:19 Medium:54 Low:7 ?:14) 103 updatable packages
localhost (centos7.3.1611)
==========================
Total: 101 (High:35 Medium:50 Low:16 ?:0) 31 updatable packages
CVE-2016-5636 10.0 (High) CPython の zipimport.c の get_data 関数における整数オーバーフローの脆弱性
http://jvndb.jvn.jp/ja/contents/2016/JVNDB-2016-004528.html
https://access.redhat.com/security/cve/CVE-2016-5636
python27-2.7.10-4.119.amzn1 -> python27-2.7.12-2.120.amzn1
python27-devel-2.7.10-4.119.amzn1 -> python27-devel-2.7.12-2.120.amzn1
python27-libs-2.7.10-4.119.amzn1 -> python27-libs-2.7.12-2.120.amzn1
Confidence: 100 / YumUpdateSecurityMatch
CVE-2017-7895 10.0 HIGH (nvd)
Linux Kernel の NFSv2/NFSv3
サーバの実装におけるポインタ演算エラーを誘発される脆弱性
Linux Kernel の NFSv2/NFSv3
サーバの実装は、バッファの終端に対する特定のチェックが欠落しているため、ポイン...
(pointer-arithmetic error)
を誘発されるなど、不特定の影響を受ける脆弱性が存在します。
---
http://jvndb.jvn.jp/ja/contents/2017/JVNDB-2017-003674.html
https://access.redhat.com/security/cve/CVE-2017-7895 (RHEL-CVE)
10.0/AV:N/AC:L/Au:N/C:C/I:C/A:C (nvd)
10.0/AV:N/AC:L/Au:N/C:C/I:C/A:C (jvn)
https://nvd.nist.gov/vuln-metrics/cvss/v2-calculator?name=CVE-2017-7895
6.5/CVSS:3.0/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N (redhat)
https://nvd.nist.gov/vuln-metrics/cvss/v3-calculator?name=CVE-2017-7895
Confidence: 100 / OvalMatch
... snip ...
````
View full report.
```
$ vuls report -format-full-text -cvedb-path=$PWD/cve.sqlite3 --lang=ja
$ vuls report -lang=ja -format-full-text |less
localhost (amazon 2015.09)
============================
Total: 94 (High:19 Medium:54 Low:7 ?:14) 103 updatable packages
localhost (centos7.3.1611)
==========================
Total: 101 (High:35 Medium:50 Low:16 ?:0) 31 updatable packages
CVE-2016-5636
-------------
Score 10.0 (High)
Vector (AV:N/AC:L/Au:N/C:C/I:C/A:C)
Title CPython の zipimport.c の get_data 関数における整数オーバーフローの脆弱性
Description CPython (別名 Python) の zipimport.c の get_data
関数には、整数オーバーフローの脆弱性が存在します。
CVE-2015-2806
----------------
Max Score 10.0 HIGH (nvd)
nvd 10.0/AV:N/AC:L/Au:N/C:C/I:C/A:C
redhat 2.6/AV:N/AC:H/Au:N/C:N/I:N/A:P
redhat 3.3/CVSS:3.0/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:L
CVSSv2 Calc https://nvd.nist.gov/vuln-metrics/cvss/v2-calculator?name=CVE-2015-2806
CVSSv3 Calc https://nvd.nist.gov/vuln-metrics/cvss/v3-calculator?name=CVE-2015-2806
Summary Stack-based buffer overflow in asn1_der_decoding in libtasn1 before 4.4 allows
remote attackers to have unspecified impact via unknown vectors.
Source https://nvd.nist.gov/vuln/detail/CVE-2015-2806
RHEL-CVE https://access.redhat.com/security/cve/CVE-2015-2806
CWE-119 (nvd) https://cwe.mitre.org/data/definitions/119.html
Package/CPE libtasn1-3.8-3.el7 -
Confidence 100 / OvalMatch
補足情報 : CWE による脆弱性タイプは、CWE-190: Integer Overflow or Wraparound
(整数オーバーフローまたはラップアラウンド) と識別されています。
http://cwe.mitre.org/data/definitions/190.html
CWE-190 https://cwe.mitre.org/data/definitions/190.html
CWE-190(JVN) http://jvndb.jvn.jp/ja/cwe/CWE-190.html
JVN http://jvndb.jvn.jp/ja/contents/2016/JVNDB-2016-004528.html
NVD https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2016-5636
MITRE https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2016-5636
CVE Details http://www.cvedetails.com/cve/CVE-2016-5636
CVSS Claculator https://nvd.nist.gov/cvss/v2-calculator?name=CVE-2016-5636&vector=(AV:N/AC:L/...
RHEL-CVE https://access.redhat.com/security/cve/CVE-2016-5636
ALAS-2016-724 https://alas.aws.amazon.com/ALAS-2016-724.html
Package python27-2.7.10-4.119.amzn1 -> python27-2.7.12-2.120.amzn1
python27-devel-2.7.10-4.119.amzn1 -> python27-devel-2.7.12-2.120.amzn1
python27-libs-2.7.10-4.119.amzn1 -> python27-libs-2.7.12-2.120.amzn1
Confidence 100 / YumUpdateSecurityMatch
... snip ...
```
## Step9. TUI
## Step10. TUI
Vulsにはスキャン結果の詳細を参照できるイカしたTUI(Terminal-Based User Interface)が付属している。
@@ -386,7 +353,7 @@ $ vuls tui
![Vuls-TUI](img/hello-vuls-tui.png)
## Step10. Web UI
## Step11. Web UI
[VulsRepo](https://github.com/usiusi360/vulsrepo)はスキャン結果をビボットテーブルのように分析可能にするWeb UIである。
[Online Demo](http://usiusi360.github.io/vulsrepo/)があるので試してみて。
@@ -397,33 +364,28 @@ $ vuls tui
SSHを用いてリモートのホストをスキャンする方法を説明する。
1. Amazon Linuxを新規に1台作成スキャン対象
1. 必要なソフトウェアをインストール
1. RemoteホストにlocalhostからSSH可能にする
1. 設定
1. Ubuntu Linuxを新規に1台作成スキャン対象
1. スキャン対象のRemoteホストにlocalhostからSSH可能にする
1. config.tomlの設定
1. 設定ファイルと、スキャン対象サーバの設定のチェック
1. Scan
1. Reporting
先程のチュートリアルで作成したVulsサーバ(以下localhostと記述)を用いる。
## Step1. Launch Another Amazon Linux
## Step1. Launch new Ubuntu Linux (the server to be sacnned)
[Tutorial: Local Scan Mode#Step1. Launch Amazon Linux](#step1-launch-amazon-linux)と同じ
[Tutorial: Local Scan Mode#Step1. Launch CentOS7](#step1-launch-centos7)のようにUbuntu Linuxを新規に作成する。
新規にターミナルを開いて今作成したEC2にSSH接続する。
$HOME/.ssh/known_hostsにリモートホストのHost Keyを追加するために、スキャン前にリモートホストにSSH接続する必要がある。
## Step2. Install Dependencies on the Remote Server
ディストリビューションによってはスキャンに必要な依存ソフトウェアをインストールする必要がある。
これらはリモートサーバ上に手動かAnsibleなどでインストールする。
依存ソフトウェアの詳細は [Dependencies on Target Servers](#dependencies-on-target-servers) を参照。
## Step3. Enable to SSH from Localhost
## Step2. Enable to SSH from localhost
VulsはSSHパスワード認証をサポートしてない。SSHの鍵認証の設定をしなければならない。
localhost上でkeypairを作成し、remote host上のauthorized_keysに追加する。
- Localhost
- localhost
```bash
$ ssh-keygen -t rsa
```
@@ -439,47 +401,50 @@ $ vim ~/.ssh/authorized_keys
```
Paste from the clipboard to ~/.ssh/.authorized_keys
パスワードありのsudoはセキュリティ上の理由からサポートしていないので、スキャンに必要なコマンドは、`NOPASSAWORD`として、remote host上の`etc/sudoers`に定義しておく
See [Usage: Configtest#Check /etc/sudoers](#check-etcsudoers)
localhostのknown_hostsにremote hostのホストキーが登録されている必要があるので確認すること
$HOME/.ssh/known_hostsにリモートホストのHost Keyを追加するために、スキャン前にリモートホストにSSH接続する必要がある。
また、localhostのknown_hostsにremote hostのホストキーが登録されている必要があるので確認すること。
## Step4. Config
- localhost
```
$ ssh ubuntu@172.31.4.82 -i ~/.ssh/id_rsa
```
- Localhost
## Step3. config.tomlの設定
- localhost
```
$ cd $HOME
$ cat config.toml
[servers]
[servers.172-31-4-82]
[servers.ubuntu]
host = "172.31.4.82"
port = "22"
user = "ec2-user"
keyPath = "/home/ec2-user/.ssh/id_rsa"
user = "ubuntu"
keyPath = "/home/centos/.ssh/id_rsa"
```
## Step5. Check config.toml and settings on the server before scanning
## Step4. Check config.toml and settings on the server before scanning
```
$ vuls configtest
$ vuls configtest ubuntu
```
see [Usage: configtest](#usage-configtest)
## Step6. Start Scanning
## Step5. Start Scanning
```
$ vuls scan
$ vuls scan ubuntu
... snip ...
Scan Summary
============
172-31-4-82 amazon 2015.09 94 CVEs 103 updatable packages
One Line Summary
================
ubuntu ubuntu16.04 30 updatable packages
```
## Step7. Reporting
## Step6. Reporting
See [Tutorial: Local Scan Mode#Step8. Reporting](#step8-reporting)
See [Tutorial: Local Scan Mode#Step9. TUI](#step9-tui)
@@ -756,6 +721,7 @@ host = "172.31.4.82"
$ vuls configtest --help
configtest:
configtest
[-deep]
[-config=/path/to/config.toml]
[-log-dir=/path/to/log]
[-ask-key-password]
@@ -774,6 +740,8 @@ configtest:
Test containers only. Default: Test both of hosts and containers
-debug
debug mode
-deep
Config test for deep scan mode
-http-proxy string
http://proxy-url:port (default: empty)
-log-dir string
@@ -784,30 +752,33 @@ configtest:
Timeout(Sec) (default 300)
```
configtestサブコマンドは以下をチェックする
- config.tomlで定義されたサーバ/コンテナに対してSSH可能かどうか
configtestサブコマンドは、config.tomlで定義されたサーバ/コンテナに対してSSH可能かどうかをチェックする
## Deep Scan Mode
Deep Scan Modeではスキャン対象サーバ上にいくつかの依存パッケージが必要。
configtestに--deepをつけて実行するとSSH接続に加えて以下もチェックする。
- スキャン対象のサーバ上に依存パッケーがインストールされているか
- /etc/sudoers
## Dependencies on Target Servers
### Dependencies and /etc/sudoers on Target Servers
スキャンするためには、下記のパッケージが必要なので、手動かまたはAnsibleなどのツールで事前にインストールする必要がある。
Deep Scan Modeでスキャンするためには、下記のパッケージが必要なので、手動かまたはAnsibleなどのツールで事前にインストールする必要がある。
| Distribution| Release | Requirements |
|:------------|-------------------:|:-------------|
| Ubuntu | 12, 14, 16| - |
| Debian | 7, 8| aptitude |
| CentOS | 6, 7| yum-plugin-changelog |
| Amazon | All | - |
| RHEL | 5 | yum-security |
| RHEL | 6, 7 | - |
| FreeBSD | 10 | - |
| Raspbian | Wheezy, Jessie | - |
| Distribution | Release | Requirements |
|:-------------|-------------------:|:-------------|
| Ubuntu | 12, 14, 16| - |
| Debian | 7, 8| aptitude |
| CentOS | 6, 7| yum-plugin-changelog, yum-utils |
| Amazon | All | yum-plugin-changelog, yum-utils |
| RHEL | 5 | yum-utils, yum-security, yum-changelog |
| RHEL | 6, 7 | yum-utils, yum-plugin-changelog |
| Oracle Linux | 5 | yum-utils, yum-security, yum-changelog |
| Oracle Linux | 6, 7 | yum-utils, yum-plugin-changelog |
| FreeBSD | 10 | - |
| Raspbian | Wheezy, Jessie | - |
## Check /etc/sudoers
スキャン対象サーバに対してパスワードなしでSUDO可能な状態か確認する。
また、requirettyも定義されているか確認する。(--ssh-native-insecureオプションでscanする場合はrequirettyは定義しなくても良い)
また、Deep Scan Modeで利用するコマンドの中にはRoot権限が必要なものものある。configtestサブコマンドでは、スキャン対象サーバに対してそのコマンドがパスワードなしでSUDO可能な状態か確認する。また、requirettyも定義されているかも確認する。(--ssh-native-insecureオプションでscanする場合はrequirettyは定義しなくても良い)
```
Defaults:vuls !requiretty
```
@@ -815,37 +786,25 @@ For details, see [-ssh-native-insecure option](#-ssh-native-insecure-option)
スキャン対象サーバ上の`/etc/sudoers`のサンプル
- CentOS
- RHEL 5 / Oracle Linux 5
```
vuls ALL=(ALL) NOPASSWD:/usr/bin/yum --changelog --assumeno update *
vuls ALL=(ALL) NOPASSWD:/usr/bin/yum --color=never repolist, /usr/bin/yum --color=never list-security --security, /usr/bin/yum --color=never info-security
Defaults:vuls env_keep="http_proxy https_proxy HTTP_PROXY HTTPS_PROXY"
```
- RHEL 5
- RHEL 6, 7 / Oracle Linux 6, 7
```
vuls ALL=(ALL) NOPASSWD:/usr/bin/yum --color=never repolist, /usr/bin/yum --color=never list-security --security, /usr/bin/yum --color=never check-update, /usr/bin/yum --color=never info-security
vuls ALL=(ALL) NOPASSWD:/usr/bin/yum --color=never repolist, /usr/bin/yum --color=never --security updateinfo list updates, /usr/bin/yum --color=never --security updateinfo updates
Defaults:vuls env_keep="http_proxy https_proxy HTTP_PROXY HTTPS_PROXY"
```
- RHEL 6, 7
```
vuls ALL=(ALL) NOPASSWD:/usr/bin/yum --color=never repolist, /usr/bin/yum --color=never --security updateinfo list updates, /usr/bin/yum --color=never check-update, /usr/bin/yum --color=never --security updateinfo updates
Defaults:vuls env_keep="http_proxy https_proxy HTTP_PROXY HTTPS_PROXY"
```
- Debian
- Debian/Ubuntu/Raspbian
```
vuls ALL=(ALL) NOPASSWD: /usr/bin/apt-get update
Defaults:vuls env_keep="http_proxy https_proxy HTTP_PROXY HTTPS_PROXY"
```
- Ubuntu/Raspbian
```
vuls ALL=(ALL) NOPASSWD: /usr/bin/apt-get update
Defaults:vuls env_keep="http_proxy https_proxy HTTP_PROXY HTTPS_PROXY"
```
- Amazon Linux, FreeBSDは今のところRoot権限なしでスキャン可能
- CentOS, Amazon Linux, FreeBSDは今のところRoot権限なしでスキャン可能
----
@@ -855,6 +814,7 @@ Defaults:vuls env_keep="http_proxy https_proxy HTTP_PROXY HTTPS_PROXY"
$ vuls scan -help
scan:
scan
[-deep]
[-config=/path/to/config.toml]
[-results-dir=/path/to/results]
[-log-dir=/path/to/log]
@@ -880,6 +840,8 @@ scan:
Scan containers only. Default: Scan both of hosts and containers
-debug
debug mode
-deep
Deep scan mode. Scan accuracy improves and information becomes richer. Since analysis of changelog, issue commands requiring sudo, but it may be slower and high load on the scan tareget server.
-http-proxy string
http://proxy-url:port (default: empty)
-log-dir string
@@ -898,6 +860,23 @@ scan:
Number of second for scaning vulnerabilities for all servers (default 7200)
```
## -deep option
You need to execute `vuls configtest --deep` to check the configuration of the target server before scanning with -deep flag.
| Distribution | Changelog |
|:-------------|:---------:|
| Ubuntu | yes |
| Debian | yes |
| CentOS | yes |
| Amazon | yes |
| RHEL | yes |
| RHEL | yes |
| Oracle Linux | yes |
| Oracle Linux | yes |
| FreeBSD | no |
| Raspbian | yes |
## -ssh-native-insecure option
Vulsは種類のSSH接続方法をサポートしている。
@@ -1045,6 +1024,9 @@ report:
[-cvedb-type=sqlite3|mysql|postgres|redis]
[-cvedb-path=/path/to/cve.sqlite3]
[-cvedb-url=http://127.0.0.1:1323 or DB connection string]
[-ovaldb-type=sqlite3|mysql]
[-ovaldb-path=/path/to/oval.sqlite3]
[-ovaldb-url=http://127.0.0.1:1324 or DB connection string]
[-cvss-over=7]
[-diff]
[-ignore-unscored-cves]
@@ -1122,6 +1104,12 @@ report:
[en|ja] (default "en")
-log-dir string
/path/to/log (default "/var/log/vuls")
-ovaldb-path string
/path/to/sqlite3 (For get oval detail from oval.sqlite3) (default "/Users/kotakanbe/go/src/github.com/future-architect/vuls/oval.sqlite3")
-ovaldb-type string
DB type for fetching OVAL dictionary (sqlite3 or mysql) (default "sqlite3")
-ovaldb-url string
http://goval-dictionary.com:1324 or mysql connection string
-pipe
Use stdin via PIPE
-refresh-cve
@@ -1177,46 +1165,45 @@ Confidence 100 / YumUpdateSecurityMatch
### Summary part
```
172-31-4-82 (amazon 2015.09)
============================
Total: 94 (High:19 Medium:54 Low:7 ?:14) 103 updatable packages
cent6 (centos6.6)
=================
Total: 145 (High:23 Medium:101 Low:21 ?:0) 83 updatable packages
```
- `172-31-4-82` means that it is a scan report of `servers.172-31-4-82` defined in cocnfig.toml.
- `(amazon 2015.09)` means that the version of the OS is Amazon Linux 2015.09.
- `Total: 94 (High:19 Medium:54 Low:7 ?:14)` means that a total of 94 vulnerabilities exist, and the distribution of CVSS Severity is displayed.
- `103 updatable packages` means that there are 103 updateable packages on the target server.
- `cent6` means that it is a scan report of `servers.cent6` defined in cocnfig.toml.
- `(centos6.6)` means that the version of the OS is CentOS6.6.
- `Total: 145 (High:23 Medium:101 Low:21 ?:0)` means that a total of 145 vulnerabilities exist, and the distribution of CVSS Severity is displayed.
- `83 updatable packages` means that there are 83 updateable packages on the target server.
### Detailed Part
```
CVE-2016-5636
-------------
Score 10.0 (High)
Vector (AV:N/AC:L/Au:N/C:C/I:C/A:C)
Summary Integer overflow in the get_data function in zipimport.c in CPython (aka Python)
before 2.7.12, 3.x before 3.4.5, and 3.5.x before 3.5.2 allows remote attackers
to have unspecified impact via a negative data size value, which triggers a
heap-based buffer overflow.
CWE https://cwe.mitre.org/data/definitions/190.html
NVD https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2016-5636
MITRE https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2016-5636
CVE Details http://www.cvedetails.com/cve/CVE-2016-5636
CVSS Claculator https://nvd.nist.gov/cvss/v2-calculator?name=CVE-2016-5636&vector=(AV:N/AC:L/...
RHEL-CVE https://access.redhat.com/security/cve/CVE-2016-5636
ALAS-2016-724 https://alas.aws.amazon.com/ALAS-2016-724.html
Package python27-2.7.10-4.119.amzn1 -> python27-2.7.12-2.120.amzn1
python27-devel-2.7.10-4.119.amzn1 -> python27-devel-2.7.12-2.120.amzn1
python27-libs-2.7.10-4.119.amzn1 -> python27-libs-2.7.12-2.120.amzn1
Confidence 100 / YumUpdateSecurityMatch
CVE-2016-0702
----------------
Max Score 2.6 IMPORTANT (redhat)
nvd 1.9/AV:L/AC:M/Au:N/C:P/I:N/A:N
redhat 2.6/AV:L/AC:H/Au:N/C:P/I:P/A:N
jvn 1.9/AV:L/AC:M/Au:N/C:P/I:N/A:N
CVSSv2 Calc https://nvd.nist.gov/vuln-metrics/cvss/v2-calculator?name=CVE-2016-0702
Summary The MOD_EXP_CTIME_COPY_FROM_PREBUF function in crypto/bn/bn_exp.c in OpenSSL
1.0.1 before 1.0.1s and 1.0.2 before 1.0.2g does not properly consider
cache-bank access times during modular exponentiation, which makes it easier for
local users to discover RSA keys by running a crafted application on the same
Intel Sandy Bridge CPU core as a victim and leveraging cache-bank conflicts, aka
a "CacheBleed" attack.
Source https://nvd.nist.gov/vuln/detail/CVE-2016-0702
RHEL-CVE https://access.redhat.com/security/cve/CVE-2016-0702
CWE-200 (nvd) https://cwe.mitre.org/data/definitions/200.html
Package/CPE openssl-1.0.1e-30.el6 - 1.0.1e-57.el6
Confidence 100 / OvalMatch
```
- `Score` means CVSS Score.
- `Vector` means [CVSS Vector](https://nvd.nist.gov/CVSS/Vector-v2.aspx)
- `Max Score` means Max CVSS Score.
- `nvd` shows [CVSS Vector](https://nvd.nist.gov/CVSS/Vector-v2.aspx) of NVD
- `redhat` shows [CVSS Vector](https://nvd.nist.gov/CVSS/Vector-v2.aspx) of RedHat OVAL
- `jvn` shows [CVSS Vector](https://nvd.nist.gov/CVSS/Vector-v2.aspx) of JVN
- `Summary` means Summary of the CVE.
- `CWE` means [CWE - Common Weakness Enumeration](https://nvd.nist.gov/cwe.cfm) of the CVE.
- `NVD` `MITRE` `CVE Details` `CVSS Caluculator`
- `RHEL-CVE` means the URL of OS distributor support.
- `Package` shows the package version information including this vulnerability.
- `Confidence` means the reliability of detection.
- `100` is highly reliable
@@ -1225,34 +1212,14 @@ Confidence 100 / YumUpdateSecurityMatch
| Detection Method | Confidence | OS |Description|
|:-----------------------|-------------------:|:---------------------------------|:--|
| YumUpdateSecurityMatch | 100 | RHEL, Amazon Linux |Detection using yum-plugin-security|
| OvalMatch | 100 | CentOS, RHEL, Oracle, Ubuntu, Debian |Detection using OVAL |
| YumUpdateSecurityMatch | 100 | RHEL, Amazon, Oracle |Detection using yum-plugin-security|
| ChangelogExactMatch | 95 | CentOS, Ubuntu, Debian, Raspbian |Exact version match between changelog and package version|
| ChangelogLenientMatch | 50 | Ubuntu, Debian, Raspbian |Lenient version match between changelog and package version|
| PkgAuditMatch | 100 | FreeBSD |Detection using pkg audit|
| CpeNameMatch | 100 | All |Search for NVD information with CPE name specified in config.toml|
### Changelog Part
The scan results of Ubuntu, Debian, Raspbian or CentOS are also output Changelog in TUI or report with -format-full-text.
(RHEL, Amazon or FreeBSD will be available in the near future)
The output change log includes only the difference between the currently installed version and candidate version.
```
tar-1.28-2.1 -> tar-1.28-2.1ubuntu0.1
-------------------------------------
tar (1.28-2.1ubuntu0.1) xenial-security; urgency=medium
* SECURITY UPDATE: extract pathname bypass
- debian/patches/CVE-2016-6321.patch: skip members whose names contain
".." in src/extract.c.
- CVE-2016-6321
-- Marc Deslauriers <marc.deslauriers@ubuntu.com> Thu, 17 Nov 2016 11:06:07 -0500
```
## Example: Send scan results to Slack
```
$ vuls report \
@@ -1508,6 +1475,9 @@ tui:
[-cvedb-type=sqlite3|mysql|postgres|redis]
[-cvedb-path=/path/to/cve.sqlite3]
[-cvedb-url=http://127.0.0.1:1323 DB connection string]
[-ovaldb-type=sqlite3|mysql]
[-ovaldb-path=/path/to/oval.sqlite3]
[-ovaldb-url=http://127.0.0.1:1324 or DB connection string]
[-refresh-cve]
[-results-dir=/path/to/results]
[-log-dir=/path/to/log]
@@ -1521,6 +1491,12 @@ tui:
DB type for fetching CVE dictionary (sqlite3, mysql, postgres or redis) (default "sqlite3")
-cvedb-url string
http://cve-dictionary.com:8080 or DB connection string
-ovaldb-path string
/path/to/sqlite3 (For get oval detail from oval.sqlite3) (default "/Users/kotakanbe/go/src/github.com/future-architect/vuls/oval.sqlite3")
-ovaldb-type string
DB type for fetching OVAL dictionary (sqlite3 or mysql) (default "sqlite3")
-ovaldb-url string
http://goval-dictionary.com:1324 or mysql connection string
-debug
debug mode
-debug-sql
@@ -1584,7 +1560,7 @@ $ go-cve-dictionary server -bind=192.168.10.1 -port=1323
Run Vuls with -cve-dictionary-url option.
```
$ vuls scan -cve-dictionary-url=http://192.168.0.1:1323
$ vuls report -cve-dictionary-url=http://192.168.0.1:1323
```
# Usage: Update NVD Data
@@ -1593,6 +1569,27 @@ see [go-cve-dictionary#usage-fetch-nvd-data](https://github.com/kotakanbe/go-cve
----
# Usage: goval-dictionary on different server
```
$ goval-dictionary server -bind=192.168.10.1 -port=1324
```
Run Vuls with -ovaldb-url option.
```
$ vuls report -ovaldb-url=http://192.168.0.1:1323
```
# Usage: Update OVAL Data
- [RedHat, CentOS](https://github.com/kotakanbe/goval-dictionary#usage-fetch-oval-data-from-redhat)
- [Ubuntu](https://github.com/kotakanbe/goval-dictionary#usage-fetch-oval-data-from-ubuntu)
- [Debian](https://github.com/kotakanbe/goval-dictionary#usage-fetch-oval-data-from-debian)
- [Oracle](https://github.com/kotakanbe/goval-dictionary#usage-fetch-oval-data-from-oracle)
----
# レポートの日本語化
see [go-cve-dictionary#usage-fetch-jvn-data](https://github.com/kotakanbe/go-cve-dictionary#usage-fetch-jvn-data)