このブログに過去、Content Security Policy を reports-only で適用しました。
前回 ポリシーを変更してから3-4ヶ月が経過しましたので、再度レポートを集計し、定義を見直していきます。
結果を以下に記載します。


前回変更時の記事

AMP HTML を作成後に、Content Security Policy (CSP) の report を 集計して、ポリシーを見直す | Monotalk


現在のポリシー定義

Content-Security-Policy-Report-Only:
script-src 'self' 'unsafe-inline' 'unsafe-eval' pagead2.googlesyndication.com www.google-analytics.com *.disqus.com c.disquscdn.com 
disqus.com *.googletagmanager.com *.google-analytics.com *.ampproject.org;
child-src 'self' 'unsafe-inline' *.disquscdn.com *.google.com *.googleapis.com;
default-src 'self';
frame-src 'self' googleads.g.doubleclick.net staticxx.facebook.com *.disqus.com disqus.com kemsakurai.github.io *.ampproject.net;
img-src 'self' *.disqus.com *.disquscdn.com *.googleusercontent.com *.google.com *.googledrive.comgoogledrive.com data: googledrive.com drive.google.com www.gstatic.com www.monotalk.xyz ssl.gstatic.com ir-jp.amazon-adsystem.com ssl.google-analytics.com; 
connect-src 'self' *.disqus.com; 
object-src pagead2.googlesyndication.com; 
font-src 'self' fonts.gstatic.com; 
report-uri /report/

CSP のレポートデータの収集と、集計について

MongoDB に レポートデータは登録しています。
収集、集計方法については以下をご確認ください。
Content Security Policy (CSP) の report を 10 日くらい集計して、ポリシーを見直す(の途中) | Monotalk


集計と、修正の方針

violated-directive ごとのblocked-uri を集計、その結果を元にポリシー定義を修正しています。
集計には、AMP HTML を作成後に、Content Security Policy (CSP) の report を 集計して、ポリシーを見直す | Monotalk に記載している MongoDB のクエリ を使用しています。
TOP10 以下も存在しますが、ほとんどのアクセスが TOP10以内に含まれていたため、TOP10以下は除外しています。

violated-directive ごとの blocked-uri の集計結果

violated-directive : script-src での 集計

  • 結果
count blocked-uri
13494 https://adservice.google.com/adsid/integrator.js?domain=www.monotalk.xyz
13036 https://adservice.google.co.jp/adsid/integrator.js?domain=www.monotalk.xyz
12384 https://uh.nakanohito.jp/uhj2/uh.js
128 https://platform.twitter.com/widgets.js
123 https://cdn.syndication.twimg.com/tweets.json?callback=__twttr.callbacks.cb0&ids=874550250010062850&lang=ja&suppress_response_codes=true&tz=GMT%2B0900
123 https://cdn.syndication.twimg.com/tweets.json?callback=__twttr.callbacks.cb1&ids=707785040256577537&lang=ja&suppress_response_codes=true&tz=GMT%2B0900
110 https://platform.twitter.com/js/tweet.77b0c8c821734364d3d725fc2955821b.js
55 https://googleads.g.doubleclick.net/pagead/js/dev/r20110914/abg_lite.js
55 data
48 https://tagmanager.google.com/debug/angular-bundle.js

violated-directive : style-src での 集計

  • 結果
count blocked-uri
1449 https://monotalk.xyz/static/CACHE/css/690a0d57c104.css
141 https://platform.twitter.com/css/tweet.6ca4ddceb51c98199a0b1f03f7ae4215.light.ltr.css
104 https://ton.twimg.com/tfw/css/syndication_bundle_v1_ac9c00781f6ab647a4d4dd7643c30675945c778e.css
94 https://monotalk.xyz/static/CACHE/css/b73f5cfafde5.css
25 https://ton.twimg.com/tfw/css/syndication_bundle_v1_3ea2b4f6d180bf8853ce37fcffcb3e134eb658d5.css
20 https://www.monotalk.xyz/static/CACHE/css/b73f5cfafde5.css
19 https://pwm-image.trendmicro.jp/3.7/extensionFrame/styles/engineV3.css
14 https://www.monotalk.xyz/static/CACHE/css/690a0d57c104.css
8 https://monotalk.xyz/static/CACHE/css/5ebef948ce2c.css
5 https://platform.twitter.com/css/tweet.fe926dfa02e1503196d3aa2c6cd7dc97.light.ltr.css
4 https://platform.twitter.com/css/tweet.7ad0231982d083c3fa704ffb2eeb271f.light.ltr.css
4 https://ton.twimg.com/tfw/css/syndication_bundle_v1_ed012b3d930543799769ad5d5ce207a67e6ae62d.css
1 https://platform.twitter.com
1 https://ton.twimg.com
  • 各ドメインごとの設定要否

    • monotalk.xyz
      このブログのドメインになります。現在、monotalk.xyzwww.monotalk.xyz でもアクセスできるようにしています。
      自ドメインの設定は行っていなかったので、許可します。

    • platform.twitter.com twitter の埋め込み記事により出力されているため、許可します。

    • ton.twimg.com twitter の埋め込み記事により出力されているため、許可します。

    • www.monotalk.xyz
      このブログのドメインになります。現在、monotalk.xyzwww.monotalk.xyz でもアクセスできるようにしています。
      自ドメインの設定は行っていなかったので、許可します。

    • pwm-image.trendmicro.jp これは、パスワードマネージャー などの plugin でのアクセスでしょうか。
      設定はせず、様子を見ます。

violated-directive : frame-src での 集計

frame-src から、child-src に変更したのですが、report は frame-src で記録されているようです。

  • 結果
count blocked-uri
331
244 https://platform.twitter.com
154 data
121 https://syndication.twitter.com
62 https://securepubads.g.doubleclick.net
28 https://api.weblio.jp
19 https://pwm-image.trendmicro.jp
12 chrome-error
9 https://www.googletagmanager.com
8 http://rcm-fe.amazon-adsystem.com

violated-directive : connect-src での 集計

  • 結果
count blocked-uri
11323 https://uh0.nakanohito.jp/uhb2/
1008 https://www.google-analytics.com/r/collect
332 https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js
142 https://www.google-analytics.com/collect
126 https://syndication.twitter.com/settings
69 https://www.googletagmanager.com/amp.json?id=GTM-5KQPP3P&gtm.url=https%3A%2F%2Fwww.monotalk.xyz%2F&__amp_source_origin=https%3A%2F%2Fwww.monotalk.xyz
47 https://3p.ampproject.net/1509747505247/f.js
46 https://3p.ampproject.net/1508794187431/f.js
42 https://3p.ampproject.net/1508896929494/f.js
38 https://3p.ampproject.net/1510180045130/f.js
34 https://3p.ampproject.net/1506372648650/f.js

violated-directive : font-src での集計

  • 結果
count blocked-uri
873 https://monotalk.xyz/static/fonts/Lora-regular/Lora-regular.woff?5ddec16961e4
873 https://monotalk.xyz/static/fonts/Open-Sans-regular/Open-Sans-regular.woff?5ddec16961e4
873 https://monotalk.xyz/static/fonts/Open-Sans-800/Open-Sans-800.woff2?5ddec16961e4
873 https://monotalk.xyz/static/fonts/Open-Sans-800/Open-Sans-800.woff?5ddec16961e4
873 https://monotalk.xyz/static/fonts/fontawesome-webfont.woff?v=4.2.0&2bfd01227ee4
873 https://monotalk.xyz/static/fonts/Lora-italic/Lora-italic.woff?5ddec16961e4
873 https://monotalk.xyz/static/fonts/Open-Sans-800/Open-Sans-800.ttf?5ddec16961e4
873 https://monotalk.xyz/static/fonts/Open-Sans-regular/Open-Sans-regular.woff2?5ddec16961e4
873 https://monotalk.xyz/static/fonts/fontawesome-webfont.ttf?v=4.2.0&2bfd01227ee4
873 https://monotalk.xyz/static/fonts/Lora-italic/Lora-italic.woff2?5ddec16961e4
  • 各ドメインごとの設定要否
    • monotalk.xyz
      自ドメインですので、許可します。

violated-directive = object-src での 集計

  • 結果
count blocked-uri
2

2件、空白のデータが記録されていました。
無視します。


まとめ

Content Security Policy の report を集計し、定義を修正しました。以下、まとめます。

  • Googleアドセンス を使っていると、よくわからないドメインにアクセスがあり、且つ、不定期で変わっている?
    そのため、Googleアドセンス を使っている限り、report-only を外すのはとても難しいように思う。

  • 自ドメインも、サイトのドメインリダイレクト設定如何では policy に定義したほうがいい。

  • 外部サービスのタグを埋め込む場合も、見直しは必要。

以上です。

コメント