phpinfo.phpとかやめようよ

PHPの関数にphpinfo()というものがあり、これをPHPファイルに含めるとPHPの設定・動作状況が分かるので使ったことのある方は多いだろう。しかしそのPHPファイルをサイトのドキュメント・ルートに、「phpinfo.php」や「info.php」などと非常に分かりやすい名前で設置している例を非常によく見かける。1度や2度ではない。
本人はすぐ消すから大丈夫だと思ってそうしているのだろうが、人間は忘れる動物である。その証拠に私が発見した事例は全て「運用中」のサイトであり、つまりは「消し忘れ」であった。
PHPの設定・動作状況を他人に晒すことは、セキュリティ・ホールの発見のお手伝いをしているのと同じなのでもっと注意深く設置する必要がある。
対策の一つとしては、パスワードで保護された領域にこれを置くことである。しかしこれは現実性を欠く。既にそういう領域があるならよいが、たかが設定情報をみるためにパスワードで保護された領域を作るなんて面倒だ(大抵の場合、phpinfo()を使うのは急いでいる時である)。面倒なことは人間はやらない。やらないから「phpinfo.php」を置いてしまう。
現実的な対策としては、パスワードのように慎重に選ばれたランダムな文字列をファイル名に使うことだ。Webブラウザ側から当該ディレクトリの内容を表示できないようにしておくのは言うまでもない。
「ランダムな文字列」と言ってもキーボードをデタラメに打たない方がいい。これは概して同じような文字列を生みやすい(それでも「phpinfo.php」よりは幾分マシである)。手軽なのはmkpasswdのようなコマンドを利用するか、ユーザーの目に触れない適当なファイルのハッシュ値を利用するものである。強度については保証しない。「phpinfo.php」に比べればずっとマシだということだ。例を示す。
% md5 /HTTPDDIR/logs/error_log MD5 (/HTTPDDIR/logs/error_log) = d2ab851dc39a79617a41ce44323b5bbc % echo '<?php phpinfo(); ?>' > d2ab851dc39a79617a41ce44323b5bbc.php
当然、確認が終わったらそのファイルは削除されなければならない。大抵のシェルには補完機能があるのだから、ファイルを選択するのはそう苦ではないはずだ。
追記
phpinfo.phpをgoogleで検索してみたら、なんと日本だけで1万件、Web全体で30万件ものヒットがあった。これを設置して動かなくて困っているもの、チュートリアルとして設置することを指示しているもの、中にはプロバイダのマニュアルの中にさえphpinfo.phpを作れという表記が見受けられた。時にはBASIC認証をコード中に科している几帳面な方もいたが、ほとんどは無防備である。「あとで消すこと」を推奨していないサイトが多いのにも驚いた。思いのほかphpinfo.php病は進行しているようだ。
2011/12/09 - 20:25:41 -
Awesome website
[…]the time to read or visit the content or sites we have linked to below the[…]…
2011/12/10 - 00:06:56 -
Superb website
[…]always a big fan of linking to bloggers that I love but don’t get a lot of link love from[…]…
2011/12/10 - 00:38:51 -
Yahoo results
While browsing Yahoo I found this page in the results and I thought it looked interesting
2011/12/10 - 02:50:19 -
Dreary Day
It was a dreary day here today, so I just took to messing around online and realized
2011/12/10 - 02:56:00 -
Read was interesting, stay in touch…
[…]please visit the sites we follow, including this one, as it represents our picks from the web[…]…
2011/12/10 - 06:03:33 -
Online Article…
[…]The information mentioned in the article are some of the best available […]…
2011/12/10 - 12:21:24 -
You should check this out
[…] Wonderful story, reckoned we could combine a few unrelated data, nevertheless really worth taking a look, whoa did one learn about Mid East has got more problerms as well […]…
2011/12/10 - 22:08:15 -
Cool site, I hope mine will be this good some day
[…]My partner and I stumbled over here by a different web address and thought I might check things out. I like what I see so i am just following you. Look forward to looking at your web page for a second time.[…]
2011/12/11 - 00:37:50 -
Websites you should visit
[…]below you’ll find the link to some sites that we think you should visit[…]…
2011/12/12 - 02:48:14 -
Sources
[…]check below, are some totally unrelated websites to ours, however, they are most trustworthy sources that we use[…]…
2011/12/12 - 10:20:03 -
You should check this out
[…] Wonderful story, reckoned we could combine a few unrelated data, nevertheless really worth taking a look, whoa did one learn about Mid East has got more problerms as well […]…
2011/12/12 - 14:30:43 -
Interesting….
A very unique post.
2011/12/12 - 17:11:58 -
Websites we think you should visit
[…]although websites we backlink to below are considerably not related to ours, we feel they are actually worth a go through, so have a look[…]…
2011/12/12 - 17:51:35 -
Great website…
[…]here are some hyper-links to sites that we link to as we feel they are really worth browsing[…]…
2011/12/12 - 18:28:27 -
Blogs ou should be reading
[…]Here is a Great Blog You Might Find Interesting that we Encourage You[…]…
2011/12/12 - 19:54:55 -
Sites we Like…
[…] Every once in a while we choose blogs that we read. Listed below are the latest sites that we choose […]…
2011/12/13 - 13:43:26 -
Informative and precise
Its hard to find informative and accurate info but here I found
2011/12/13 - 18:19:05 -
Interesting….
A very interesting post.
2011/12/14 - 10:02:45 -
Websites worth visiting
[…]here are some links to sites that we link to because we think they are worth visiting[…]…
2011/12/15 - 06:04:20 -
Sites we Like…
[…] Every once in a while we choose blogs that we read. Listed below are the latest sites that we choose […]…
2011/12/15 - 12:01:41 -
Tumblr article
I saw someone talking about this on Tumblr and it linked to
2011/12/15 - 16:27:12 -
Visitor recommendations
[…]one of our visitors recently recommended the following website[…]…
2011/12/15 - 20:30:26 -
Sources
[…]check below, are some totally unrelated websites to ours, however, they are most trustworthy sources that we use[…]…
2011/12/15 - 21:50:42 -
Recent Blogroll Additions…
[…]usually posts some very interesting stuff like this. If you’re new to this site[…]…
2011/12/16 - 00:59:59 -
Superb website
[…]always a big fan of linking to bloggers that I love but don’t get a lot of link love from[…]…
2011/12/16 - 03:47:19 -
Visitor recommendations
[…]one of our visitors recently recommended the following website[…]…
2011/12/16 - 05:35:37 -
Gems form the internet
[…]very few websites that happen to be detailed below, from our point of view are undoubtedly well worth checking out[…]…
2012/01/10 - 08:33:05 -
Cheers,Well it appears this internet site is somewhat sizzling, congratulations towards the owner! I try to go .through as much as feasible on the web when I’ve extra time. However it is beginning to get the norm for men and women to invest all day for the internet instead of of basically,By far the most concise and up to date information I have found on this topic.
2012/01/12 - 06:12:10 -
Hey there could you please tell me which hosting company you’re working with? Also can you recommend an honest web hosting provider at a normal price? Thank you, in advance!