ブログ

Ruby On Rails Security Guideの訳 : 4.4 File Downloads

2010年04月30日(金)15:00|木村

こんにちは。木村です。

今回は4.4 File Downloadsです。

原文の単語と全く違う言葉に置きかえている場合が多々あります。原文ページと併せて、ご覧下さい。気になる箇所や間違っている箇所があれば、どうかご指摘下さい。

では、以下訳です。 私です。

ああああ

———————-

4.4 File Downloads

4.4 ファイルダウンロード

- Make sure users cannot download arbitrary files.
  • ユーザが任意のファイルをダウンロードできないように確認する。
Just as you have to filter file names for uploads, you have to do so for downloads. The send_file() method sends files from the server to the client. If you use a file name, that the user entered, without filtering, any file can be downloaded:

アップロード時にファイル名にフィルターをかけなければならないように、ダウンロードの場合もフィルターをかける必要があります。send_file()メソッドはサーバからクライアントにファイルを送ります。もしユーザが入力したファイル名をフィルタなしで使用しているならば、どんなファイルもダウンロードされます。

Simply pass a file name like “../../../etc/passwd” to download the server’s login information. A simple solution against this, is to check that the requested file is in the expected directory:

“../../../etc/passwd”というようなファイル名を渡すだけでサーバのログイン情報をダウンロードできてしまいます。これに対する簡単な解決方法は、リクエストされたファイルが期待通りのディレクトリの中のファイルであるかチェックすることです。

Another (additional) approach is to store the file names in the database and name the files on the disk after the ids in the database. This is also a good approach to avoid possible code in an uploaded file to be executed. The attachment_fu plugin does this in a similar way.

もう1つの(さらなる)アプローチはファイル名をデータベースに保存して、データベースのIDでディスク上のファイル名をつけることです。これはアップロードファイル中の実行可能なコードを回避するための良いアプローチでもあります。attachment_fuプラグインは似たような方法でこれを実行します。

———————-

次回は5 Intranet and Admin Securityです。

この記事に関するお問い合わせはこちら

ページの先頭へ