============================================================================= FreeBSD-SA-02:14 Security Advisory FreeBSD, Inc. トピック: pam-pgsql の port が認証をバイパスされる問題 カテゴリ: ports モジュール: pam-pgsql 告知日: 2002-03-12 クレジット: Jacques A. Vidrine 影響範囲: pam-pgsql port prior to pam-pgsql-0.5.2 修正日: 2002-01-21 20:06:05 UTC FreeBSD 固有: NO I. 背景 - Background pam-pgsql is a PAM module which allows PAM-enabled applications such as login(1) to use a PostgreSQL database for user authentication. pam-pgsql は、login(1) のような PAM が有効になっているアプリケーションで、 ユーザの認証に PostgreSQL データベースを利用できるようにするための PAM モジュールです。 II. 問題の詳細 - Problem Description The affected versions of the pam-pgsql port contain a vulnerability that may allow a remote user to cause arbitrary SQL code to be executed. pam-pgsql constructs a SQL statement to be executed by the PostgreSQL server in order to lookup user information, verify user passwords, and change user passwords. The username and password given by the user is inserted into the SQL statement without any quoting or other safety checks. この問題の影響を受けるバージョンの pam-pgsql の port には、リモート ユーザが任意の SQL コードを実行できる脆弱性があります。pam-pgsql は ユーザ情報の検索やパスワードの確認・変更を行うために PostgreSQL サー バに実行させる SQL 文を生成します。ユーザから与えられるユーザ名や パスワードは、クオーティングやその他の安全性チェックといった処理を何も 行わずに、SQL 文の中に挿入されてしまいます。 The pam-pgsql port is not installed by default, nor is it "part of FreeBSD" as such: it is part of the FreeBSD ports collection, which contains thousands of third-party applications in a ready-to-install format. The ports collection shipped with FreeBSD 4.4 contains this problem since it was discovered after the release. pam-pgsql の port はデフォルトではインストールされていませんし、 「FreeBSD の一部」でもありません。それは数千のサードパーティ製アプリ ケーションをすぐにインストールできる形式で収録した FreeBSD ports collection の一部です。FreeBSD 4.4 のリリース後にこの問題が発見された ため、これと同時にリリースされた ports collection にはこの問題が含まれ ています。 FreeBSD makes no claim about the security of these third-party applications, although an effort is underway to provide a security audit of the most security-critical ports. FreeBSD は、このようなサードパーティ製アプリケーションのセキュリティに ついて、何か主張するということはありません。しかし、システムのセキュリ ティに大きな影響を与える ports に関しては、セキュリティ監査を提供する よう努力を続けています。 III. 影響範囲 - Impact A user interacting with a PAM-enabled application may insert arbitrary SQL code into the username or password fields during authentication or while changing passwords, leading to several exploit opportunities. In all versions of the pam-pgsql port prior to 0.5.2, attackers may add or change user account records. In addition, in versions of the pam-pgsql port prior to 0.3, attackers may cause pam-pgsql to completely bypass password authentication, allowing them to authenticate as any user and obtain unauthorized access using the PAM-enabled application. Since common PAM applications include login(1) and sshd(8), both local and remote attacks are possible. PAM が有効になっているアプリケーションと対話するユーザは、認証や パスワードの変更を行う際に、ユーザ名やパスワードのフィールドに任意の SQL コードを挿入できる可能性があります。これによって、ユーザは攻撃の 機会を与られることになります。0.5.2 より前の全てのバージョンの pam-pgsql の port では、攻撃者はユーザのアカウントレコードの追加・ 変更を行うことができます。さらに、0.3 以前のバージョンでは、攻撃者 は pam-pgsql を利用してパスワード認証を完全に回避して任意のユーザと して認証を受けることができます。これにより、PAM が有効になっている アプリケーションを認証なしで利用することができます。login(1) や sshd(8) でも PAM が有効になっているため、この脆弱性によりローカル・リモート 双方からの攻撃が可能です。 IV. 回避方法 - Workaround 1) Deinstall the pam-pgsql port/package if you have it installed. 1) pam-pgsql の port や package をインストールしている場合は、これを 削除してください。 V. 解決方法 - Solution One of the following: 以下のいずれかを実行してください: 1) Upgrade your entire ports collection and rebuild the port. 1) port collection 全体をアップグレードし、port をリビルドします。 2) Download a new port skeleton for the pam-pgsql port from: 2) 以下の場所から pam-pgsql の port 用の新しい port スケルトンを ダウンロードします: http://www.freebsd.org/ports/ and use it to rebuild the port. そして、これを使って port をリビルドします。 3) Use the portcheckout utility to automate option (2) above. The portcheckout port is available in /usr/ports/devel/portcheckout or the package can be obtained from: 3) 上記の選択肢 (2) の作業を自動化するために、portcheckout ユーティリティ を使用します。portcheckout の port は /usr/ports/devel/portcheckcout で 利用できるほか、以下の場所から package を入手することもできます: ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/i386/packages-4-stable/Latest/portcheckout.tgz VI. 修正の詳細 - Correction details The following list contains the revision numbers of each file that was corrected in the FreeBSD Ports Collection. 以下のリストは、FreeBSD Ports Collection の中で修正されたファイルの リビジョン番号です。 Path Revision - ------------------------------------------------------------------------- ports/security/pam-pgsql/Makefile 1.9 ports/security/pam-pgsql/distinfo 1.3 ports/security/pam-pgsql/pkg-descr 1.2 - ------------------------------------------------------------------------- VII. 参考資料 - References This vulnerability is very similar to previous vulnerabilities involving Apache modules and discovered by RUS-CERT. この脆弱性は、以前 RUS-CERT が発見した Apache のモジュールに含まれる 脆弱性に非常に良く似ています。