Apache を利用したユーザ名検索




Apache の設定によっては、そのシステムに存在するユーザを検索することができる。

OCN などのプロバイダが公開している Web サーバではユーザ検索が可能。
ユーザ毎にホームディレクトリを Web 上に公開するためには必要な設定のため仕方無い。

Web サーバをプロバイダのような使い方をしない場合は、
ユーザ名の漏えいにつながるため検索できないようにしたい。

関係するディレクティブは次の箇所。

下の例は CentOS 5 にインストールした httpd-2.2.3 のデフォルト設定。

設定ファイルは /etc/httpd/conf/httpd.conf

#
# UserDir: The name of the directory that is appended onto a user's home
# directory if a ~user request is received.
#
# The path to the end user account 'public_html' directory must be
# accessible to the webserver userid.  This usually means that ~userid
# must have permissions of 711, ~userid/public_html must have permissions
# of 755, and documents contained therein must be world-readable.
# Otherwise, the client will only receive a "403 Forbidden" message.
#
# See also: http://httpd.apache.org/docs/misc/FAQ.html#forbidden
#
<IfModule mod_userdir.c>
    #
    # UserDir is disabled by default since it can confirm the presence
    # of a username on the system (depending on home directory
    # permissions).
    #
    UserDir disable

    #
    # To enable requests to /~user/ to serve the user's public_html
    # directory, remove the "UserDir disable" line above, and uncomment
    # the following line instead:
    #
    #UserDir public_html

</IfModule>

[ UserDir disable ] となっているので、この設定あればユーザの検索はできません。

これを次のように変更するとユーザ検索が可能になります。

#
# UserDir: The name of the directory that is appended onto a user's home
# directory if a ~user request is received.
#
# The path to the end user account 'public_html' directory must be
# accessible to the webserver userid.  This usually means that ~userid
# must have permissions of 711, ~userid/public_html must have permissions
# of 755, and documents contained therein must be world-readable.
# Otherwise, the client will only receive a "403 Forbidden" message.
#
# See also: http://httpd.apache.org/docs/misc/FAQ.html#forbidden
#
<IfModule mod_userdir.c>
    #
    # UserDir is disabled by default since it can confirm the presence
    # of a username on the system (depending on home directory
    # permissions).
    #
    #UserDir disable

    #
    # To enable requests to /~user/ to serve the user's public_html
    # directory, remove the "UserDir disable" line above, and uncomment
    # the following line instead:
    #
    UserDir public_html

</IfModule>

httpd.conf の設定を変更したら、httpd を再起動して設定を反映。

ブラウザから URL に「http://[ サーバの IP アドレス ]/~root/」とすると、
403 Forbidden となる。

これは root ユーザが存在するため。

「http://[ サーバの IP アドレス ]/~xxxx/」とすると
404 Not Found ( Web ページがみつかりません)となる。

これは xxxx ユーザが存在しないため。

このエラーコードの違いによってユーザを検索することができる。

[ UserDir disable ] となっていれば、どのユーザを指定しても
404 Not Found ( Web ページがみつかりません)となり
存在するかどうかは分からない。