============================================================================= FreeBSD-SA-01:55 Security Advisory FreeBSD, Inc. トピック: procfs の脆弱性が set uid/gid されたプロセスのメモリを 漏洩する 分類: core モジュール: procfs 告知日: 2001-08-21 クレジット: Joost Pol 影響範囲: FreeBSD 4.x、 修正日以前の 4.3-STABLE 修正日: 2001-08-12 07:29 PDT (4.3-STABLE) 2001-08-13 12:45 PDT (RELENG_4_3) FreeBSD 固有: Yes I. 背景 - Background procfs is the process filesystem, which presents a filesystem interface to the system process table, together with associated data. procfs provides access to the memory space of processes via the synthetic /proc//mem file, subject to access control checks. procfs は、関連するデータとシステムプロセステーブルへのファイル システム型のインタフェースを提供する「プロセスファイルシステム」である。 procfs は、アクセスコントロールチェックの影響下にある /proc//mem ファイルを経由して、プロセスのメモリ空間へのアクセスを提供する。 linprocfs is an implementation of procfs which implements a Linux-style procfs, for use with Linux binaries so they can obtain access to exported kernel data. It uses procfs to provide the /proc//mem file. linprocfs は、Linux バイナリを使用する際に、それらがカーネルが 出力するデータへのアクセスできるための、Linux スタイルの procfs の 実装である。linprocfs は /proc//mem ファイルを提供するため、 procfs を使用する。 II. 問題の詳細 - Problem Description Prior to the migration of system monitoring utilities (such as ps(8)) to use the sysctl(8) management interface, these utilities formerly used procfs and direct kernel memory access to extract process information, and they ran with the setgid kmem privilege to allow direct kernel memory access. The procfs code checks for gid kmem privilege when granting access to the /proc//mem file -- however, the code which is used to allow read-only access via the kmem group was incorrect, and inappropriately granted read access to the caller as long as they already had an open file descriptor for the procfs mem file. ps(8) のようなシステムモニタリングユーティリティが sysctl(8) 管理 インタフェースを利用するようになる以前は、これらのユーティリティは プロセス情報を抽出するために、procfs とカーネルメモリへの直接アクセスを 用いており、カーネルメモリへの直接アクセスのために kmem 特権を setgid して動作していた。procfs コードは /proc//mem ファイルへの アクセスを許可する際に、kmem グループの特権をチェックする。しかし、 そのコードを用いて kmem グループを介したリードオンリーアクセスを許可する のは不適切で、既にオープンした procfs mem ファイルへのファイルディスクリプタ を持っている限り、呼び出し者に対して不適当な読み出し許可をしてしまう。 The result of this problem is that if a process initially has debugging rights to a second process, it may retain access to the target process' memory space, even if the target process has upgraded privilege by virtue of performing an execve() call on a setuid or setgid process. This vulnerability can lead to the leaking of sensitive information from such processes, which could be used as the basis for additional attacks, resulting in escalation of attacker privilege on the system. この問題の結果、プロセスが始めに第2のプロセスへの「デバッグ権」を 持っていれば、たとえ execve() で setuid や setgid されたプロセスを 呼ぶことでターゲットプロセスの権限が昇格しても、目標プロセスの メモリ空間へのアクセスを保つことができる。この脆弱性は、このような プロセスから、更なる攻撃の基礎となる極秘の情報を引き出すために利用でき、 結果としてシステム上での攻撃者の権限を昇格することになる。 The linprocfs filesystem is also vulnerable to the problem if procfs support is available in the kernel (statically compiled in, or dynamically loaded as a module). If procfs support is not available then linprocfs is not vulnerable to this problem. procfs サポートがカーネルで利用可能になっていれば(静的にカーネルに 組み込むか、モジュールとして動的にロードする)、linprocfs ファイル システムもこの問題に対して脆弱である。もし procfs サポートが利用可能 でなければ、linprocfs もまたこの問題に対して脆弱ではない。 All released versions of FreeBSD 4.x including FreeBSD 4.3-RELEASE are vulnerable to this problem if the procfs filesystem is in use. It was corrected prior to the (forthcoming) release of FreeBSD 4.4-RELEASE. FreeBSD 4.3-RELEASE を含む全てのバージョンの FreeBSD 4.x には、procfs ファイルシステムを利用するならば、この問題に対する脆弱性が存在する。 この脆弱性は、(次の)FreeBSD 4.4-RELEASE のリリース以前に修正された。 III. 影響範囲 - Impact Attackers may be able to extract sensitive system information, such as password hashes from the /etc/master.passwd file, from setuid or setgid processes, such as su(1). This information could be used by attackers to escalate their privileges, possibly yielding root privileges on the local system. 攻撃者は su(1) のような setuid や setgid されたプロセスから、 /etc/master.passwd ファイルのパスワードハッシュのような極秘の システム情報を引き出すことができる。この情報は、攻撃者の権限の昇格の ために利用でき、ローカルシステムの root 権限への昇格ををもたらす 可能性もある。 Because this attack may only be used on processes that initially are "debuggable" by the attacking process, this attack is limited to executed processes which gain privilege by virtue of being setuid or setgid, and so it cannot be used against other processes which are already running with privilege such as already-running daemons containing sensitive system information. この攻撃は、始めに攻撃するプロセスによって「デバッグ可能」なプロセス 上でのみ用いられるため、setuid や setgid によって権限が昇格する プロセスを実行しなければならないという制限がある。そのため、極秘の システム情報を含む起動済みデーモンのように、既に特権を持って実行 されている他のプロセスに対して使用することはできない。 IV. 回避方法 - Workaround To work around the problem, perform the following steps as root: この問題を回避するには、root ユーザで以下のステップを実行する: Unmount all instances of the procfs and linprocfs filesystems using the unmount(8) command: unmount(8) コマンドを使って、procfs と linprocfs ファイルシステム の全てのインスタンスをアンマウントする。 # umount -f -a -t procfs # umount -f -a -t linprocfs Disable the automatic mounting of all instances of procfs in /etc/fstab: remove or comment out the line(s) of the following form: /etc/fstab にある、procfs の全てのインスタンスの自動マウントを無効にする: 以下の形式の行を削除、もしくはコメントアウト proc /proc procfs rw 0 0 proc /compat/linux/proc linprocfs rw 0 0 V. 解決法 - Solution 1) Upgrade your vulnerable system to 4.3-STABLE or the RELENG_4_3 security branch, dated after the respective correction dates. 1) 脆弱性のあるシステムを、それぞれの修正日以降の 4.3-STABLE や RELENG_4_3 セキュリティブランチに更新する。 2) To patch your present system: download the relevant patch from the below location, and execute the following commands as root: 2) 現在のシステムにパッチを当てる: 以下の場所から適切なパッチをダウンロード し、root で以下のコマンドを実行する。 # fetch ftp://ftp.FreeBSD.org/pub/FreeBSD/CERT/patches/SA-01:55/procfs.patch # fetch ftp://ftp.FreeBSD.org/pub/FreeBSD/CERT/patches/SA-01:55/procfs.patch.asc Verify the detached PGP signature using your PGP utility. PGP ユーティリティを使って PGP シグネチャを確認する。 This patch has been verified to apply to FreeBSD 4.3-RELEASE and 4.2-RELEASE (users of 4.2-RELEASE should already have the patch from FreeBSD SA-00:77.procfs installed). It may or may not apply to older, unsupported releases of FreeBSD. このパッチは、FreeBSD 4.3-RELEASE と 4.2-RELEASE(FreeBSD SA-00:77.procfs パッチをインストール済みのもの)への適用を確認している。サポートされて いない古い FreeBSD のリリースへの適用は不明である。 # cd /usr/src/sys # patch -p < /path/to/patch If procfs is statically compiled into the kernel (i.e. the kernel configuration file contains the line 'options PROCFS'), then rebuild and reinstall your kernel as described in http://www.freebsd.org/handbook/kernelconfig.html and reboot the system with the new kernel for the changes to take effect. By default procfs is statically compiled in the GENERIC kernel configuration. procfs が静的にカーネル内にコンパイルされている(すなわち、カーネル コンフィグレーションファイルが 'options PROCFS' という行を含んでいる) 場合は、http://www.freebsd.org/handbook/kernelconfig.html で説明されて いる内容に従って再構築とインストールを行い、カーネルの変更内容を反映 させるために新しいカーネルでシステムを再起動する。標準では、procfs は GENERIC カーネルコンフィグレーションの中で、静的にコンパイルされるよう 設定されている。 If procfs is dynamically loaded by KLD (use the kldstat(8) command to verify whether this is the case) and the system securelevel has not been raised to a level of 1 or higher, the system can be patched at run-time without requiring a reboot by performing the following steps after patching the source as described above: procfs が KLD で動的にロードされる場合(このケースかどうか確認するには、 kldstat(8) コマンドを使用する)で、システムのセキュアレベルを1以上に 上げていない場合は、上記の内容に従ってソースにパッチを当てたのちに 以下のステップを行うことで、再起動せずに実行時にシステムにパッチを当てる ことができる: # cd /usr/src/sys/modules/procfs # make depend # make all install # umount -f -a -t procfs # kldunload procfs # kldload procfs # mount -a -t procfs 3) FreeBSD 4.3-RELEASE systems: 3) FreeBSD 4.3-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.3-RELEASE systems only, and is intended for use on systems for which source patching is not practical or convenient. バイナリアップグレードの処理のテストとフィードバックをしてくれる ユーザのため、実験的なアップグレードパッケージが利用可能である。この パッケージは、FreeBSD 4.3-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. インストール中に、パッケージによって置き換えられるファイルの バックアップコピーが作成される。これらのバックアップコピーは、 システムをパッチを当てる前の状態に戻すとき、パッケージを削除した あとに再インストールできる。 # fetch ftp://ftp.FreeBSD.org/pub/FreeBSD/CERT/packages/SA-01:55/security-patch-procfs-01.55.tgz # fetch ftp://ftp.FreeBSD.org/pub/FreeBSD/CERT/packages/SA-01:55/security-patch-procfs-01.55.tgz.asc Verify the detached PGP signature using your PGP utility. PGP ユーティリティを使って PGP シグネチャを確認する。 # pkg_add security-patch-procfs-01.55.tgz Restart your system after applying the patch. パッチが当てられた後、システムを再起動する。 VI. CVS リビジョン - CVS Revisions The following $FreeBSD$ CVS revisions contain the fixes for this vulnerability. The $FreeBSD$ revision of installed sources can be examined using the ident(1) command. These revision IDs are not updated by applying the patch referenced above. 以下の $FreeBSD$ CVS リビジョンは、この脆弱性の修正を含んでいる。 インストールされているソースの $FreeBSD$ リビジョンは、ident(1) コマンド を使って調べられる。これらのリビジョン ID は、上で参照されているパッチを 適用してもアップデートされない。 [FreeBSD 4.3-STABLE] Revision Path 1.3.2.5 src/sys/i386/linux/linprocfs/linprocfs_vnops.c 1.32.2.2 src/sys/miscfs/procfs/procfs.h 1.46.2.2 src/sys/miscfs/procfs/procfs_mem.c 1.76.2.5 src/sys/miscfs/procfs/procfs_vnops.c [RELENG_4_3] Revision Path 1.3.2.3.2.1 src/sys/i386/linux/linprocfs/linprocfs_vnops.c 1.32.2.1.2.1 src/sys/miscfs/procfs/procfs.h 1.46.2.1.2.1 src/sys/miscfs/procfs/procfs_mem.c 1.76.2.3.2.1 src/sys/miscfs/procfs/procfs_vnops.c