OWASP Zed Attack Proxy(ZAP)おためし

OWASP Zed Attack Proxy(ZAP)をためしてみました。

OWASP ZAPとは

Webアプリケーションのペネトレーションテストツールです。
ペネトレーションテストとは脆弱性を発見するテストです。
ツールを知ったきっかけは下記のIPAの紹介です。
https://www.ipa.go.jp/about/technicalwatch/20131212.html

試した環境

サーバ

OS:CentOS6.5 64bit
Web:Apache 2.2
DB:PostgreSQL 9.3
アプリケーション:CakePHPで自作した写真帳らしきもの

クライアント

OS:Windows7 32bit

インストール手順

クライアントにダウンロード

http://sourceforge.net/projects/zaproxy/files/2.2.2/

インストール

ダウンロードしたZAP_2.2.2_Windows.exeをダブルクリック
問題なければ初期値のまま「Next」ボタン連続押下
インストール完了

使い方

起動したら表示される「Quick Start」タブの「URL to Attack」入力欄に
ペネトレーションテスト対象のURLを入力して「攻撃」ボタンを押下するだけです。
※対象は自分が管理する検証環境上のWebアプリケーションにしてください

実際に検出された脆弱性と対応

Medium (Warning) Directory browsing

It is possible to view the directory listing. Directory listing may reveal hidden scripts, include files , backup source files etc which be accessed to read sensitive information.
(ディレクトリ内ファイル一覧が見えてるから見せたくないファイルが見られちゃうよ)

対策:httpd.confに下記を修正
「Options Indexes FollowSymLinks」などを「Options -Indexes FollowSymLinks」に修正
※上記設定をしたとしても見せたくないファイルをWebから見える位置には置かない

Low (Warning) Password Autocomplete in browser

AUTOCOMPLETE attribute is not disabled in HTML FORM/INPUT element containing password type input. Passwords may be stored in browsers and retrieved.
(パスワードがオートコンプリートできちゃうよ)

対策:パスワードのオートコンプリートをOFFに

<input name="data[User][password]" type="password" value="" id="UserPassword">

<input name="data[User][password]" type="password" value="" id="UserPassword" autocomplete="off">

Low (Warning) X-Content-Type-Options header missing

The Anti-MIME-Sniffing header X-Content-Type-Options was not set to 'nosniff'
(IEが勝手にコンテンツ内容でMIMEタイプを決めることによっておきるXSSを防ぐ
HTTPヘッダがついてないよ)

対策:httpd.confに下記を追記
Header always set X-Content-Type-Options nosniff

※上記脆弱性自体の詳細は下記URLを参照
http://d.hatena.ne.jp/hasegawayosuke/20110106/p1

Low (Information) X-Frame-Options header not set

X-Frame-Options header is not included in the HTTP response to protect against 'ClickJacking' attacks
(クリックジャッキングを防ぐHTTPヘッダがついていないよ)

対策:httpd.confに下記を追記
Header always append X-Frame-Options SAMEORIGIN

※クリックジャッキング詳細は下記URLを参照
http://blog.tokumaru.org/2013/03/clickjacking-report-by-IPA.html

まとめ

OWASP Zed Attack Proxy(ZAP)をインストールして使うのはすごく簡単でした。

体系的に学ぶ 安全なWebアプリケーションの作り方 脆弱性が生まれる原理と対策の実践

体系的に学ぶ 安全なWebアプリケーションの作り方 脆弱性が生まれる原理と対策の実践