HSTS Super Cookies について

この概要を聞いてピン、と来る人もいるかと思いますがHSTSは「ブラウザ内に情報を保存する」という仕組みになっていまして、それが今回の現象につながっています。
HSTSではアドレスの一文字一文字に対してtrueかfalseのbitに変換、それをバイナリ値(PIN、と言います)としてブラウザ内に保存します。そうすることで20億以上のタグ付けが可能になります。上で表示した組み合わせはこのバイナリ値をbase36変換したものです。
プライバシーモードでもiPhoneでも追跡? エンジニアが知っておくべき「HSTS Super Cookies」 | Developers.IO

ピン、と来なかったのであれこれ考えた。

まずこのサイトのソースを見ると以下のようなリクエストが発行されている。

http://1f-hsts-lab.radicalresearch.co.uk/hsts/get?cb=window['hsts']._['w']
:
http://a-hsts-lab.radicalresearch.co.uk/hsts/get?cb=window['hsts']._['b']
http://9-hsts-lab.radicalresearch.co.uk/hsts/get?cb=window['hsts']._['a']
:
http://0-hsts-lab.radicalresearch.co.uk/hsts/get?cb=window['hsts']._['1']
http://1f-hsts-lab.radicalresearch.co.uk/hsts/get?cb=window['hsts']._['0']

サブドメインが 0-hsts-lab から 1f-hsts-lab まであって、そのうち 1f-hsts-lab が重複しているので全部で 33 個のリクエストが発行される。それぞれで Strict-Transport-Security を発行するとクライアントはこれらサブドメインHTTPS での接続が強制されることになる。

これを利用しサブドメインごとに HSTS の有無に変化をつけることで、各ブラウザに対しユニークな HSTS の設定パターンを記憶させることができる。このパターンをエンコードすることで "Super Cookies" とするのだろう。あるブラウザに対してはあるサブドメインの HSTS が有効で、他のブラウザではそれとは異なるサブドメインのパターンの HSTS が有効になることで、各ブラウザを識別できるようになる。これにより一つのブラウザでの操作を Cookie に頼らず追跡できるようになる。Chrome の場合なら incognito モードもこの HSTS の設定を引き継ぐから、サーバサイドから見た場合同じパターンを得ることができるため、シークレットモードであっても同一のブラウザであることが分かってしまう。

この挙動を確認するため、Chromechrome://net-internals/#hsts を開いて特定のサブドメインの HSTS を削除(例えば 1f-hsts-lab.radicalresearch.co.uk)すると、この ”Super Cookies” のデモはこれまでと異なった識別子を返すようになる。

このへんの話は「参考サイト」(というか本家)にも書いてある。

A number can be encoded as a series of bits (true and false values) and stored by accessing a set of web addresses. Each web address responds with HSTS enabled or disabled depending on the address. Once the number is stored it could be read by other sites in the future. Reading the number just requires testing if requests for the same web addresses are redirected or not.
RadicalResearch HSTS Super Cookies

arstechnica にはもう少し詳しく書いてある。

For any one site, HSTS can be used to hold only a single binary value—either on or off. To work around this limitation, Greenhalgh strings together 32 sites, adds all of the ons and offs, and stores them as a binary number. The result is the ability to uniquely tag more than two billion individual browsers. To make it easier on the website, the decimal number he stores is converted into a base36 string, so 169ze7 is used to represent 71009647, or lm8nsf is used to represent 1307145327.
Browsing in privacy mode? Super Cookies can track you anyway | Ars Technica

この手法は目的こそ異なれどアイデアとしてはかつて「楽天ad4U」として行われていたことに近いと感じる。これは大量のリンクが差し込まれユーザが当該リンクを訪問済みかどうかを調べるというもの。これはユーザの閲覧履歴を(不当に)調べるものだが、見方を変えればブラウザの特定(絞り込み)にも使えただろう。
高木浩光@自宅☆の日記 - 楽天ad4Uの隠しリンクを露出させるユーザスタイルシート