こんにちは。木村です。
今回は4 Redirection and Filesから
4.1 Redirectionです。
原文の単語と全く違う言葉に置きかえている場合が多々あります。原文ページと併せて、ご覧下さい。気になる箇所や間違っている箇所があれば、どうかご指摘下さい。
では、以下訳です。
4 Redirection and Files
4 リダイレクトとファイル
Another class of security vulnerabilities surrounds the use of redirection and files in web applications.
もう1つの種類のセキュリティ脆弱性はリダイレクトの使用とウェブアプリケーションのファイルの周辺に存在します。
4.1 Redirection
4.1 リダイレクト
- Redirection in a web application is an underestimated cracker tool: Not only can the attacker forward the user to a trap web site, he may also create a self-contained attack.
- webアプリケーションのリダイレクトはクラッカーツールとして甘く見られています。攻撃者は罠のあるwebサイトにユーザを転送できるだけでなく、内包型の攻撃を作り出すこともできます。
Whenever the user is allowed to pass (parts of) the URL for redirection, it is possibly vulnerable. The most obvious attack would be to redirect users to a fake web application which looks and feels exactly as the original one.
This so-called phishing attack works by sending an unsuspicious link in an email to the users, injecting the link by XSS in the web application or putting the link into an external site. It is unsuspicious, because the link starts with the URL to the web application and the URL to the malicious site is hidden in the redirection parameter: http://www.example.com/site/redirect?to= www.attacker.com. Here is an example of a legacy action:
ユーザが(部分的な)リダイレクトURLの通過を許可されるときはいつでも、攻撃を受けやすい可能性があります。最も分かりやすい攻撃は、オリジナルサイトと勘違いするような偽者のwebアプリケーションにユーザをリダイレクトすることでしょう。いわゆるフィッシング攻撃はユーザへのメールで疑わしくないリンクを送りつけるか、webアプリケーションのXSSをリンクに入れるか、外部サイトへのリンクを設置します。フィッシング攻撃は不審に思われません。なぜなら、リンクはwebアプリケーションへのURLで始まり、悪意のあるサイトへのURLはリダイレクトパラメータに隠されているからです。http://www.example.com/site/redirect?to= www.attacker.com. あるlegacyアクションの例が次の通りです。
def
legacy redirect_to(params.update(:action=>'main'))
end
This will redirect the user to the main action if he tried to access a legacy action. THowever, it can exploited by an attacker if he includes a host key in the URL:he intention was to preserve the URL parameters to the legacy action and pass them to the main action.
これはユーザがlegacyアクションにアクセスしようととするとmainアクションにリダイレクトします。legacyアクションへのURLパラメータをmainアクションに移動する時に保持することが目的です。しかしながら、URLにホストキーを含めることで攻撃者に悪用される可能性があります。
http://www.example.com/site/legacy?param1=xy¶m2=23&host=www.attacker.com
If it is at the end of the URL it will hardly be noticed and redirects the user to the attacker.com host. A simple countermeasure would be to include only the expected parameters in a legacy action (again a whitelist approach, as opposed to removing unexpected parameters). And if you redirect to an URL, check it with a whitelist or a regular expression.
URLの終わりがこのようになっていれば、ほぼ気づかれずにユーザをattacker.comホストにリダイレクトします。簡単な対策方法はlegacyアクションに期待されるパラメータだけ含めることでしょう。(また一方で期待されないパラメータを削除するのとは対照的なホワイトリストという方法があります)もしリダイレクトするときは、ホワイトリストか正規表現でURLをチェックしてください。
4.1.1 Self-contained XSS
4.1.1 内包型のXSS
Another redirection and self-contained XSS attack works in Firefox and Opera by the use of the data protocol. This protocol displays its contents directly in the browser and can be anything from HTML or JavaScript to entire images:
もう1つのリダイレクトと内包型のXSSによる攻撃はデータプロトコルを使うことでFirefoxとOperaで動作します。このプロトコルはそのコンテンツをブラウザで直接表示し、HTMLやJavaScriptから完全な画像まで何にでもなれます。
data:text/html;base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4K
This example is a Base64 encoded JavaScript which displays a simple message box. In a redirection URL, an attacker could redirect to this URL with the malicious code in it. As a countermeasure, do not allow the user to supply (parts of) the URL to be redirected to.
この例は簡単なメッセージボックスを表示するJavaScriptをBase64エンコードしたものです。リダイレクトURLで使用する場合は、攻撃者は悪意のあるコードをデータプロトコルに含めることでリダイレクトすることができます。対策方法としては、(部分的な)リダイレクトURLをユーザに使わせないことです。
次回は4.2 File Uploadsです。



… ①
の計算量(時間的)がかかります。
とすると
です。
… ②
… ③
です。頂点間に枝があるかを調べる計算量(時間的)は
です。
… ④
です。頂点間に枝があるかを調べる計算量(時間的)は
です。