Skip to content

Instantly share code, notes, and snippets.

@azu
Last active August 17, 2019 20:04
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save azu/bacfcec3b4c209773dbae1127e7a709e to your computer and use it in GitHub Desktop.
Save azu/bacfcec3b4c209773dbae1127e7a709e to your computer and use it in GitHub Desktop.
Firefoxのトラッキングブロックについてのメモ

Firefoxのトラッキングブロックについて


Anti-tracking


Anti-tracking

  • Improve page load performance
  • Remove Cross-site tracking
    • トラッキングクッキー
    • localStorageへのアクセスを防止する

Why


仮説と目的

  • FastBlock - PHD - Google ドキュメント
  • TB(Tracking Block)についての仮説
    • TBはFirefoxの"Speed"にプラスの影響を与える可能性がある
    • TBはページロードのパフォーマンスを改善する可能性がある
    • TBはページの破損(breakage)といった悪影響を及ぼさないだろう
  • まとめ: Improve speed without breakage

Slow Tracking Script


Firefox Nightly

  • Fast Block
  • ルールベースのブロッキング(disconnectの2種類のルール)
    • Private mode
    • デフォルト
  • サードパーティトラッキングCookieのブロック

First-Party and Third-Party

ファーストパーティCookie(Same-site cookie)k

  • 見ているドメインと同じドメインに紐づくもの

サードパーティCookie

  • 見ているドメインとは異なるドメインに紐づくもの

トラッキング

トラッキング (行動追跡) は一般的に、ユーザーの複数のサイトにまたがる閲覧データを収集することを指します。 -- https://support.mozilla.org/ja/kb/tracking-protection

  • ただし動作については未定義
  • Firefoxではサードパーティ + リストに入っているものをトラッキングスクリプトとして扱う

トラッカー

トラッキングをするもの


Firefoxの実装


"トラッキング"の判定

  • Firefoxにおける"トラッキング"スクリプトとは何かを実装から見ていく
    • コンテンツブロックで"トラッカー"をブロックするとあるが、何をブロックするのかは載ってない
  • Security/Safe Browsing - MozillaWiki
    • Safe Browsingなどを扱うURLClassifierあたりで実装されている

    if ((shouldEnableTrackingProtection && inTrackingTable) ||
        (shouldEnableTrackingAnnotation && inAnnotationTable)) {
      // Valid blacklist result, need to check the whitelist(s) next
      return OnBlacklistResult(NS_ERROR_MAYBE_TRACKING_URI, inTrackingTable,
                               inAnnotationTable);
    }
  • TrackingURICallback::OnBlacklistResult
    • blacklistにマッチしたら
    • このうちwhitelistにマッチしない => tracking
      • 次の2種類のURLがtrackingになっている
      • NS_ERROR_TRACKING_ANNOTATION_URI
      • NS_ERROR_TRACKING_URI

📝 trackingの違い

  • NS_ERROR_TRACKING_URI テーブルに入ってる純粋なトラッカー
  • NS_ERROR_TRACKING_ANNOTATION_URI テーブル外のトラッカー
  // The lookup failed to match at least one of the active whitelists
  // (tracking protection takes precedence over tracking annotations)
  return OnWhitelistResult(isTracker ? NS_ERROR_TRACKING_URI :
                           NS_ERROR_TRACKING_ANNOTATION_URI);
void
HttpBaseChannel::SetIsTrackingResource(bool aIsThirdParty)
{
  LOG(("HttpBaseChannel::SetIsTrackingResource thirdparty=%d %p",
       static_cast<int>(aIsThirdParty), this));

  if (aIsThirdParty) {
    MOZ_ASSERT(!mIsFirstPartyTrackingResource);
    mIsThirdPartyTrackingResource = true;
  } else {
    MOZ_ASSERT(!mIsThirdPartyTrackingResource);
    mIsFirstPartyTrackingResource = true;
  }

  if (mLoadInfo) {
    MOZ_ALWAYS_SUCCEEDS(mLoadInfo->SetIsTracker(true));
  }
}

最終的にTrackingResource is third party or first party && リストマッチ

NS_IMETHODIMP
HttpBaseChannel::GetIsTrackingResource(bool* aIsTrackingResource)
{
  MOZ_ASSERT(!(mIsFirstPartyTrackingResource && mIsThirdPartyTrackingResource));
  *aIsTrackingResource =
    mIsThirdPartyTrackingResource || mIsFirstPartyTrackingResource;
  return NS_OK;
}

What is Trakcer?

トラッキング (行動追跡) は一般的に、ユーザーの複数のサイトにまたがる閲覧データを収集することを指します。 -- https://support.mozilla.org/ja/kb/tracking-protection


Yahoo!

  • propertiers
    • flicker.com
    • tumblr.com
    • yahoo.com
    • yahoo.co.jp
  • resources
    • adinterax.com
    • yahooapis.com
    • yimg.com

unvisit blockingに利用される


  • isThridParty
  • ThirdPartyUtil::GetBaseDomain
  • BaseDomain同士の一致を見る
  • a.example.com === b.example.com
  • a.example.com !== c.ex.com

Background

歴史

ITP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment