CVE-2015-0235はRHEL4/CentOS4に影響する&修正版提供開始(2015/01/30 20:40版)


CVE-2015-0235 というglibcに大きめのバグが見つかった模様。

RedHat Enterprise Linux 4 / CentOS 4に対して影響があるのかどうかを調べてみた。

まずは、RedHat公式情報系

・RedHat Bugzilla:Bug 1183461 – (CVE-2015-0235) CVE-2015-0235 glibc: __nss_hostname_digits_dots() heap-based buffer overflow
 ・RHEL Knowledgebase Articles:GHOST: glibc vulnerability (CVE-2015-0235) / GHOST: glibc 脆弱性 (CVE-2015-0235)
 ・RHEL CVEデータベース:CVE-2015-0235
 ・RHEL4向け:RHSA-2015:0101:Critical: glibc security update
 ・RHEL5向け:RHSA-2015:0090:Critical: glibc security update
 ・RHEL6,RHEL7向け:RHSA-2015:0092:Critical: glibc security update

はい、RHEL4も対象になっています。

実際に確認してみるため、openwallにあるCVE-2015-0235についての詳細報告書「Qualys Security Advisory CVE-2015-0235 – GHOST: glibc gethostbyname buffer overflow」の「4 – Case studies」の記述を試してみる。

実行した際に「vulnerable」と出たら、問題あり。
「not vulnerable」だったら問題なし、というもの。

[root@cent4 201501]# mkdir security
[root@cent4 201501]# cd security/
[root@cent4 security]# rpm -qa|grep glibc|sort
警告: only V3 signatures can be verified, skipping V4 signature
glibc-2.3.4-2.57
glibc-2.3.4-2.57
glibc-common-2.3.4-2.57
glibc-devel-2.3.4-2.57
glibc-devel-2.3.4-2.57
glibc-headers-2.3.4-2.57
glibc-kernheaders-2.4-9.1.103.EL
[root@cent4 security]# cat > GHOST.c << EOF
> #include <netdb.h>
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
> #include <errno.h>
>
> #define CANARY "in_the_coal_mine"
>
> struct {
>   char buffer[1024];
>   char canary[sizeof(CANARY)];
> } temp = { "buffer", CANARY };
>
> int main(void) {
>   struct hostent resbuf;
>   struct hostent *result;
>   int herrno;
>   int retval;
>
>   /*** strlen (name) = size_needed - sizeof (*host_addr) - sizeof (*h_addr_ptrs) - 1; ***/
>   size_t len = sizeof(temp.buffer) - 16*sizeof(unsigned char) - 2*sizeof(char *) - 1;
>   char name[sizeof(temp.buffer)];
>   memset(name, '0', len);
>   name[len] = '\0';
>
>   retval = gethostbyname_r(name, &resbuf, temp.buffer, sizeof(temp.buffer), &result, &herrno);
>
>   if (strcmp(temp.canary, CANARY) != 0) {
>     puts("vulnerable");
>     exit(EXIT_SUCCESS);
>   }
>   if (retval == ERANGE) {
>     puts("not vulnerable");
>     exit(EXIT_SUCCESS);
>   }
>   puts("should not happen");
>   exit(EXIT_FAILURE);
> }
> EOF
[root@cent4 security]# ls
GHOST.c
[root@cent4 security]# gcc GHOST.c -o GHOST
[root@cent4 security]# ls
GHOST  GHOST.c
[root@cent4 security]# ./GHOST
vulnerable
[root@cent4 security]#

「vulnerable」なので、「問題あり」確定です。

修正版については、RHEL4の通常サポートは終了。現在はELSと呼ばれる特別な契約者向けに提供されているものだけが更新されています。

前述の「RHSA-2015:0101 Critical: glibc security update」にあるとおり、修正されたglibcのバージョンは「glibc-2.3.4-2.57.el4.2」となります。

ただ、このバージョンは通常の方法ではRHEL4およびCentOS4には提供されません。

しかし、RHEL4のソースを元にOracleで再構成した、Oracle Linux 4は、まだサポートを行っています。
こちらから、ファイルを持ってくることで対応が可能となっています。

Oracle Linux 4向けのSource RPMは、「https://oss.oracle.com/el4/SRPMS-updates/」にて提供されています。
Oracle LinuxではRHEL4とパッケージバージョンが若干異なり「glibc-2.3.4-2.57.0.1.el4.1」となります。
https://oss.oracle.com/el4/SRPMS-updates/glibc-2.3.4-2.57.0.1.el4.1.src.rpm

ただ、今回のことを受けて更新されたコンパイル済みのRPMは、glibc関連だけではなかったりします。
nptl-devel, nscdも更新されています。
このため、今回については、glibcのSource RPMだけを持ってきてコンパイルして適用、というのは、あまりお薦めできないような感じです。

コンパイル済みのRPMファイルについて、Oracle Linuxでは「Oracle Public Yum Server」としてレポジトリを公開しており、適切な設定を行うことで、RHEL4/CentOS4からOracle Linux 4に乗り換え、yumコマンドによるアップデートが行えるようになります。

コンパイル済みRPMファイル自体は「http://public-yum.oracle.com/repo/EnterpriseLinux/EL4/latest/」以下を探せば出てきますので、ページを「2015」で検索し出てくるパッケージが自分のサーバにインストールされているかを確認し、ダウンロードして適用する、ということが可能です。

しかし、依存関係解決とか面倒なので、これを機会にOracle Linux 4に乗り換えてしまう、というのも手かもしれません。

切り替え方法については、「RHEL4/CentOS4をOracle Linux4に!」にて紹介していますので、興味がある方は参照してみてください。
設定は非常に簡単です。

こちらの環境ではOralce Linux 4になっているため「yum update -y」で更新が完了しました。

更新後、再度テストプログラムを実行してみます。

[root@cent4 security]# ./GHOST
not vulnerable
[root@cent4 security]#

「not vulnerable」と出力されるので、脆弱性は修正されている、ということになります。

これで、一安心、といったところです。


<以下は修正版のglibcが出る前に書いたものです。資料として残しておきます>

glibcに大きめのバグが見つかった模様。
CVE-2015-0235

・RedHat Bugzilla:Bug 1183461 – (CVE-2015-0235) CVE-2015-0235 glibc: __nss_hostname_digits_dots() heap-based buffer overflow
 ・RHEL CVEデータベース:CVE-2015-0235
 ・RHEL5向け:RHSA-2015:0090-1:Critical: glibc security update
 ・RHEL6,RHEL7向け:RHSA-2015:0092-1:Critical: glibc security update

RHEL4/CentOS4についての記載が見付からない。

Oracle LinuxのSource RPM置き場 https://oss.oracle.com/el4/SRPMS-updates/ を見ても、2015/01/28 10:35時点では何も無し。

(2015/01/28 23:00 追加)
1時間ぐらい前に「GHOST: glibc vulnerability (CVE-2015-0235)」にRed Hat Enterprise Linux 4 Extended Life Cycle Supportに関する記述が追加された。
いまのところ修正版に関する記述はないが、RHEL4に脆弱性がある、という公式告知になっている。

(2015/01/29 19:30追加)
Red Hat Enterprise Linux ELS (v. 4)に対するSecurity Advisoryが公開された。
RHSA-2015:0101 Critical: glibc security update

ELS契約者向けに glibc-2.3.4-2.57.el4.2 としてリリースされたので、そのうちOracle Linuxにも波及してくるものと想定されるが、現状はまだ公開されていない。

(2015/01/30 14:20追加)
https://oss.oracle.com/el4/SRPMS-updates/ に、glibc-2.3.4-2.57.0.1.el4.1.src.rpmが置かれました。
Oralce Linux 4のpublic yumレポジトリのほう(repo url)にはまだ登録されていないようです。

(2015/01/30 16:30追加)
Oracle Linux 4のpublic yumレポジトリでの配布が始まりました。

以下の16:20ぐらいの段階ではi386(32bit)版のみだったのですが、16:37にはx86_64(64bit)版のディレクトリにもファイルが置かれ始めました。

i386(32bit)版
 http://public-yum.oracle.com/repo/EnterpriseLinux/EL4/latest/i386/getPackage/glibc-common-2.3.4-2.57.0.1.el4.1.i386.rpm
 http://public-yum.oracle.com/repo/EnterpriseLinux/EL4/latest/i386/getPackage/glibc-devel-2.3.4-2.57.0.1.el4.1.i386.rpm
 http://public-yum.oracle.com/repo/EnterpriseLinux/EL4/latest/i386/getPackage/glibc-headers-2.3.4-2.57.0.1.el4.1.i386.rpm
 http://public-yum.oracle.com/repo/EnterpriseLinux/EL4/latest/i386/getPackage/glibc-profile-2.3.4-2.57.0.1.el4.1.i386.rpm
 http://public-yum.oracle.com/repo/EnterpriseLinux/EL4/latest/i386/getPackage/glibc-utils-2.3.4-2.57.0.1.el4.1.i386.rpm
 http://public-yum.oracle.com/repo/EnterpriseLinux/EL4/latest/i386/getPackage/nptl-devel-2.3.4-2.57.0.1.el4.1.i386.rpm
 http://public-yum.oracle.com/repo/EnterpriseLinux/EL4/latest/i386/getPackage/nptl-devel-2.3.4-2.57.0.1.el4.1.i686.rpm
 http://public-yum.oracle.com/repo/EnterpriseLinux/EL4/latest/i386/getPackage/nscd-2.3.4-2.57.0.1.el4.1.i386.rpm

64bit(x86_64)版
 

(追加部分おわり)

openwallにあるCVE-2015-0235についての詳細報告書「Qualys Security Advisory CVE-2015-0235 – GHOST: glibc gethostbyname buffer overflow」の「4 – Case studies」には事象確認方法が記載されている。

下記をコンパイルして、実行した際に「vulnerable」と出たら、問題あり。
「not vulnerable」だったら問題なし、というもの。

#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>

#define CANARY "in_the_coal_mine"

struct {
  char buffer[1024];
  char canary[sizeof(CANARY)];
} temp = { "buffer", CANARY };

int main(void) {
  struct hostent resbuf;
  struct hostent *result;
  int herrno;
  int retval;

  /*** strlen (name) = size_needed - sizeof (*host_addr) - sizeof (*h_addr_ptrs) - 1; ***/
  size_t len = sizeof(temp.buffer) - 16*sizeof(unsigned char) - 2*sizeof(char *) - 1;
  char name[sizeof(temp.buffer)];
  memset(name, '0', len);
  name[len] = '\0';

  retval = gethostbyname_r(name, &resbuf, temp.buffer, sizeof(temp.buffer), &result, &herrno);

  if (strcmp(temp.canary, CANARY) != 0) {
    puts("vulnerable");
    exit(EXIT_SUCCESS);
  }
  if (retval == ERANGE) {
    puts("not vulnerable");
    exit(EXIT_SUCCESS);
  }
  puts("should not happen");
  exit(EXIT_FAILURE);
}

さて・・・CentOS4ではどうなっているのか?

[root@cent4 201501]# mkdir security
[root@cent4 201501]# cd security/
[root@cent4 security]# rpm -qa|grep glibc|sort
警告: only V3 signatures can be verified, skipping V4 signature
glibc-2.3.4-2.57
glibc-2.3.4-2.57
glibc-common-2.3.4-2.57
glibc-devel-2.3.4-2.57
glibc-devel-2.3.4-2.57
glibc-headers-2.3.4-2.57
glibc-kernheaders-2.4-9.1.103.EL
[root@cent4 security]# cat > GHOST.c << EOF
> #include <netdb.h>
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
> #include <errno.h>
>
> #define CANARY "in_the_coal_mine"
>
> struct {
>   char buffer[1024];
>   char canary[sizeof(CANARY)];
> } temp = { "buffer", CANARY };
>
> int main(void) {
>   struct hostent resbuf;
>   struct hostent *result;
>   int herrno;
>   int retval;
>
>   /*** strlen (name) = size_needed - sizeof (*host_addr) - sizeof (*h_addr_ptrs) - 1; ***/
>   size_t len = sizeof(temp.buffer) - 16*sizeof(unsigned char) - 2*sizeof(char *) - 1;
>   char name[sizeof(temp.buffer)];
>   memset(name, '0', len);
>   name[len] = '\0';
>
>   retval = gethostbyname_r(name, &resbuf, temp.buffer, sizeof(temp.buffer), &result, &herrno);
>
>   if (strcmp(temp.canary, CANARY) != 0) {
>     puts("vulnerable");
>     exit(EXIT_SUCCESS);
>   }
>   if (retval == ERANGE) {
>     puts("not vulnerable");
>     exit(EXIT_SUCCESS);
>   }
>   puts("should not happen");
>   exit(EXIT_FAILURE);
> }
> EOF
[root@cent4 security]# ls
GHOST.c
[root@cent4 security]# gcc GHOST.c -o GHOST
[root@cent4 security]# ls
GHOST  GHOST.c
[root@cent4 security]# ./GHOST
vulnerable
[root@cent4 security]#

駄目でした。

とりあえず、続報待ちということで・・・

(2015/01/30 16:50追記)
Oralce public yum repoで提供されたのでアップデートを行い、試験実施。

[root@cent4 security]# ./ghost
not vulnerable
[root@cent4 security]#

問題がなくなったことを確認できました。

なお、Oracle Linux public レポジトリからyumコマンドを使ってファイルを持ってこれるようにするには「RHEL4/CentOS4をOracle Linux4に!」で紹介しているようにOracle Linuxに切り替えてしまう、というのが簡単でいいと思います。

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください