labunix's blog

labunixのラボUnix

Wheezyの「CVE-2014-0224」は修正出来ていない?

■「CVE-2014-0224」について
 以下の後にもいくつかセキュリティアップデートはあった。

 「CVE-2014-0160.」の脆弱性の対処について(Debian Wheezy)
 http://labunix.hateblo.jp/entry/20140408/1396963029

 「CVE-2014-0160」をnmapスクリプトを使ってローカル環境でテストする
 http://labunix.hateblo.jp/entry/20140412/1397296614

■私の環境は最新版になっている。

$ uname -a | sed s/"`hostname -s`"/"localhost"/g
Linux localhost 3.2.0-4-amd64 #1 SMP Debian 3.2.57-3+deb7u2 x86_64 GNU/Linux

$ openssl version;dpkg -l openssl | tail -1 | awk '{print $3}'
OpenSSL 1.0.1e 11 Feb 2013
1.0.1e-2+deb7u10

$ for opt in update upgrade autoremove autoclean;do sudo apt-get $opt -y ;done

■Debianのchangelogから見ると、前回チェックしたHeartBleedのパッチ適用前のバージョンは
 「1.0.1e-2+deb7u4」だった。

$ lv -s /usr/share/doc/openssl/changelog.Debian.gz | \
  nl -nln -ba | grep 1.0.1e-2+deb7u4
64    	openssl (1.0.1e-2+deb7u4) stable; urgency=medium

■「1.0.1e-2+deb7u7」の履歴にあるようにHeartBleedの修正も1回ではなかったようだ。

$ MYHEAD=`lv -s /usr/share/doc/openssl/changelog.Debian.gz | \
          nl -nln -ba | grep 1.0.1e-2+deb7u4 | awk '{print $1-1}'`; \
  lv -s /usr/share/doc/openssl/changelog.Debian.gz | head -n ${MYHEAD} | \
    grep "CVE\|^openssl\|^ \-\-" | sed s/".*\(CVE-[0-9\-]*\).*"/"\1"/g
openssl (1.0.1e-2+deb7u10) wheezy-security; urgency=medium
CVE-2014-0224
CVE-2014-0221
CVE-2014-0195
CVE-2014-3470
 -- Kurt Roeckx <kurt@roeckx.be>  Wed, 04 Jun 2014 20:04:27 +0200
openssl (1.0.1e-2+deb7u9) wheezy-security; urgency=medium
CVE-2014-0198
 -- Kurt Roeckx <kurt@roeckx.be>  Mon, 12 May 2014 22:10:41 +0200
openssl (1.0.1e-2+deb7u8) wheezy; urgency=medium
 -- Kurt Roeckx <kurt@roeckx.be>  Thu, 01 May 2014 15:06:05 +0200
openssl (1.0.1e-2+deb7u7) wheezy-security; urgency=high
CVE-2010-5298
CVE-2014-0160
CVE-2014-0076
 -- Raphael Geissert <geissert@debian.org>  Thu, 17 Apr 2014 22:11:33 +0200
openssl (1.0.1e-2+deb7u6) wheezy-security; urgency=high
 -- Salvatore Bonaccorso <carnil@debian.org>  Tue, 08 Apr 2014 10:44:53 +0200
openssl (1.0.1e-2+deb7u5) wheezy-security; urgency=high
CVE-2014-0160
CVE-2014-0160
 -- Salvatore Bonaccorso <carnil@debian.org>  Mon, 07 Apr 2014 22:26:55 +0200

■公式サイトを見ると、HeartBleedを含めて6つのCVEが修正されている。

$ w3m -dump https://www.openssl.ornerabilities.html | \
  grep CVE-20 | head -6 | sed s/"^  *"//g | \
  awk '{print $0};END{printf "\nCVE Count:%s\n\n",NR}'
CVE-2014-0224: 5th June 2014
CVE-2014-0221: 5th June 2014
CVE-2014-3470: 30th May 2014
CVE-2014-0198: 21st April 2014
CVE-2010-5298: 8th April 2014
CVE-2014-0160: 7th April 2014

CVE Count:6

■どうやって適用済みであることを確認するか。
 ベンダ情報、ディストリビューション等のサポートのステータスを確認する方法。

 DSA-2950-1 openssl -- security update
 https://www.debian.org/security/2014/dsa-2950

 Vulnerability Note VU#978508
 OpenSSL is vulnerable to a man-in-the-middle attack
 http://www.kb.cert.org/vuls/id/978508

 JVN#61247051
 OpenSSL における Change Cipher Spec メッセージの処理に脆弱性
 http://jvn.jp/jp/JVN61247051/index.html

■公開しているWebサーバならば、テストサイトがある。

 SSL Server Test
 https://www.ssllabs.com/ssltest/

■一旦、情報収集

 CCS Injection Vulnerability
 http://ccsinjection.lepidum.co.jp/ja.html

 CCS Injection脆弱性(CVE-2014-0224)発見の経緯についての紹介
 http://lepidum.co.jp/blog/2014-06-05/CCS-Injection/

 OpenSSLの脆弱性CCS Injection(CVE-2014-0224)の攻撃が行われる恐れがあるパターンをマトリックス化してみた。
 http://d.hatena.ne.jp/Kango/20140605/1401978480

 ZDI-14-173/CVE-2014-0195 - OpenSSL DTLS Fragment Out-of-Bounds Write: Breaking up is hard to do
 http://h30499.www3.hp.com/t5/HP-Security-Research-Blog/ZDI-14-173-CVE-2014-0195-OpenSSL-DTLS-Fragment-Out-of-Bounds/ba-p/6501002#.U5Cjpnmx3UY

 CVE Details
 http://www.cvedetails.com/cve/2014-0224

■「1.0.1g 」でも「-DOPENSSL_NO_NEXTPROTONEG」を付けてコンパイルされていれば
 影響なしとのことだが。。。

 OpenSSL の Man-in-the-middle 攻撃可能な脆弱性の影響
 https://sect.iij.ad.jp/d/2014/06/069806.html

■「1.0.1e」ベースで、「-DOPENSSL_NO_NEXTPROTONEG」というコンパイルオプションなし。

$ sudo openssl version -a | grep compiler | sed s/" \-"/"\n&"/g | column
[sudo] password for labunix: 
compiler: gcc			 -Wl,-z,relro
 -fPIC				 -Wa,--noexecstack
 -DOPENSSL_PIC			 -Wall
 -DZLIB				 -DMD32_REG_T=int
 -DOPENSSL_THREADS		 -DOPENSSL_IA32_SSE2
 -D_REENTRANT			 -DOPENSSL_BN_ASM_MONT
 -DDSO_DLFCN			 -DOPENSSL_BN_ASM_MONT5
 -DHAVE_DLFCN_H			 -DOPENSSL_BN_ASM_GF2m
 -m64				 -DSHA1_ASM
 -DL_ENDIAN			 -DSHA256_ASM
 -DTERMIO			 -DSHA512_ASM
 -g				 -DMD5_ASM
 -O2				 -DAES_ASM
 -fstack-protector		 -DVPAES_ASM
 --param=ssp-buffer-size=4	 -DBSAES_ASM
 -Wformat			 -DWHIRLPOOL_ASM
 -Werror=format-security	 -DGHASH_ASM
 -D_FORTIFY_SOURCE=2

■「DSA-2950-1」で修正されていることになっているけれど。。。

$ w3m -dump "https://security-tracker.debian.org/tracker/DSA-2950-1"
DSA-2950-1

Name             DSA-2950-1
Description      openssl - security update
Source           Debian
References       CVE-2014-0195, CVE-2014-0221, CVE-2014-0224, CVE-2014-3470
Debian/oldstable not known to be vulnerable.
Debian/stable    package openssl is vulnerable.
Debian/testing   not known to be vulnerable.
Debian/unstable  not known to be vulnerable.

Vulnerable and fixed packages

The table below lists information on source packages.

Source Package      Release          Version        Status
openssl (PTS)  wheezy            1.0.1e-2+deb7u7  vulnerable
               wheezy (security) 1.0.1e-2+deb7u10 fixed

The information above is based on the following data on fixed versions.

Package  Type  Release  Fixed Version   Urgency Origin Debian Bugs
openssl source wheezy  1.0.1e-2+deb7u10

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Search for package or bug name: [                    ][Go] Reporting problems
Home - Testing Security Team - Debian Security - Source (SVN)

■apache2のSSLモジュールを有効に。IPv6をIPv4にして、フッタを削除。

$ sudo apt-get install -y apache2; \
  sudo a2enmod ssl; \
  sudo /etc/init.d/apache2 restart; \
  netstat -an | grep "\:80 \|\:443 "
tcp6       0      0 :::80                   :::*                    LISTEN     
tcp6       0      0 :::443                  :::*                    LISTEN     

$ sudo sed -i s/"Listen 443"/"Listen 0.0.0.0:443"/g /etc/apache2/ports.conf; \
  sudo sed -i s/"Listen 80"/"Listen 0.0.0.0:80"/g /etc/apache2/ports.conf; \
  sudo /etc/init.d/apache2 restart; \
  netstat -an | grep "\:80 \|\:443 "
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:443             0.0.0.0:*               LISTEN     

$ sudo sed -i s/"ServerSignature On"/"#&"/ /etc/apache2/conf.d/security; \
  sudo sed -i s/"#\(ServerSignature Off\)"/"\1"/ /etc/apache2/conf.d/security; \
  sudo /etc/init.d/apache2 restart

■「ccsinjection.c」で確認。ダメじゃん。

$ URL="https://gist.githubusercontent.com/rcvalle/71f4b027d61a78c42607/raw/b44892562a3062c8e2451915d233f50849bb0924/";\ 
  TARGET="ccsinjection.c"; \
  wget -O "${TARGET}" "${URL}${TARGET}"; \
  gcc -o ccsinjection "$TARGET"

$ ./ccsinjection 
Usage: ./ccsinjection [-123dhv][-p port] host

$ ./ccsinjection -v -p 443 localhost
Connected to localhost:443
159 bytes sent
304 bytes received
127.0.0.1: Vulnerable

■再起動していないから?そんなはずは無い。

$ sudo shutdown -r now && exit

$ grep openssl /var/log/dpkg.log | tail -1
2014-06-07 12:09:14 status installed openssl:amd64 1.0.1e-2+deb7u10
$ sudo grep reboot /var/log/syslog | sed s/"`hostname -s`"/"localhost"/g
Jun  9 18:55:32 localhost /usr/sbin/cron[2757]: (CRON) INFO (Running @reboot jobs)
Jun  9 22:25:36 localhost shutdown[11047]: shutting down for system reboot
Jun  9 22:26:25 localhost /usr/sbin/cron[2771]: (CRON) INFO (Running @reboot jobs)

■再起動してもダメでした。

$ ./ccsinjection -d -p 443 localhost
Connected to localhost:443
00000000  16 03 01 00 9a 01 00 00  96 03 01 53 95 b4 e3 d6  ...........S....
00000010  a0 68 96 2c 8c 85 19 a4  bb 89 4a f0 0c 29 37 1a  .h.,......J..)7.
00000020  0e d6 17 da a1 fc d5 0c  6a 37 e2 00 00 68 c0 14  ........j7...h..
00000030  c0 13 c0 12 c0 11 c0 10  c0 0f c0 0e c0 0d c0 0c  ................
00000040  c0 0b c0 0a c0 09 c0 08  c0 07 c0 06 c0 05 c0 04  ................
00000050  c0 03 c0 02 c0 01 00 39  00 38 00 37 00 36 00 35  .......9.8.7.6.5
00000060  00 33 00 32 00 31 00 30  00 2f 00 16 00 15 00 14  .3.2.1.0./......
00000070  00 13 00 12 00 11 00 10  00 0f 00 0e 00 0d 00 0c  ................
00000080  00 0b 00 0a 00 09 00 08  00 07 00 06 00 05 00 04  ................
00000090  00 03 00 02 00 01 01 00  00 05 00 0f 00 01 01     ............... 
159 bytes sent
00000000  3c 21 44 4f 43 54 59 50  45 20 48 54 4d 4c 20 50  <!DOCTYPE.HTML.P
00000010  55 42 4c 49 43 20 22 2d  2f 2f 49 45 54 46 2f 2f  UBLIC."-//IETF//
00000020  44 54 44 20 48 54 4d 4c  20 32 2e 30 2f 2f 45 4e  DTD.HTML.2.0//EN
00000030  22 3e 0a 3c 68 74 6d 6c  3e 3c 68 65 61 64 3e 0a  ">.<html><head>.
00000040  3c 74 69 74 6c 65 3e 35  30 31 20 4d 65 74 68 6f  <title>501.Metho
00000050  64 20 4e 6f 74 20 49 6d  70 6c 65 6d 65 6e 74 65  d.Not.Implemente
00000060  64 3c 2f 74 69 74 6c 65  3e 0a 3c 2f 68 65 61 64  d</title>.</head
00000070  3e 3c 62 6f 64 79 3e 0a  3c 68 31 3e 4d 65 74 68  ><body>.<h1>Meth
00000080  6f 64 20 4e 6f 74 20 49  6d 70 6c 65 6d 65 6e 74  od.Not.Implement
00000090  65 64 3c 2f 68 31 3e 0a  3c 70 3e 16 03 01 20 74  ed</h1>.<p>....t
000000a0  6f 20 2f 69 6e 64 65 78  2e 68 74 6d 6c 20 6e 6f  o./index.html.no
000000b0  74 20 73 75 70 70 6f 72  74 65 64 2e 3c 62 72 20  t.supported.<br.
000000c0  2f 3e 0a 3c 2f 70 3e 0a  3c 2f 62 6f 64 79 3e 3c  />.</p>.</body><
000000d0  2f 68 74 6d 6c 3e 0a                              /html>.         
215 bytes received
127.0.0.1: Vulnerable

■今日はここまで。。。