FreeBSD-SA-06:12.opie "OPIE arbitrary password change"

The FreeBSD Project よりセキュリティ勧告が出ました。私の認識を以下にまとめます。

  • 危険度中


セキュリティ勧告は ftp://ftp.freebsd.org/pub/FreeBSD/CERT/advisories/FreeBSD-SA-06:12.opie.asc にあります。
以下は上記のセキュリティ勧告の一部とその翻訳です。ただし品質は保証致しません。

I. 背景 - Background

OPIE is a one-time password system designed to help to secure a system against replay attacks. It does so using a secure hash function and a challenge/response system. The opiepasswd(1) program is used to set up OPIE authentication for a user. OPIE is enabled by default on FreeBSD through PAM.
OPIEはリプレイ攻撃に対してシステムを保全するのに役立つように設計されたワンタイムパスワードシステムです。これは安全なハッシュ関数とチャレンジ/レスポンスシステムを使用します。opiepasswd(1)プログラムはユーザのOPIE認証をセットアップするのに使われています。OPIEはPAMによりFreeBSDではデフォルトで有効です。

II. 問題の詳細 - Problem Description

The opiepasswd(1) program uses getlogin(2) to identify the user calling opiepasswd(1). In some circumstances getlogin(2) will return "root" even when running as an unprivileged user. This causes opiepasswd(1) to allow an unpriviled user to configure OPIE authentication for the root user.
opiepasswd(1)プログラムはopiepasswd(1)を呼び出したユーザを確認するためにgetlogin(2)を使用します。ある状況でgetlogin(2)は権限のないユーザとして実行している時でさえも「root」であると返します。これによりopiepasswd(1)は権限がないユーザにrootユーザのOPIE認証を設定させる事を許します。

III. 影響範囲 - Impact

In certain cases an attacker able to run commands as a non privileged users which have not explicitly logged in, for example CGI scripts run by a web server, is able to configure OPIE access for the root user. If the attacker is able to authenticate as root using OPIE authentication, for example if "PermitRootLogin" is set to "yes" in sshd_config or the attacker has access to a local user in the "wheel" group, the attacker can gain root privileges.
確かな事として、攻撃者が明示的にログインせずとも、(例えばwebサーバにより実行されるCGIスクリプトのように)権限のないユーザとしてコマンドを実行できれば、rootユーザのOPIE設定にアクセスできます。もし、攻撃者が(例えばsshd_configで「PermitRootLogin」が「yes」にセットされていたり「wheel」グループのローカルユーザにアクセスできるなど)OPIE認証を使用してrootとして認証できれば、root権限をえる事ができてしまいます。

IV. 回避方法 - Workaround

Disable OPIE authentication in PAM:
PAMでOPIE認証を無効にします:

# sed -i "" -e /opie/s/^/#/ /etc/pam.d/*

or
Remove the setuid bit from opiepasswd:
またはopiepasswdのsetuidビットをクリアします:

# chflags noschg /usr/bin/opiepasswd
# chmod 555 /usr/bin/opiepasswd
# chflags schg /usr/bin/opiepasswd