Amazon LinuxでCCS Injection脆弱性に対応したOpenSSLのパッチを当てる方法

AWS Elastic Beanstalk

※当ブログではアフィリエイト広告を利用しています。

またOpenSSLの脆弱性が発見されたようで話題になっているようです。前回のHeartbleed脆弱性に続き、今回もAWS Elastic Beanstalkで使っているEC2インスタンスに対応パッチを当てようとしたのですがうまくいきませんでした。

なんとか対応パッチを当て、脆弱性への対応完了まで確認できたので解決までの手順をメモします。

OpenSSLの脆弱性 CCS Injection(CVE-2014-0224)について

OpenSSLのChangeCipherSpecメッセージの処理に欠陥があったことによる脆弱性のようです。バグを悪用された場合、暗号通信の情報が漏えいする可能性があります。

OpenSSLの以下のバージョンが影響を受けます。

  • 1.0.1から1.0.1g
  • 1.0.0から1.0.0l
  • 0.9.8y以前の全て

脆弱性の詳細についてはバグ発見者様のサイト及び関連サイトをご覧ください。

関連サイト:CCS Injection Vulnerability
関連サイト:OpenSSLの脆弱性CCS Injection(CVE-2014-0224)の攻撃が行われる恐れがあるパターンをマトリックス化してみた。

AWSの対応状況

AWSでの対応状況はこちらのページから確認できます。さすがにかなり早い段階で対応が行われています。Amazon LinuxでのOpenSSL修正版パッケージのバージョンはopenssl-1.0.1g-1.70.amzn1です。

Amazon Linux AMI – A fix has been made available in its package repository. The fixed package is openssl-1.0.1g-1.70.amzn1. Run “sudo yum update openssl” to update your Amazon Linux AMI Instance. Once the new package is installed, it is required that you either manually restart all services that are using openssl, or that you reboot your instance.

Amazon LinuxでOpenSSLのパッチを当てる方法

AWS公式サイトではsudo yum update opensslでパッチを当てられる旨が書いてありましたが、私の環境ではyum list updates opensslでアップデートの一覧を見ても修正版パッケージがリストに現れませんでした。

yum list updates openssl
読み込んだプラグイン:priorities, update-motd, upgrade-helper
インストール済みパッケージ
openssl.x86_64                 1:1.0.1e-4.58.amzn1
@amzn-updates
利用可能なパッケージ
openssl.i686                   1:1.0.1e-4.58.amzn1
amzn-updates

そこで/etc/yum.confreleasever=2013.09となっていた部分をreleasever=latestに書き換えました。

が、再度yum list updates opensslするとミラーリストが無いと怒られました。

yum list updates openlssl
読み込んだプラグイン:priorities, update-motd, upgrade-helper
amzn-main/latest                                         | 2.1 kB     00:00

Could not retrieve mirrorlist
http://repo.ap-northeast-1.amazonaws.com/latest/updates/mirror.list-7ea48e1baabc
error was
14: PYCURL ERROR 22 - "The requested URL returned error: 403 Forbidden"


 One of the configured repositories failed (不明),
 and yum doesn't have enough cached data to continue. At this point the only
 safe thing yum can do is fail. There are a few ways to work "fix" this:

     1. Contact the upstream for the repository and get them to fix the
problem.

     2. Reconfigure the baseurl/etc. for the repository, to point to a
working
        upstream. This is most often useful if you are using a newer
        distribution release than is supported by the repository (and the
        packages for the previous distribution release still work).

     3. Disable the repository, so yum won't use it by default. Yum will
then
        just ignore the repository until you permanently enable it again or
use
        --enablerepo for temporary usage:

            yum-config-manager --disable <repoid>

     4. Configure the failing repository to be skipped, if it is
unavailable.
        Note that yum will try to contact the repo. when it runs most
commands,
        so will have to try and fail each time (and thus. yum will be be
much
        slower). If it is a very temporary problem though, this is often a
nice
        compromise:

            yum-config-manager --save
--setopt=<repoid>.skip_if_unavailable=true

Cannot find a valid baseurl for repo: amzn-updates/latest

調べたところyumリポジトリ/etc/yum.repos.d/amzn-updates.repo内のmirrorlist=の記述を変更することで対応可能とのことでした。

I have found that if you drop -$guid suffix in this line:

/etc/yum.repos.d/amzn-updates.repo:mirrorlist=
http://repo.us-east-1.amazonaws.com/$releasever/updates/mirror.list-$guid

so make it

/etc/yum.repos.d/amzn-updates.repo:mirrorlist=
http://repo.us-east-1.amazonaws.com/$releasever/updates/mirror.list

よって同ファイルを以下の通り書き換えました。

変更前

mirrorlist=http://repo.us-east-1.amazonaws.com/$releasever/updates/mirror.list-$guid

変更後

mirrorlist=http://repo.us-east-1.amazonaws.com/$releasever/updates/mirror.list

念のためsudo yum clean allでキャッシュクリアしたあと、再度yum list updates opensslすると最新パッチがアップデートの一覧に表示されました。

yum list updates openssl
読み込んだプラグイン:priorities, update-motd, upgrade-helper
amzn-main/latest                                         | 2.1 kB     00:00

amzn-updates/latest                                      | 2.3 kB     00:00

amzn-updates/latest/group                                |  35 kB     00:00

amzn-updates/latest/updateinfo                           | 152 kB     00:00

amzn-updates/latest/primary_db                           | 751 kB     00:00

更新したパッケージ
openssl.x86_64                 1:1.0.1g-1.70.amzn1
 amzn-updates

最新パッケージが確認できたのでsudo yum update opensslでアップデートします。

sudo yum update openssl
読み込んだプラグイン:priorities, update-motd, upgrade-helper
amzn-main/latest                                         | 2.1 kB     00:00

amzn-main/latest/group                                   |  35 kB     00:00

amzn-main/latest/primary_db                              | 2.8 MB     00:00

amzn-updates/latest                                      | 2.3 kB     00:00

amzn-updates/latest/group                                |  35 kB     00:00

amzn-updates/latest/updateinfo                           | 152 kB     00:00

amzn-updates/latest/primary_db                           | 751 kB     00:00

〜中略〜

更新:
  audit.x86_64 0:2.3.2-3.19.amzn1       openssl.x86_64 1:1.0.1g-1.70.amzn1


依存性を更新しました:
  audit-libs.x86_64 0:2.3.2-3.19.amzn1

  glibc.x86_64 0:2.17-36.81.amzn1

  glibc-common.x86_64 0:2.17-36.81.amzn1

  glibc-devel.x86_64 0:2.17-36.81.amzn1

  glibc-headers.x86_64 0:2.17-36.81.amzn1

  openssl-devel.x86_64 1:1.0.1g-1.70.amzn1


完了しました!

openssl version -aでバージョンを確認します。バージョンは1.0.1gですが、2014/6/4にビルドされた最新版の状態となりました。

openssl version -a
OpenSSL 1.0.1g-fips 7 Apr 2014
built on: Wed Jun  4 21:03:05 UTC 2014
platform: linux-x86_64
options:  bn(64,64) md2(int) rc4(16x,int) des(idx,cisc,16,int) idea(int)

関連するサービスをリスタートして対応完了です。私の環境ではhttpdのみのリスタートでOKでした。

sudo service httpd restart

脆弱性対応が完了したことのチェック

会員登録が必要ですが、redhatのサイトより任意のサーバーのCCS Injection脆弱性の有無が確認できます。

脆弱性確認サイト:OpenSSL CCS Injection Detector

今回対応した環境をチェックしてみたところ、「Status:Not Vulnerable」となり脆弱性が無いことが確認できました。
OpenSSL CCS Injection 対応済み

ちなみに対応前は「Status:Vulnerable!」でした。
OpenSSL CCS Injection 未対応

おわりに

ただ単にupdateするだけではパッチが当たらなかったため、結構ハマりました。しかし通信内容の暗号化に関わる問題のため早めに対応しておくに越したことはないと思います。

再度OpenSSLの脆弱性が発見された時のためにも、AWSでの対応方法は覚えておきたい手順です。