============================================================================= FreeBSD-SA-01:63 Security Advisory FreeBSD, Inc. トピック: OpenSSH の UseLogin ディレクティブが権限の昇格を許す カテゴリ: core/ports モジュール: openssh 告知日: 2001-12-02 クレジット: Markus Friedl 影響範囲: FreeBSD 4.3-RELEASE, 4.4-RELEASE 修正日以前の FreeBSD 4.4-STABLE 修正日以前の ports コレクション 修正日: 2001-12-03 00:53:28 UTC (RELENG_4) 2001-12-03 00:54:18 UTC (RELENG_4_4) 2001-12-03 00:54:54 UTC (RELENG_4_3) 2001-12-02 06:52:40 UTC (openssh port) FreeBSD 固有: NO I. 背景 - Background OpenSSH is an implementation of the SSH1 and SSH2 secure shell protocols for providing encrypted and authenticated network access, which is available free for unrestricted use. Versions of OpenSSH are included in the FreeBSD ports collection and the FreeBSD base system. OpenSSH は、ネットワーク接続の暗号化と認証を提供する SSH1 および SSH2 セキュアシェルプロトコルの実装の一つで、使用に関する制限がなく、自由に 無料で利用することができる。OpenSSH の FreeBSD 版は、ports コレクション や FreeBSD の基本システムに含まれている。 II. 問題の詳細 - Problem Description OpenSSH includes a feature by which a user can arrange for environmental variables to be set depending upon the key used for authentication. These environmental variables are specified in the `authorized_keys' (SSHv1) or `authorized_keys2' (SSHv2) files in the user's home directory on the server. This is normally safe, as this environment is passed only to the user's shell, which is invoked with user privileges. OpenSSH には、認証用の鍵によってセットされる環境変数をユーザが変更する 機能がある。この環境変数は、サーバ上のユーザのホームディレクトリにある `authorized_keys'(SSH バージョン1)ファイルや `authorized_keys2' (SSH バージョン2)ファイルで指定する。通常は、この環境変数はユーザの 権限で起動されたシェルにのみ伝えられるため安全である。 However, when the OpenSSH server `sshd' is configured to use the system's login program (via the directive `UseLogin yes' in sshd_config), this environment is passed to login, which is invoked with superuser privileges. Because certain environmental variables such as LD_LIBRARY_PATH and LD_PRELOAD can be set using the previously described feature, the user may arrange for login to execute arbitrary code with superuser privileges. しかし、OpenSSH サーバ `sshd' がシステムのログインプログラムを使用する ように設定されていた場合(sshd_config ファイルの `UseLogin yes' という ディレクティブによって設定する)、この環境変数はスーパーユーザ権限で起動 される login プログラムに伝えられてしまう。この方法で LD_LIBRARY_PATH や LD_PRELOAD といった環境変数が設定できるため、一般ユーザが、login プログラ ムがスーパーユーザ権限で任意のコードを実行するように仕向けることができる。 All versions of FreeBSD 4.x prior to the correction date including FreeBSD 4.3 and 4.4 are potentially vulnerable to this problem. However, the OpenSSH server is configured to not use the system login program (`UseLogin no') by default, and is therefore not vulnerable unless the system administrator has changed this setting. FreeBSD 4.3、4.4 を含む、修正日以前の全ての FreeBSD 4.x には、この問題 の潜在的な脆弱性がある。しかし、デフォルトの OpenSSH サーバはシステムの login プログラムを使用しない設定(`UseLogin no')になっているため、シス テム管理者がこの設定を変更していなければ脆弱ではない。 In addition, there are two versions of OpenSSH included in the ports collection. One is ports/security/openssh, which is the BSD-specific version of OpenSSH. Versions of this port prior to openssh-3.0.2 exhibit the problem described above. The other is ports/security/openssh-portable, which is not vulnerable, even if the server is set to `UseLogin yes'. 加えて、ports コレクションに含まれる OpenSSH には二つのバージョンがある。 一つは ports/security/openssh で、これは OpenSSH の BSD 用のバージョン である。openssh-3.0.2 以前のこのタイプの port には上記の問題がある。 もう一つは ports/security/openssh-portable で、サーバが `UseLogin yes' に設定されているが、これには脆弱性はない。 III. 影響範囲 - Impact Hostile but otherwise legitimate users that can successfully authenticate using public key authentication may cause /usr/bin/login to run arbitrary code as the superuser. 悪意を持ちながら、合法的な権限も持つユーザが、公開鍵認証方式で認証を 成功させることで /usr/bin/login にスーパーユーザ権限で任意のコードを 実行させる可能性がある。 If you have not enabled the 'UseLogin' directive in the sshd configuration file, you are not vulnerable to this problem. sshd の設定ファイルで `UseLogin' ディレクティブを有効にしていない場合は、 この問題による脆弱性の影響は受けない。 IV. 回避方法 - Workaround Doing one of the following will eliminate the vulnerability: 以下のいずれかを実行する事で、脆弱性を無効にできる: 1) Configure sshd to not use the system login program. Edit the server configuration file and change any `UseLogin' directives to `UseLogin no'. This is the preferred workaround. 1) システムの login プログラムを使用しないように sshd を設定する。 ssh サーバの設定ファイルを修正し、`UseLogin' ディレクティブを `UseLogin no' に変更する。通常はこの回避方法が望ましい。 2) If for whatever reason, disabling `UseLogin' is not possible, then one can instead disable public key authentication. Edit the server configuration file and change any `RSAAuthentication', `DSAAuthentication', or `PubKeyAuthentication' directives to `RSAAuthentication no', `DSAAuthentication no', and `PubKeyAuthentication no', respectively. 2) 何らかの理由で `UseLogin' を無効にすることが不可能な場合は、その 代わりに公開鍵認証を無効にすることができる。ssh サーバの設定ファイ ルを修正し、`RSAAuthentication'、`DSAAuthentication'、 `PubKeyAuthentication' ディレクティブを、それぞれ `RSAAuthentication no'、`DSAAuthentication no'、 `PubKeyAuthentication no' に変更する。 For sshd included in the base system (/usr/bin/sshd), the server configuration file is `/etc/ssh/sshd_config'. For sshd from the ports collection, the server configuration file is `/usr/local/etc/sshd_config'. FreeBSD の基本システムに組み込まれている sshd(/usr/bin/sshd)の設定 ファイルは `/etc/ssh/sshd_config' に置かれている。ports コレクション からインストールした sshd の場合は `/usr/local/etc/sshd_config' にある。 After modifying the sshd configuration file, the sshd daemon must be restarted by executing the following command as root: sshd の設定ファイルを修正後 root 権限で以下のコマンドを実行し、sshd デーモンを再起動しなければならない。 # kill -HUP `cat /var/run/sshd.pid` V. 解決法 - Solution 1) Upgrade the vulnerable system to 4.3-RELEASEp21, 4.4-RELEASEp1, or 4.4-STABLE after the correction date, or patch your current system source code and rebuild. 1) 脆弱性のあるシステムを、4.3-RELEASEp21 や 4.4-RELEASEp1、および 修正日 以降の 4.4-STABLE にアップグレードするか、現在のシステムのソースコードに パッチを当て、システムを再構築する。 2) FreeBSD 4.x systems prior to the correction date: 2) 修正日以前の FreeBSD 4.x システムの場合: The following patch has been verified to apply to FreeBSD 4.3-RELEASE, 4.4-RELEASE, and 4.4-STABLE dated prior to the correction date. It may or may not apply to older, unsupported versions of FreeBSD. 以下のパッチは FreeBSD 4.3-RELEASE、4.4-RELEASE および修正日以前の 4.4-STABLE への適用を確認している。これより古い、サポート外の バージョンの FreeBSD には正しく適用できない可能性がある。 Download the patch and the detached PGP signature from the following locations, and verify the signature using your PGP utility. 以下の場所からパッチと PGP シグネチャをダウンロードし、PGP ユーティリティ を使ってシグネチャを確認する。 # fetch ftp://ftp.FreeBSD.org/pub/FreeBSD/CERT/patches/SA-01:63/sshd.patch # fetch ftp://ftp.FreeBSD.org/pub/FreeBSD/CERT/patches/SA-01:63/sshd.patch.asc root 権限で以下のコマンドを実行する: Execute the following commands as root: # cd /usr/src/crypto/openssh # patch < /path/to/sshd.patch # cd /usr/src/secure/usr.sbin/sshd # make depend && make all install 3) FreeBSD 4.4-RELEASE systems: 3) FreeBSD 4.4-RELEASE システムの場合: An experimental upgrade package is available for users who wish to provide testing and feedback on the binary upgrade process. This package may be installed on FreeBSD 4.4-RELEASE systems only, and is intended for use on systems for which source patching is not practical or convenient. バイナリアップグレード処理のテストとフィードバックを希望するユーザの ため、実験的なアップグレードパッケージが利用可能である。このパッケージは FreeBSD 4.4-RELEASE システムのみにインストール可能で、ソースへのパッチ当て が現実的でなかったり、都合が悪かったりするシステムでの利用を意図している。 If you use the upgrade package, feedback (positive or negative) to security-officer@FreeBSD.org is requested so we can improve the process for future advisories. このアップグレードパッケージを利用する場合は、将来の勧告のためにアップ グレード処理を改良できるよう、security-officer@FreeBSD.org 宛てに フィードバック(肯定・否定を問わない)をお願いする。 During the installation procedure, backup copies are made of the files which are replaced by the package. These backup copies will be reinstalled if the package is removed, reverting the system to a pre-patched state. In addition, the package automatically restarts the sshd daemon if it is running. インストール処理中に、パッケージによって上書きされるファイルのバック アップコピーが作成される。このバックアップコピーは、パッケージが削除 されると再インストールされ、システムをパッチを当てる前の状態に戻す。 加えて、sshd デーモンが動作している場合は、このパッケージが自動的に デーモンの再起動を行う。 Three versions of the upgrade package are available, depending on whether or not the system has the kerberosIV or kerberos5 distributions installed. システムに kerberonIV か kerberos5 のディストリビューションがインス トールされている場合と、何もインストールされていない場合について、 3種類のアップグレードパッケージが利用可能である。 3a) For systems without kerberosIV or kerberos5 installed: 3a) kerberosIV や kerberos5 がインストールされていないシステムの場合: # fetch ftp://ftp.FreeBSD.org/pub/FreeBSD/CERT/packages/SA-01:63/security-patch-sshd-01.63.tgz # fetch ftp://ftp.FreeBSD.org/pub/FreeBSD/CERT/packages/SA-01:63/security-patch-sshd-01.63.tgz.asc Verify the detached PGP signature using your PGP utility. PGP ユーティリティを使って PGP シグネチャを確認する。 # pkg_add security-patch-sshd-01.63.tgz 3b) For systems with kerberosIV only installed: 3b) kerberosIV のみがインストールされているシステムの場合: # fetch ftp://ftp.FreeBSD.org/pub/FreeBSD/CERT/packages/SA-01:63/security-patch-sshd-kerberosIV-01.63.tgz # fetch ftp://ftp.FreeBSD.org/pub/FreeBSD/CERT/packages/SA-01:63/security-patch-sshd-kerberosIV-01.63.tgz.asc Verify the detached PGP signature using your PGP utility. PGP ユーティリティを使って PGP シグネチャを確認する。 # pkg_add security-patch-sshd-kerberosIV-01.63.tgz 3c) For systems with kerberos5 only installed: 3c) kerberos5 のみがインストールされているシステムの場合: # fetch ftp://ftp.FreeBSD.org/pub/FreeBSD/CERT/packages/SA-01:63/security-patch-sshd-kerberos5-01.63.tgz # fetch ftp://ftp.FreeBSD.org/pub/FreeBSD/CERT/packages/SA-01:63/security-patch-sshd-kerberos5-01.63.tgz.asc Verify the detached PGP signature using your PGP utility. PGP ユーティリティを使って PGP シグネチャを確認する。 # pkg_add security-patch-sshd-kerberos5-01.63.tgz 3d) For systems with both kerberosIV and kerberos5 installed: 3d) kerberosIV と kerberos5 が両方インストールされているシステムの場合: # fetch ftp://ftp.FreeBSD.org/pub/FreeBSD/CERT/packages/SA-01:63/security-patch-sshd-kerberosIV-kerberos5-01.63.tgz # fetch ftp://ftp.FreeBSD.org/pub/FreeBSD/CERT/packages/SA-01:63/security-patch-sshd-kerberosIV-kerberos5-01.63.tgz.asc Verify the detached PGP signature using your PGP utility. PGP ユーティリティを使って PGP シグネチャを確認する。 # pkg_add security-patch-sshd-kerberosIV-kerberos5-01.63.tgz [Ports collection] [ports コレクションの場合] One of the following: 以下のいずれかを実行する: 1) Upgrade your entire ports collection and rebuild the OpenSSH port. 1) ports コレクション全体をアップグレードし、OpenSSH port をリビルドする。 2) Deinstall the old package and install a new package dated after the correction date, obtained from: 2) 古いパッケージを削除し、以下の URL で取得できる修正日以降の新しい パッケージをインストールする: [i386] ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/i386/packages-4-stable/security/openssh-3.0.2.tgz ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/i386/packages-5-current/security/openssh-3.0.2.tgz [alpha] Packages are not automatically generated for the alpha architecture at this time due to lack of build resources. NOTE: It may be several days before updated packages are available. Be sure to check the file creation date on the package, because the version number of the software has not changed. 注意: アップデートパッケージが利用可能になるまで何日かかかるかもしれない。 ソフトウェアのバージョン番号は変わらないため、必ずパッケージのファイル 生成日時を確認すること。 3) Download a new port skeleton for the openssh port from: 3) 以下の URL から openssh port 用の新しい port スケルトンをダウンロードする: http://www.freebsd.org/ports/ and use it to rebuild the port. そして、それを使って port をリビルドする。 4) Use the portcheckout utility to automate option (3) above. The portcheckout port is available in /usr/ports/devel/portcheckout or the package can be obtained from: 4) portcheckout ユーティリティを使って、上記の (3) の選択肢を自動化する。 portcheckout の port は、/usr/ports/devel/portcheckout で利用できるほか、 以下の URL から package を入手することもできる: ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/i386/packages-4-stable/devel/portcheckout-2.0.tgz ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/i386/packages-5-current/devel/portcheckout-2.0.tgz VI. 修正の詳細 - Correction details Path Revision Branch ------------------------------------------------------------------------- src/crypto/openssh/session.c HEAD 1.18 RELENG_4 1.4.2.11 RELENG_4_4 1.4.2.8.4.1 RELENG_4_3 1.4.2.8.2.1 src/crypto/openssh/version.h HEAD 1.9 RELENG_4 1.1.1.1.2.7 RELENG_4_4 1.1.1.1.2.5.2.1 RELENG_4_3 1.1.1.1.2.4.2.1 ports/security/openssh/Makefile 1.79 ------------------------------------------------------------------------- For OpenSSH included in the base system, there is a version string indicating which FreeBSD localizations are available. The following table lists the version strings for each branch which include this security fix: FreeBSD の基本システムに含まれる OpenSSH の場合、FreeBSD 限定のバージョンを 示すバージョン文字列が存在する場合がある。以下の表は、このセキュリティ フィックスを含むブランチそれぞれのバージョン文字列の一覧である。 Branch Version string ------------------------------------------------------------------------- HEAD OpenSSH_2.9 FreeBSD localisations 20011202 RELENG_4 OpenSSH_2.9 FreeBSD localisations 20011202 RELENG_4_4 OpenSSH_2.3.0 FreeBSD localisations 20011202 RELENG_4_3 OpenSSH_2.3.0 green@FreeBSD.org 20011202 ------------------------------------------------------------------------- To view the version string of the OpenSSH server, execute the following command: OpenSSH サーバのバージョン文字列を表示するには、以下のコマンドを実行する: % /usr/sbin/sshd -\? The version string is also displayed when a client connects to the server. バージョン文字列は、クライアントがサーバに接続する際にも表示される。 VII. 参考文献 - References