LoginSignup
5
3

More than 5 years have passed since last update.

observatoryでWebアプリケーションの脆弱性診断

Last updated at Posted at 2019-04-01

はじめに

前回に引き続きウェブアプリケーションの脆弱性診断です。
observatoryも使ってみました。

observatoryとは

mozillaが提供している脆弱性診断サービスです。
URLを入力するだけで100点満点で採点してくれます。とっても手軽です。
スコア表

診断

使い方は簡単。
ここにアクセスして、診断対象のURLを入力するだけ。

結果と対策

55点。。
結果が見やすいですね。
capt9.png

Laravelでの対策はこちらを参考にさせてもらいました。

CSPの設定

下記で設定したところ、さらに引っかかりました。
content-security-policy: style-src 'self'
capt10.png

  • Blocks execution of inline JavaScript by not allowing 'unsafe-inline' inside script-src

javascriptやcssのリソースを制限する指定です。ここで指定したリソースのみ許可されます。
'unsafe-inline'は攻撃の対象となってしまうので、推奨はされないようですが、ワンタイムのハッシュを用意するのが面倒なので、'unsafe-inline'を設定します。

selfも許可したいのでこんな感じです。
Content-Security-Policy: script-src 'self' 'unsafe-inline'

  • Blocks execution of plug-ins, using object-src restrictions

オブジェクト(画像など)のリソースを制限する指定です。ここで指定したリソースのみ許可されます。

selfのみ許可します。
Content-Security-Policy: object-src 'self'

  • Clickjacking protection, using frame-ancestors

,

  • Deny by default, using default-src 'none'

デフォルトで使うリソースの指定です。
他の場所で明示的に許可設定をしているため、noneを設定します。
Content-Security-Policy: default-src 'none'

  • Restricts use of the tag by using base-uri 'none', base-uri 'self', or specific origins

baseは使う予定がないので、noneを設定します。
Content-Security-Policy: base-uri 'none'

  • Restricts where contents may be submitted by using form-action 'none', form-action 'self', or specific URIs

フォームアクションはselfを設定します。
Content-Security-Policy: form-action 'self'

最後に

上記対策を施して、最終的に結果はB+となりました。
script-src 'unsafe-inline'の除去とCSRFのトークンのsecure化をしないと、
満点には届かなそうです。。

参考:
- HSTS (HTTP Strict Transport Security) の導入
- コンテンツセキュリティポリシー (CSP)

5
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
3