Manual:Securing database passwords/ja
This page might be not up to date
Contents |
LocalSettings.php [edit]
LocalSettings.php はMySQLデータベースパスワードと、WikiSysopパスワードを含む。phpファイルは管理者用のwikiアカウントと同様、世界中にパスワードを表わしてしまういくつかの異なった条件下で平文テキストとして提供されることが出来るので、LocalSettings.php中のそれらのパスワードをそのままにしておくのはリスクがある。もしも、管理者アカウントとパスワードを秘密にして起きたいと思ったならば、LocalSettigs.phpからそれを削除する
LocalSettings.php はもしも以下の場合に平文テキストとして提供することが出来る:
- Phpがサーバ上で無効になっている場合
- Phpそれ自身が壊れている場合
- そのドメイン中のどこかで(共通のcgi検索スクリプト)search.plというcgiを持っている。Description of exploit.
apacheがこのファイルにアクセスすることを得ることが出来るかを検査し、ログインしたときこのファイルへのアクセスは管理者のみにする。
修正(理論) [edit]
apacheのユーザが何であるかをディストリビューションで調べる(これは変化し、例としては、"apache"、"nobody"、"httpd"が含まれる)。次に、以下のように、mediawikiをインストールする先のフォルダのためにパーミッションを設定する:
chown apache mediawikifolder chgrp apache mediawikifolder chmod o-rxw mediawikifolder (その他ユーザからアクセス権を取り去る) (probably repeat with g-rxw ... for LocalSettings.php ) uがrとxを持っていることを確実にする(か、chmod 500 LocalSettings.php)
注意: もしもapacheの所有者とグループに対してwikiフォルダの所有者とグループを変更する権利が許可されている場合のみ、上記の修正は動作する。 もしも、上記を実行した場合:Access deniedを得る。これを防ぐには以下を行なう:
chmod 755 mediawikifolder
注意: LocalSettings.phpのために次に必要とされる権利は:
chmod 500 LocalSettings.php
実行ビットは不要である。 注意: "mediawikifolder" は、mediawikiインストールを置くためのフォルダである(すなわち、/var/www/mediawiki)
編集: これは、Localsettings.phpが、他の人に対して読み出し権を持たせる必要があるように見える; chmod o+rx LocalSettings.php を行なう
例 [edit]
全体を通してのセキュリティはないが、"other"としてファイルにapacheがアクセスすることは、セキュアであることからは遠い。
mediawikiに対する既定値のパーミッションは root:root -rw-rw-r-- で、ディレクトリを検索する。
上記のようにapacheとして所有者を設定することを推奨する(あるいは、サーバ上で名前を付けなければならないもの)。現在、グループをapacheにも設定できるか、データにアクセスできるごくわずかの人のグループに設定できる。憶えておくこと:もしも可能ならば、rootとして振る舞わないこと!staff中にいる通常の利用者として代りに振る舞う。
現在、staffかそれに名前を付けたいもののグループを作成する。もしもすでに存在するならば、エラーとなるだろう。
kuser & #on KDE with a gui, very simple groupadd staff #or on posix-terminal add per hand addgroup putYourNameHere staff #add him to staff addgroup putNextNameHere staff #add him to staff addgroup root staff #add him to staff
この設定を推奨する(これらのコマンドを1つづつ実行できる):
export mediawikifolder="/var/www/mw6" #put your setting here
export apacheID="www-data" #put your setting here, see above for examples
export groupID="staff" #example, name it as you like or as you've set it earlier
chown -R "$apacheID":"$groupID" $mediawikifolder
chmod -R 460 $mediawikifolder #user can read, group can read and write others are not allowed
#- be careful, directories come later
chmod -R 660 $mediawikifolder/images #we need write access for user(=apache) and group - you see,
#noone else allowed
chmod 660 $mediawikifolder/config # Allow write access for installation,
chmod -R u+X $mediawikifolder #only user and staff can lookup (x on dirs)
chmod -R g+X $mediawikifolder
later set
chmod 060 $mediawikifolder/config # Only staff
この時点で、なぜグループapacheが設定しなれればならないかを見ることが出来ない。もしも、いくつかのもクールや拡張で問題が生じたならば、以下を行なうことが出来る:
export mediawikifolder="/var/www/mw6" #put your setting here export groupID="apache" #be sure to take right groupname that apache needs chgroup -R $groupID $mediawikifolder
MysqlパスワードをWebrootの外に置く [edit]
web root中にテキストファイル中にmysqlのパスワードを置いてはならない。以下を実行してこれを防ぐことが出来る:
- Make a directory outside your web root. For example, if your website is located at "/htdocs/www-wiki", then make a directory called "external_includes" outside of your webroot:
- mkdir /external_includes
- Create a file in the directory you just made called something like "mysql_pw" and place a variable on a separate line for each of your mysql user name, password, hostname, and database name, each variable being set to the real values. For example, using vi as your editor:
- vi /external_includes/mysql_pw
- i (vi command for insert)
- Type the following lines using the real values of course in place of the bracketed "mysql_" fillers:
- $db_host="[mysql_host]";
- $db_name="[mysql_db_name]";
- $db_user="[mysql_user]";
- $db_password="[mysql_password]";
<?php $db_host="[mysql_host]"; $db_name="[mysql_db_name]"; $db_user="[mysql_user]"; $db_password="[mysql_password]"; ?>
-
- Save the file. In vi this is: [Escape Key]ZZ
- Chmod and/or chown this file as explained in the previous example for LocalSettings.php so apache can read it. Usually something like:
chown apache /htdocs/external_includes/mysql_pw chmod o-rw /htdocs/external_includes/mysql_pw
- Now edit your LocalSettings.php file and add the following line in the beginning of the file:
- require_once("[FULL ABSOLUTE PATH TO mysql_pw]") (in our example this would be: require_once ("/external_includes/mysql_pw");
- Now instead of your real password, user name, database name, and host name do this in LocalSettings.php:
$wgDBserver = $db_host; $wgDBname = $db_name; $wgDBuser = $db_user; $wgDBpassword = $db_password;
もしもLocalSettings.phpに対して、だれかがアクセスかつ表示可能な場合、すべての人が見ることが出来るものは、真のパスワードの代りに変数、ユーザ名、などである。それらの情報を含む真のファイルやMySQLデータベースのために、webサーバに対して制限はない。引き続き、上記で説明したように、apacheユーザに対して、読み出しのみ、LocalSettings.phpを設定しなければならない。
注意 もしも、webサーバプロバイダがそれをさせないという理由で、それらの変更を行ない、利用者へのアクセスがない場合、ftp経由で、"external_includes" へ設定しなければならない最低限の権利は: "rwxr-xr-x"である。"mysql_pw" ファイルのために、"rwxr-xr--"をセットしなければならず、そうでないと、wikiは動作しない。繰り返すと、機密情報があるファイルはworld acces を外すという理由で、パスワードは安全になる。
PHP breakage security problems [edit]
If your php breaks, it will serve LocalSettings.php as a regular file, giving the world your wiki database password!
修正 [edit]
(may break elsewhere!)
<IfModule !sapi_apache2.c>
<Files ~ '\.php$'>
Order allow,deny
Deny from all
Allow from none
</Files>
<Files ~ '\.phps'>
Order deny,allow
Allow from all
</Files>
</IfModule>
Replace sapi_apache2.c with mod_php4.c for apache 1.3
Replace sapi_apache2.c with mod_php5.c for apache 2
| 言語: | English • 日本語 |
|---|
