clairとは?
CoreOSが作ってる、コンテナの脆弱性スキャンツールです。
CVEデータをpostgresに入れて(定期更新される)、それを元にスキャンします。
ローカルイメージをスキャン
CoreOSが提供してた、analyze-local-imagesはdeprecatedだったので、
https://github.com/arminc/clair-scanner を使って、ローカルのイメージをスキャンしてみました。
実行
# clair-scannerをインストール $ make clair-scanner/install # clairサーバとpostgresを起動 $ make clair/run # 起動してから10 ~ 20分くらいでCVEデータが更新されます。それまで待機 # postgresに入ってるCVEデータの量を見たいときは $ make check # golang:1.10をスキャン $ docker pull golang:1.10 $ make run IMAGE=golang:1.10 clair-scanner --ip=host.docker.internal golang:1.10 2018/10/04 14:53:39 [INFO] ▶ Start clair-scanner 2018/10/04 14:53:59 [INFO] ▶ Server listening on port 9279 2018/10/04 14:53:59 [INFO] ▶ Analyzing 4f68522e312f5f12340e4b9559e71bba43ef929a10efc9ea6b67b4ff33bfb82e 2018/10/04 14:54:02 [INFO] ▶ Analyzing f56aeae9371b6c04ca4cf57a326b42de8c0d08a5fdebb26ef6b8df324337ea72 2018/10/04 14:54:02 [INFO] ▶ Analyzing 66f389e10325cd0c5f124eba8c5e9b57a9d490a5ddfa02a38f92686d04bda898 2018/10/04 14:54:03 [INFO] ▶ Analyzing 070ca363ac71db895b70015f3c83a1b09a42e74a52b9afdddd15e8aab4dd4a4a 2018/10/04 14:54:06 [INFO] ▶ Analyzing 13d63372391595f4c4086f342f2d0205542ba4530ec95fb8bd069bc7a19dea5e 2018/10/04 14:54:10 [INFO] ▶ Analyzing bf50139cdff0a2429fdf26ed2464b30ec6c88adf24d973ac5a6ed046283ee397 2018/10/04 14:54:20 [INFO] ▶ Analyzing b16a12b1f36856e47d3cea6f2141b970f4b383c6b5302189b3dd452ce9389af9 2018/10/04 14:54:20 [WARN] ▶ Image [golang:1.10] contains 288 total vulnerabilities 2018/10/04 14:54:20 [ERRO] ▶ Image [golang:1.10] contains 288 unapproved vulnerabilities +------------+-----------------------------+-----------------+-----------------------+--------------------------------------------------------------+ | STATUS | CVE SEVERITY | PACKAGE NAME | PACKAGE VERSION | CVE DESCRIPTION | +------------+-----------------------------+-----------------+-----------------------+--------------------------------------------------------------+ | Unapproved | High CVE-2018-6485 | glibc | 2.24-11+deb9u3 | An integer overflow in the implementation of the | | | | | | posix_memalign in memalign functions in the GNU C Library | | | | | | (aka glibc or libc6) 2.26 and earlier could cause these | | | | | | functions to return a pointer to a heap area that is | | | | | | too small, potentially leading to heap corruption. | | | | | | https://security-tracker.debian.org/tracker/CVE-2018-6485 | +------------+-----------------------------+-----------------+-----------------------+--------------------------------------------------------------+ | Unapproved | High CVE-2018-1000001 | glibc | 2.24-11+deb9u3 | In glibc 2.26 and earlier there is confusion in the | | | | | | usage of getcwd() by realpath() which can be used | | | | | | to write before the destination buffer leading to | | | | | | a buffer underflow and potential code execution. | | | | | | https://security-tracker.debian.org/tracker/CVE-2018-1000001 | +------------+-----------------------------+-----------------+-----------------------+--------------------------------------------------------------+ まだまだCVEの詳細な情報が流れてくるが、量が多いため割愛します # clairサーバのログが見たいときは $ make tail # clairサーバとpostgresのコンテナ削除 $ make clair/rm
所感
プロダクトに入れる前には脆弱性スキャンしたほうが良いですね。
High/Medium/Low/Negligible/Unknown
で区別してくれるので、最低でもHighはチェックしましょう。
また、clair-scannerは -w
でwhitelist指定出来るみたいなので、自前でwhitelistを持ってると良いかもですね。
ただこれらもイメージpush先のリポジトリ側でスキャンされるのが理想であり、デファクトスタンダードになるでしょう。
GCRはα版がすでに提供されており、ECRもいずれ自動でスキャンして通知してくれるでしょう。