Amazon InspectorでRed Hat Enterprise Linux(RHEL)の脆弱性を検知させてみた

2016.06.06

この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。

コカコーラが大好きなカジです。

Amazon Inspectorを使ってWindowsに続いて、RHELサーバへの脆弱性診断をしてみました。

Amazon InspectorのRHEL対応について

2016/6/6現在、Red Hat Enterprise Linuxを検査対象の場合、7.2以降が対応となっています。

マニュアルに以下のように記載されています。

Supported Operating Systems for the AWS Agent

In this release of Amazon Inspector, your assessment targets can consist of EC2 instances that run the following operating systems:

Amazon Linux (2015.03 or later) Ubuntu (14.04 LTS) Red Hat Enterprise Linux (7.2) CentOS (7.2)

試したところ、検知していた内容がありましたので今回、ご紹介します。

EC2の構築

Amazon Inspectorの検査対象のリージョンは以下の4つとなります。

  • US West (Oregon)
  • US East (N. Virginia)
  • EU (Ireland)
  • Asia Pacific (Tokyo)

今回も、東京で実施しています。以下のイメージでLaunchし、Inspectorで検査してみました。

RHEL-7.2_HVM_GA-20151112-x86_64-1-Hourly2-GP2 (ami-0dd8f963)

kaji-inspector-EC2-01

タグの設定

AWS Inspectorの検査対象はタグによって判別させます。今回も「Inspector」=「True」というタグを付与しました。

kaji-inspector-EC2-02

RHELへのInspector エージェントインストール

エージェントダウンロード

マニュアルに記載のあるURLからダウンロードしますが、wgetはインストールされていないため、curlを利用します。

curl -O https://d1wk0tztpsntt1.cloudfront.net/linux/latest/install

ダウンロード

$ curl -O https://d1wk0tztpsntt1.cloudfront.net/linux/latest/install
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 19612 100 19612 0 0 150k 0 --:--:-- --:--:-- --:--:-- 152k
$

エージェントインストール

$ sudo bash install
**************************************************
INIT PHASE
**************************************************
Distribution type of the machine is rhel.
Distribution of the machine is Red Hat Enterprise Linux Server.
Revision of the distro is 7.2.
Kernel version of the machine is 3.10.0-327.el7.x86_64.
Trying to resolve domain name for s3.amazonaws.com to check internet connectivity.....
install: 行 166: host: コマンドが見つかりません
Unable to resolve domain name for s3.amazonaws.com. Please check internet connectivity and dns resolution capability.

**************************************************
SCRIPT SETUP PHASE
**************************************************
ip-10-10-10-223.ap-northeast-1.compute.internal is an EC2 instance reporting region as ap-northeast-1.

**************************************************
INSTALLATION PHASE-1
**************************************************
No existing version of agent in the machine.
Validated awsagent inventory text signature with:
Validated version file signature with:

**************************************************
INSTALLATION PHASE-2
**************************************************
The package version for rhel-3.10.0-327.el7.x86_64-x86_64 is found in version mainfest: rhel-3.10.0-123.1.2.el7.x86_64-x86_64 AwsAgent-1.0.298.0-100298.x86_64.rpm 8c33fec52c24af87ff0f66dfc4cebffc4ccab4d5f8db6cce28c8248243ead925 https://s3-ap-northeast-1.amazonaws.com/aws-agent.ap-northeast-1/linux/releases/1.0.298.0/rhel-3.10.0-327.el7.x86_64-x86_64/AwsAgent-1.0.298.0-100298.x86_64.rpm.
The package file name from version manifest for rhel-3.10.0-327.el7.x86_64-x86_64 is AwsAgent-1.0.298.0-100298.x86_64.rpm.
Validated package sha256 hash matches expected value.
Installing with yum...
読み込んだプラグイン:amazon-id, rhui-lb, search-disabled-repos
/tmp/awsagent.oRj0SNwJ/AwsAgent-1.0.298.0-100298.x86_64.rpm を調べています: AwsAgent-1.0.298.0-100298.x86_64
/tmp/awsagent.oRj0SNwJ/AwsAgent-1.0.298.0-100298.x86_64.rpm をインストール済みとして設定しています
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> パッケージ AwsAgent.x86_64 0:1.0.298.0-100298 を インストール
--> 依存性解決を終了しました。

依存性を解決しました

==========================================================================================================
Package アーキテクチャー
バージョン リポジトリー 容量
==========================================================================================================
インストール中:
AwsAgent x86_64 1.0.298.0-100298 /AwsAgent-1.0.298.0-100298.x86_64 136 M

トランザクションの要約
==========================================================================================================
インストール 1 パッケージ

合計容量: 136 M
インストール容量: 136 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
インストール中 : AwsAgent-1.0.298.0-100298.x86_64 1/1

Redirecting to /bin/systemctl reload crond.service
検証中 : AwsAgent-1.0.298.0-100298.x86_64 1/1

インストール:
AwsAgent.x86_64 0:1.0.298.0-100298

完了しました!
読み込んだプラグイン:amazon-id, rhui-lb, search-disabled-repos
/tmp/awsagent.oRj0SNwJ/AwsAgent-1.0.298.0-100298.x86_64.rpm を調べています: AwsAgent-1.0.298.0-100298.x86_64
エラー: 何もしません

**************************************************
FINISH PHASE
**************************************************

Notice:
By installing the Amazon Inspector Agent, you agree that your use is subject to the terms of your existing
AWS Customer Agreement or other agreement with Amazon Web Services, Inc. or its affiliates governing your
use of AWS services. You may not install and use the Amazon Inspector Agent unless you have an account in
good standing with AWS.
* * *
Current running agent reports to arsenal endpoint: arsenal.ap-northeast-1.amazonaws.com
Current running agent reports version as: 1.0.298.0
This install script was created to install agent version: 1.0.298.0
In most cases, these version numbers should be the same.
HTTP/1.1 200 OK
x-amz-id-2: Zkp81mthCUGUPMICuQnTZPmjFElZb8L7lmPrik4i93YcqLOBNZhFg2NyEGoV5xMWxkxJCwlnuu0=
x-amz-request-id: 060A59C13E579041
Date: Mon, 30 May 2016 13:13:09 GMT
Last-Modified: Fri, 27 May 2016 16:35:18 GMT
ETag: "1d23723b7d25806d36b476a22fe58fb0"
Accept-Ranges: bytes
Content-Type:
Content-Length: 78081
Server: AmazonS3

$

EC2側の準備は完了です。

Amazon Inspectorの設定

Inspector設定についてはAmazon InspectorでWindowsの脆弱性を検知させてみたと同じですので、そちらの手順を参照ください。

評価テンプレートの定義は以下を設定しました。

  • CIS Operating System Security Configuration Benchmarks-1.0
  • Security Best Practices-1.0
  • Common Vulnerabilities and Exposures-1.1
  • Runtime Behavior Analysis-1.0

分析結果の確認

分析完了になりましたら、「結果」をクリックし内容を確認します。

詳細を確認できます。

右側のダウンロードボタンを押すとCSVファイルでダウンロードできます。 文字コードの問題と思いますが、Mac版のExcelでCSVを開いたところ、1行目が文字化けしましたがテキストエディタでは表示されましたので、変換すると良いと思います。

"重要度","結果","ターゲット","テンプレート","ルールパッケージ"
"Informational","Unsupported Operating System or Version","Inspector-Scan","Assesment","CIS Operating System Security Configuration Benchmarks-1.0"
"Medium","Instance i-0342269c is configured to allow users to log in with root credentials over SSH. This increases the likelihood of a successful brute-force attack.","Inspector-Scan","Assesment","Security Best Practices-1.0"
"Low","Instance i-0342269c used insecure protocol(s) 80/tcp (http) to connect to a remote host. These protocols pass traffic in the clear, increasing the risk of a successful traffic interception attack.","Inspector-Scan","Assesment","Runtime Behavior Analysis-1.0"
"Medium","The following executable files on instance i-0342269c do not support stack cookies: /usr/bin/rpm, /usr/lib64/libcrypt-2.17.so, /usr/lib64/libdl-2.17.so, /usr/lib64/libgcc_s-4.8.5-20150702.so.1, /usr/lib64/libm-2.17.so, /usr/lib64/libnsl-2.17.so, /usr/lib64/libnss_files-2.17.so, /usr/lib64/libpthread-2.17.so, /usr/lib64/librt-2.17.so, /usr/lib64/libutil-2.17.so.","Inspector-Scan","Assesment","Runtime Behavior Analysis-1.0"
"Informational","No potential security issues found","Inspector-Scan","Assesment","Common Vulnerabilities and Exposures-1.1"

結果を見て

わざと、古めのRHELのイメージを利用しましたが、CVE=「Common Vulnerabilities and Exposures」が見つかりませんでした。 「Runtime Behavior Analysis」については2件検知しており、Lowで検出されたhttpはLISTENしていないので、なぜ検知したかわかりませんでした。 「Unsupported Operating System or Version」にて「CIS Operating System Security Configuration Benchmarks-1.0」がありましたので、ルールバージョンがアップデートされ、すべてのルールパッケージが検査できるようになることを期待しています。

関連資料

AWS Inspectorで脆弱性を検知させる Ubuntu

Amazon InspectorでWindowsの脆弱性を検知させてみた